@lobu/runtime-server 24.3.0 → 24.4.0
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/dist/catalogs/skills.json +1 -1
- package/dist/component.json +1 -1
- package/dist/db/migrations/20261101010000_public_source_type_references.sql +157 -0
- package/dist/dependencies.bun.lock +59 -57
- package/dist/owletto/dist/assets/_-DIK0ae_S.js +2 -0
- package/dist/owletto/dist/assets/_-gTbcArpS.js +3 -0
- package/dist/owletto/dist/assets/_agentId-DOmcJZfk.js +2 -0
- package/dist/owletto/dist/assets/_agentId-DW6wRCVC.js +2 -0
- package/dist/owletto/dist/assets/{_automationId-CfFFAYK1.js → _automationId-B9IcDYBu.js} +2 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-C6PmMPTA.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-BrJ8Pzze.js +2 -0
- package/dist/owletto/dist/assets/{_conversationId-D3vuAQPe.js → _conversationId-BpJAeYYW.js} +2 -2
- package/dist/owletto/dist/assets/_eventId-DarQJo0G.js +2 -0
- package/dist/owletto/dist/assets/_name-DtmNTcUm.js +2 -0
- package/dist/owletto/dist/assets/{_owner-oBX68rb9.js → _owner-Db8at3hk.js} +3 -3
- package/dist/owletto/dist/assets/_shape-6iFA8A86.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-CXkHn3Nl.js +2 -0
- package/dist/owletto/dist/assets/{_slug-B2g5qzn3.js → _slug-DBOuBLoX.js} +2 -2
- package/dist/owletto/dist/assets/_viewKey-DC27aIN9.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-DuYDieln.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-38lHBvjO.js → accept-invitation-BbDCVvur.js} +2 -2
- package/dist/owletto/dist/assets/activity-route-view-V4ftmSN7.js +2 -0
- package/dist/owletto/dist/assets/{agent-card-controls-DiU7Un5w.js → agent-card-controls-99mG6H5k.js} +2 -2
- package/dist/owletto/dist/assets/agent-client-setup-list-kMmqQSrf.js +4 -0
- package/dist/owletto/dist/assets/agent-connect-pages-B-NPTFs6.js +2 -0
- package/dist/owletto/dist/assets/{agent-editor-form-QrIDroFL.js → agent-editor-form-DfMTSIvj.js} +2 -2
- package/dist/owletto/dist/assets/{agent-guardrails-route-CyoGSxcZ.js → agent-guardrails-route-BvGgfd-h.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-CamDtzHY.js → agent-loading-shells-Dnmb6W5Y.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-CgsQ8BK_.js → agent-permissions-matrix-CbhXlbgY.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-lWbXKEm1.js → agent-skill-context-V__2i6Vl.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skills-route-D-w3tY_2.js → agent-skills-route-DFXr_bHp.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-CLqpn5Tb.js → agent-subpage-shell-DWzljvFb.js} +2 -2
- package/dist/owletto/dist/assets/{agent-thread-CsRexwTv.js → agent-thread-DQIr20H-.js} +4 -4
- package/dist/owletto/dist/assets/agents-CLbeiqTR.js +2 -0
- package/dist/owletto/dist/assets/{agents-workbench-CmGrMvPC.js → agents-workbench-C8bTa2rv.js} +2 -2
- package/dist/owletto/dist/assets/{app._appId-BO7G38fL.js → app._appId-Bsq40nak.js} +2 -2
- package/dist/owletto/dist/assets/{automation-detail-content-DMYxs6F6.js → automation-detail-content-C9Cgr5Zj.js} +2 -2
- package/dist/owletto/dist/assets/automations-CLbeiqTR.js +2 -0
- package/dist/owletto/dist/assets/{calendar-DDCCSPW6.js → calendar-DMq3Dtqy.js} +2 -2
- package/dist/owletto/dist/assets/{callback-DFciMR8u.js → callback-B-CAz-bK.js} +2 -2
- package/dist/owletto/dist/assets/{card-BCsbrdGs.js → card-SFtxv9f2.js} +2 -2
- package/dist/owletto/dist/assets/{claim-BRua2b_7.js → claim-DrxIRWKt.js} +2 -2
- package/dist/owletto/dist/assets/client-activity-scopes-boZOHuPW.js +2 -0
- package/dist/owletto/dist/assets/{client-rows-DiJQ5D1z.js → client-rows-BJ2PxM4J.js} +2 -2
- package/dist/owletto/dist/assets/clients-C7Lnuc3S.js +2 -0
- package/dist/owletto/dist/assets/{code-editor-BFZa4EIt.js → code-editor-rX0t1g5C.js} +2 -2
- package/dist/owletto/dist/assets/connect-BcwgytDV.js +2 -0
- package/dist/owletto/dist/assets/{connect-menu-D2K4tmvW.js → connect-menu-BF-AlunU.js} +2 -2
- package/dist/owletto/dist/assets/connect._clientId-sDypRDeN.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-C9OkW1tv.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.activity-Dc6HYr55.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId.index-BTI5JXA3.js → connected._clientId.index-C6qbqgwF.js} +2 -2
- package/dist/owletto/dist/assets/connection-88YzIBK9.js +2 -0
- package/dist/owletto/dist/assets/connection-feed-detail-D7pnWaFB.js +2 -0
- package/dist/owletto/dist/assets/{connections-browser-BMV8bf54.js → connections-browser-DDJQh8Na.js} +2 -2
- package/dist/owletto/dist/assets/{connector-boxes-DqZA-FdG.js → connector-boxes-DDX7Ebc4.js} +2 -2
- package/dist/owletto/dist/assets/connector-provenance-Th8ymGec.js +2 -0
- package/dist/owletto/dist/assets/{connector-scope-lists-CJYz53YF.js → connector-scope-lists-BibdzKl1.js} +2 -2
- package/dist/owletto/dist/assets/{connectors-BroKpwhB.js → connectors-BqwgLUUK.js} +2 -2
- package/dist/owletto/dist/assets/consent-BR5U7dwb.js +2 -0
- package/dist/owletto/dist/assets/copy-button-2swYh4jb.js +2 -0
- package/dist/owletto/dist/assets/{core.esm-A1UnFbGs.js → core.esm-CHnfRiEM.js} +2 -2
- package/dist/owletto/dist/assets/{create-c94SPL21.js → create-BsPVnRpG.js} +2 -2
- package/dist/owletto/dist/assets/create-CVPYVOR5.js +2 -0
- package/dist/owletto/dist/assets/create-QFjmhOEU.js +2 -0
- package/dist/owletto/dist/assets/{create-automation-form-DHW6OUoS.js → create-automation-form-DmCOFbRT.js} +3 -3
- package/dist/owletto/dist/assets/create._connectorKey-DLDDVtLS.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-xxpD1P2-.js → cronstrue-CKwjNYgj.js} +2 -2
- package/dist/owletto/dist/assets/device-CKup7kvB.js +2 -0
- package/dist/owletto/dist/assets/{device-pin-tombstone-B_te59GE.js → device-pin-tombstone-xGhCTU5_.js} +2 -2
- package/dist/owletto/dist/assets/{device._deviceId-ZU09qrot.js → device._deviceId-B1H_ivDT.js} +2 -2
- package/dist/owletto/dist/assets/{entity-avatar-CEV4ttUQ.js → entity-avatar-HloBoalJ.js} +2 -2
- package/dist/owletto/dist/assets/{entity-options-DJv2EhVV.js → entity-options-BSW_EG0W.js} +2 -2
- package/dist/owletto/dist/assets/entity-page-D-WDWrAe.js +2 -0
- package/dist/owletto/dist/assets/entity-type-page-BCBdFndu.js +2 -0
- package/dist/owletto/dist/assets/{event-card-CBlsG32u.js → event-card-Mcxv56DG.js} +2 -2
- package/dist/owletto/dist/assets/event-detail-DXifj49J.js +2 -0
- package/dist/owletto/dist/assets/{events-feed-VfU4csn2.js → events-feed-BysC9HgU.js} +2 -2
- package/dist/owletto/dist/assets/{filter-bar-COU0sBFQ.js → filter-bar-BQm-ubB1.js} +2 -2
- package/dist/owletto/dist/assets/{full-page-spinner-C1Q_jEzD.js → full-page-spinner-BMiXl54z.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-D7W80sJO.js +2 -0
- package/dist/owletto/dist/assets/identity-N0cAO9BR.js +2 -0
- package/dist/owletto/dist/assets/{index-008wj-Pz.js → index-4gCDI7m4.js} +1601 -1601
- package/dist/owletto/dist/assets/{index-DQxzeM37.js → index-B4wXJwQY.js} +2 -2
- package/dist/owletto/dist/assets/{index-BrDP4PCs.js → index-BNaI5GpS.js} +2 -2
- package/dist/owletto/dist/assets/index-BUUrHuJJ.js +2 -0
- package/dist/owletto/dist/assets/index-BqrvJmLh.js +2 -0
- package/dist/owletto/dist/assets/{index-DNtYqkiA.js → index-C-WaHj1Y.js} +2 -2
- package/dist/owletto/dist/assets/index-CnvQEA5V.js +2 -0
- package/dist/owletto/dist/assets/index-Cq7P2c_E.js +2 -0
- package/dist/owletto/dist/assets/{index-DFyBbp7b.js → index-CzoK57xp.js} +2 -2
- package/dist/owletto/dist/assets/index-D3omC3Us.js +2 -0
- package/dist/owletto/dist/assets/{index-yIub2xUM.js → index-D4-uel59.js} +2 -2
- package/dist/owletto/dist/assets/index-DDGdlQrt.css +1 -0
- package/dist/owletto/dist/assets/index-DFEW7hMg.js +2 -0
- package/dist/owletto/dist/assets/index-DVV-WWuT.js +2 -0
- package/dist/owletto/dist/assets/{index-CAVcR9za.js → index-DduQ_e9q.js} +2 -2
- package/dist/owletto/dist/assets/index-DutlI1d-.js +2 -0
- package/dist/owletto/dist/assets/{json-diff-LE_vNZrM.js → json-diff-E5D-NGYT.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-Kzxi2OXB.js → list-skeleton-Bp4HNgJ9.js} +2 -2
- package/dist/owletto/dist/assets/login-7F48UJGx.js +2 -0
- package/dist/owletto/dist/assets/{logout-Dt_VDilG.js → logout-DxmfsVKD.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-De75CR7W.js → member-scope-gate-vp3FihBD.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-CfDmjhDl.js +74 -0
- package/dist/owletto/dist/assets/{model-udnQ_S43.js → model-Dn40BUzs.js} +2 -2
- package/dist/owletto/dist/assets/{model-selector-3l9lY50C.js → model-selector-88PJnyTq.js} +2 -2
- package/dist/owletto/dist/assets/models-BBK_n2RP.js +2 -0
- package/dist/owletto/dist/assets/{new-BOwIHkre.js → new-4ruWHLR5.js} +2 -2
- package/dist/owletto/dist/assets/{new-BbdwuJPm.js → new-CvX8_gIb.js} +2 -2
- package/dist/owletto/dist/assets/new-gMD1PHTL.js +2 -0
- package/dist/owletto/dist/assets/oauth-workspace-access-D9BNmyMY.js +2 -0
- package/dist/owletto/dist/assets/organization-BHcp5Pzg.js +2 -0
- package/dist/owletto/dist/assets/peek-pane-content-0sa10jER.js +2 -0
- package/dist/owletto/dist/assets/{permissions-CfoY4WFY.js → permissions-hhxosugv.js} +2 -2
- package/dist/owletto/dist/assets/proposal-review-shell-B4CSiyLB.js +2 -0
- package/dist/owletto/dist/assets/public-shell-ready-CsenJeXa.js +2 -0
- package/dist/owletto/dist/assets/record-activity-D7bRaMk2.js +2 -0
- package/dist/owletto/dist/assets/{record-session-D07szzqN.js → record-session-CWXnCVln.js} +2 -2
- package/dist/owletto/dist/assets/{renderer-AJxSmE3-.js → renderer-7EGgTVX0.js} +2 -2
- package/dist/owletto/dist/assets/reset-password-CFUzxH7m.js +2 -0
- package/dist/owletto/dist/assets/runs-BPtQBTRN.js +2 -0
- package/dist/owletto/dist/assets/{runs-panel-LnGpHCAQ.js → runs-panel-Bj63_hb9.js} +2 -2
- package/dist/owletto/dist/assets/{schema-type-editor-panel-C_Es0qDf.js → schema-type-editor-panel-CAhOB648.js} +2 -2
- package/dist/owletto/dist/assets/{settings-gGYXbFfd.js → settings-Dg6nxKyw.js} +2 -2
- package/dist/owletto/dist/assets/settings-KJJ6WihO.js +2 -0
- package/dist/owletto/dist/assets/skills-ayt06_o2.js +2 -0
- package/dist/owletto/dist/assets/{source-record-panels-CjFPgKKJ.js → source-record-panels-Bh5F4C5K.js} +2 -2
- package/dist/owletto/dist/assets/{status-dot-CSBtKT4g.js → status-dot-D3FoDRcc.js} +2 -2
- package/dist/owletto/dist/assets/{table-DHM-vCxP.js → table-DFcJRNk7.js} +2 -2
- package/dist/owletto/dist/assets/{use-automations-C4TSie1i.js → use-automations-BHoV0dLs.js} +2 -2
- package/dist/owletto/dist/assets/{use-mention-search-PfZrNbu_.js → use-mention-search-C3rWLuKm.js} +2 -2
- package/dist/owletto/dist/assets/{use-scroll-sentinel-D-fJx_Md.js → use-scroll-sentinel-Ct-jt7O0.js} +2 -2
- package/dist/owletto/dist/assets/view-param-filters-mKoqDsaD.js +2 -0
- package/dist/owletto/dist/assets/{views-access-required-2ubIf_3N.js → views-access-required-DHrDO333.js} +2 -2
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +1978 -1199
- package/npm-shrinkwrap.json +286 -272
- package/package.json +1 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +45 -20
- package/vendor/core/dist/contracts/tools/manage-entity.js +17 -5
- package/vendor/core/dist/index.d.ts +1 -0
- package/vendor/core/dist/index.js +4 -1
- package/vendor/core/dist/logger.js +8 -2
- package/vendor/core/dist/otel.d.ts +13 -2
- package/vendor/core/dist/otel.js +67 -41
- package/vendor/core/dist/trace-context.d.ts +12 -0
- package/vendor/core/dist/trace-context.js +50 -0
- package/vendor/core/package.json +1 -1
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-XKF0m81R.js +0 -3
- package/dist/owletto/dist/assets/_-e8MbEBtw.js +0 -2
- package/dist/owletto/dist/assets/_agentId-Cv9goIFf.js +0 -2
- package/dist/owletto/dist/assets/_agentId-emObu67X.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-D6NKXSOE.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-DFrkLLTU.js +0 -2
- package/dist/owletto/dist/assets/_eventId-BV5SQaUA.js +0 -2
- package/dist/owletto/dist/assets/_name-DjtJMop4.js +0 -2
- package/dist/owletto/dist/assets/_shape-C4lLPAwI.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-Cw-7q6hI.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-CIKGCtdK.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-Dx4kJo7o.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-voRYSM3a.js +0 -2
- package/dist/owletto/dist/assets/agent-client-setup-list-Bkyw22GW.js +0 -5
- package/dist/owletto/dist/assets/agent-connect-pages-CpBxQCpx.js +0 -2
- package/dist/owletto/dist/assets/agents-DzH_FFKU.js +0 -2
- package/dist/owletto/dist/assets/automations-DzH_FFKU.js +0 -2
- package/dist/owletto/dist/assets/client-activity-scopes-BLIy1Zc3.js +0 -2
- package/dist/owletto/dist/assets/clients-8-EpRjsm.js +0 -2
- package/dist/owletto/dist/assets/connect-C0cHE9Xl.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-D4EG5a0v.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-DhoCT6sT.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.activity-Dn4qw2Us.js +0 -2
- package/dist/owletto/dist/assets/connection-X9VU9Ijm.js +0 -2
- package/dist/owletto/dist/assets/connection-feed-detail-B6ydKasK.js +0 -2
- package/dist/owletto/dist/assets/connector-provenance-BIg8P8WY.js +0 -2
- package/dist/owletto/dist/assets/consent-fzLN-Qy7.js +0 -2
- package/dist/owletto/dist/assets/copy-button-Df7QXE0w.js +0 -2
- package/dist/owletto/dist/assets/create-BjwsYarn.js +0 -2
- package/dist/owletto/dist/assets/create-Dzr4mlr0.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-DLLn2nej.js +0 -2
- package/dist/owletto/dist/assets/device-C3AEoL5c.js +0 -2
- package/dist/owletto/dist/assets/entity-page-BUghWZ1s.js +0 -2
- package/dist/owletto/dist/assets/entity-type-page-Lf6ONdpf.js +0 -2
- package/dist/owletto/dist/assets/event-detail-BKSGEOdW.js +0 -2
- package/dist/owletto/dist/assets/guardrails-6ZJv1uzM.js +0 -2
- package/dist/owletto/dist/assets/identity-BaFLmbSo.js +0 -2
- package/dist/owletto/dist/assets/index-BaetvYLa.js +0 -2
- package/dist/owletto/dist/assets/index-BiEf5xOE.css +0 -1
- package/dist/owletto/dist/assets/index-BuXIeK7D.js +0 -2
- package/dist/owletto/dist/assets/index-CMLfWGPU.js +0 -2
- package/dist/owletto/dist/assets/index-D0YEYP7N.js +0 -2
- package/dist/owletto/dist/assets/index-DkO0nPex.js +0 -2
- package/dist/owletto/dist/assets/index-KlRId0g6.js +0 -2
- package/dist/owletto/dist/assets/index-Ywnqi4A6.js +0 -2
- package/dist/owletto/dist/assets/index-xnxhf3Op.js +0 -2
- package/dist/owletto/dist/assets/login-DWOT6jtS.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-p2vIbfkC.js +0 -74
- package/dist/owletto/dist/assets/models-CQj7GIOp.js +0 -2
- package/dist/owletto/dist/assets/new-DTuFCQhV.js +0 -2
- package/dist/owletto/dist/assets/oauth-workspace-access-QPo4YwRX.js +0 -2
- package/dist/owletto/dist/assets/organization-BDzjnqPf.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-D7yt0PrA.js +0 -2
- package/dist/owletto/dist/assets/proposal-review-shell-CVkLnnKo.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-DXUTTGGp.js +0 -2
- package/dist/owletto/dist/assets/record-activity-BXhvJbd9.js +0 -2
- package/dist/owletto/dist/assets/reset-password-kRYyQuTY.js +0 -2
- package/dist/owletto/dist/assets/runs-lG2ChtOt.js +0 -2
- package/dist/owletto/dist/assets/settings-CEAOg7fr.js +0 -2
- package/dist/owletto/dist/assets/skills-BOL5c_Tk.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-DkX4YdDT.js +0 -2
package/dist/owletto/dist/assets/{device._deviceId-ZU09qrot.js → device._deviceId-B1H_ivDT.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{aN as Y,ib as ne,ic as U,r as j,j as e,id as L,B as b,a5 as z,g1 as C,aD as G,ax as te,g4 as R,S as I,b4 as B,dS as ae,dU as ie,C as ce,dY as oe,ie as re,Y as le,v as de,aC as me,ig as ue,ih as xe,ii as he,aF as pe,ay as ge,aG as P,b3 as q,L as E,ij as fe,ik as ve,aT as je,il as ye,im as be,hy as Ne,bf as ke,gr as _e,io as K,I as we,b9 as Ce,bg as Se,gs as $e,gt as O,bk as De,ip as F,av as Pe}from"./index-008wj-Pz.js";import{c as V,C as Le,R as ze}from"./device-pin-tombstone-B_te59GE.js";import{R as Re,S as Ie,g as Ae}from"./runs-panel-LnGpHCAQ.js";import{c as Ee}from"./connection-label-BobuYiAG.js";import{w as M}from"./workspace-label-o_QfBuCM.js";import"./connector-scope-lists-CJYz53YF.js";import"./status-dot-CSBtKT4g.js";import"./use-scroll-sentinel-D-fJx_Md.js";import"./use-automations-C4TSie1i.js";import"./clients-8-EpRjsm.js";import"./runs-lG2ChtOt.js";import"./filter-bar-COU0sBFQ.js";import"./calendar-DDCCSPW6.js";import"./table-DHM-vCxP.js";function Me(s,n,o){const h=new Set(s.capabilities??[]),m=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key)),r=new Set(J(s,o).map(t=>t.connector_key));return n.filter(t=>Y(t)&&!!t.required_capability&&h.has(t.required_capability)&&!m.has(t.key)&&!r.has(t.key))}function J(s,n){return s.organization_slug===n?s.update_required:[]}function Be(s,n,o){const h=s.organization_slug;if(!h||h===o)return[];const m=new Set(n.map(t=>t.key)),r=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key));return s.connectors.filter(t=>t.organization_slug!==h||m.has(t.connector_key)||r.has(t.connector_key)?!1:(r.add(t.connector_key),!0))}function Te({device:s,organizationId:n,ownerSlug:o,connectable:h,unavailable:m}){const r=ne(),t=U(),[u,p]=j.useState(null),[f,a]=j.useState(null),[g,N]=j.useState(null),[v,d]=j.useState([]),x=s.organization_id===n,y=async i=>{p(null),N(null),a(i.key);try{x||await t.mutateAsync({deviceWorkerId:s.id,organizationId:n});const w=await r.mutateAsync({connector_key:i.key,device_worker_id:s.id}),S=w.connection_id??w.connection?.id;if(S===void 0)throw new Error(w.instructions??"The connection was not created.");d($=>[...$.filter(D=>D.connectorKey!==i.key),{connectorKey:i.key,name:i.name,connectionId:S,instructions:w.status==="setup_required"?w.instructions:void 0}])}catch(w){N({key:i.key,message:w instanceof Error?w.message:"Could not connect."})}finally{a(null)}},k=new Set(v.map(i=>i.connectorKey)),l=J(s,o),c=h.filter(i=>!k.has(i.key));return e.jsxs("div",{className:"mt-4 space-y-3",children:[v.map(i=>e.jsx(qe,{outcome:i,device:s,organizationId:n},i.connectorKey)),c.length>0?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium",children:"Supported by this device"}),e.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:["Not connected in this workspace yet.",x?null:" Connecting one moves the device here; you will be asked to confirm first."]}),e.jsx("div",{className:"divide-y border-y",children:c.map(i=>e.jsxs("div",{className:"space-y-2 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"min-w-0 flex-1 text-sm font-medium",children:[i.name,i.required_capability&&L[i.required_capability]&&L[i.required_capability]!==i.name?e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:L[i.required_capability]}):null]}),e.jsxs(b,{size:"sm",variant:"outline","aria-label":`Connect ${i.name}`,disabled:f!==null,onClick:()=>x?void y(i):p(i.key),children:[f===i.key?e.jsx(z,{className:"mr-1.5"}):null,"Connect"]})]}),u===i.key?e.jsx(Q,{device:s,ownerSlug:o,title:"Move device to this workspace",intro:`${C(s)} lives in ${s.organization_name??"another workspace"}. A device serves one workspace at a time, so it has to move here before it can be connected.`,confirmLabel:"Move here and connect",onConfirm:()=>void y(i),onCancel:()=>p(null)}):null,g?.key===i.key?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g.message}):null]},i.key))})]}):null,l.length>0?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"text-xs font-medium",children:"Update Lobu on this device"}),e.jsx("ul",{className:"mt-1 space-y-1 text-xs text-muted-foreground",children:l.map(i=>e.jsx("li",{children:`${i.display_name} — this device has ${i.device_version}, this workspace uses ${i.workspace_version}`},i.connector_key))})]}):null,m.length>0?e.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:m.map(i=>e.jsx("li",{children:`${i.display_name} — set up on this device in ${s.organization_name??"its home workspace"}, not available in this workspace yet`},i.connector_key))}):null]})}function Q({device:s,ownerSlug:n,title:o,intro:h,aftermath:m,confirmLabel:r,pending:t=!1,onConfirm:u,onCancel:p}){const f=s.connector_count,a=s.connectors.filter(g=>g.organization_slug===n).length;return e.jsxs("div",{role:"alertdialog","aria-label":o,className:"space-y-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs",children:[e.jsx("p",{children:h}),e.jsxs("p",{className:"text-muted-foreground",children:[f>0?`Moving pauses and unpins all ${f} connection${f===1?"":"s"} pinned to it${a>0?`, including ${a} in this workspace`:""}. They stay paused until you reconnect them.`:"It has no pinned connections, so nothing is paused.",m?` ${m}`:null]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(b,{size:"sm",disabled:t,onClick:u,children:[t?e.jsx(z,{className:"mr-1.5"}):null,r]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:t,onClick:p,children:"Cancel"})]})]})}function qe({outcome:s,device:n,organizationId:o}){const{data:h=[],isLoading:m}=G(o,{connectionIds:[s.connectionId]}),r=h.find(p=>p.id===s.connectionId),t=C(n);if(m)return e.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Checking ",s.name,"…"]});const u=[];if(!r)u.push(`${s.name} was created but could not be loaded yet.`);else if(r.status!=="active"){const p=V(r);u.push(`${s.name} is ${r.status}${p?`: ${p}`:"."}`)}return s.instructions&&u.push(s.instructions),n.online||u.push(`${t} is offline. ${s.name} runs once it reconnects.`),e.jsx("div",{role:"status",className:"rounded-lg border px-3 py-2 text-sm",children:u.length===0?e.jsxs("p",{children:[s.name," is ready on ",t,"."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:[s.name," connected, not ready yet"]}),e.jsx("ul",{className:"mt-1 list-disc pl-4 text-xs text-muted-foreground",children:u.map(p=>e.jsx("li",{children:p},p))})]})})}function H({device:s,organizationId:n,ownerSlug:o,selectedConnection:h,openSettings:m}){const{data:r=[],isLoading:t,isError:u,refetch:p}=te(n),f=new Map(r.map(d=>[d.key,d])),a=new Map,g=[];for(const d of s.connectors){if(d.organization_slug!==o)continue;const x=f.get(d.connector_key);if(!x||!Y(x)){g.push(d);continue}const y=x.required_capability??`connector:${x.key}`,k=a.get(y)??{key:y,name:x.name,connections:[]};k.name=L[y]??x.name,k.connections.push(d),a.set(y,k)}const N=Me(s,r,o),v=Be(s,r,o);return e.jsxs(e.Fragment,{children:[e.jsxs(R,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),s.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!n||t?e.jsx(I,{className:"h-24 w-full"}):u?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load capability settings."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void p(),children:"Retry"})]}):a.size===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No native connections on this device in this workspace."}):e.jsx("div",{className:"divide-y border-y",children:[...a.values()].map(d=>e.jsx(W,{group:d,deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:f,selectedConnection:h,openSettings:m},d.key))}),n&&!t&&!u?e.jsx(Te,{device:s,organizationId:n,ownerSlug:o,connectable:N,unavailable:v}):null,B(s)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),n&&g.length>0&&!t&&!u?e.jsxs(R,{title:"Apps and sources",count:String(g.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:[...new Set(g.map(d=>d.connector_key))].map(d=>e.jsx(W,{group:{key:d,name:f.get(d)?.name??d,connections:g.filter(x=>x.connector_key===d)},deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:f,selectedConnection:h,openSettings:m},d))})]}):null]})}function W({group:s,deviceId:n,organizationId:o,ownerSlug:h,definitionsByKey:m,selectedConnection:r,openSettings:t}){const u=s.connections.some(a=>a.connection_id===r),[p,f]=j.useState(u);return j.useEffect(()=>{u&&r!==void 0&&f(!0)},[u,r]),e.jsxs(ae,{open:p,onOpenChange:f,children:[e.jsxs(ie,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(ce,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:s.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:s.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":s.connections.length>1?`${s.connections.length} connections`:"Configured"})]}),e.jsx(oe,{className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:s.connections.map(a=>e.jsx(Ke,{summary:a,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m.get(a.connector_key),openSettings:a.connection_id===r&&t},a.connection_id))})})]})}function Ke({summary:s,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m,openSettings:r}){const{data:t=[],isLoading:u,isError:p,refetch:f}=G(o,{connectionIds:[s.connection_id]}),a=t.find(v=>v.id===s.connection_id&&v.device_worker_id===n),g=m?.name??s.connector_key,N=a?V(a):null;return e.jsxs("section",{id:`connection-${s.connection_id}`,"aria-label":g,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:Ee(a)}),e.jsx("span",{children:a.status})]}):null,u||!o?e.jsx(I,{className:"h-24 w-full"}):p?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load this connection."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void f(),children:"Retry"})]}):a?e.jsxs(e.Fragment,{children:[N?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:N}):null,e.jsx("div",{className:"mb-4",children:e.jsx(re,{connection:a})}),e.jsx(Le,{connection:a,connectorDef:m,ownerSlug:h,openSettings:r,showActivity:!1,showShare:!1,embedded:!0})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection is no longer available on this device."})]})}function Oe({device:s,ownerSlug:n}){const o=j.useId(),{data:h=[]}=le(),m=U(),[r,t]=j.useState(!1),[u,p]=j.useState(null),[f,a]=j.useState(null),g=h.filter(l=>l.is_member).map(l=>({id:l.id,name:l.name,isPersonal:l.is_personal===!0})),N=g.find(l=>l.id===s.organization_id),v=N?M(N):s.organization_name??"No workspace",d=g.filter(l=>l.id!==s.organization_id),x=d.find(l=>l.id===u)??null,y=()=>{t(!1),p(null)},k=async l=>{a(null);try{await m.mutateAsync({deviceWorkerId:s.id,organizationId:l}),y()}catch(c){a(c instanceof Error?c.message:"Could not move the device.")}};return e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Workspace: "}),v]}),!r&&d.length>0?e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{a(null),t(!0)},children:"Change workspace"}):null]}),r?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("label",{htmlFor:o,className:"text-xs text-muted-foreground",children:"Move to"}),e.jsxs("select",{id:o,value:u??"",disabled:m.isPending,onChange:l=>p(l.target.value||null),className:"h-8 rounded-md border border-input bg-background px-2 text-sm",children:[e.jsx("option",{value:"",children:"Choose a workspace"}),d.map(l=>e.jsx("option",{value:l.id,children:M(l)},l.id))]}),x?null:e.jsx(b,{size:"sm",variant:"ghost",onClick:y,children:"Cancel"})]}):null,x?e.jsx(Q,{device:s,ownerSlug:n,title:`Move device to ${x.name}`,intro:`Move ${C(s)} from ${v} to ${M(x)}?`,aftermath:`It is set up fresh in ${x.name}, with its connections there private to you until you share them.`,confirmLabel:"Move device",pending:m.isPending,onConfirm:()=>void k(x.id),onCancel:y}):null,f?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f}):null]})}function Fe({ownerSlug:s,deviceId:n,organizationId:o,selectedConnection:h,openSettings:m}){const r=de(),{data:t=[],isLoading:u,isError:p,refetch:f}=me(),a=ue(),g=xe(),[N,v]=j.useState(!1),[d,x]=j.useState(!1),[y,k]=j.useState(""),l=he(t,n),c=l&&pe(l,s)?l:void 0,i=c?.id??n,{data:w=[]}=ge(o,{profileKind:"browser_session"}),S=j.useMemo(()=>w.filter(_=>_.device_worker_id===i&&_.status!=="revoked"),[w,i]),$=c?.label?.trim()??"";if(j.useEffect(()=>{d||k($)},[$,d]),u)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-6 w-6 rounded"}),e.jsx(I,{className:"h-5 w-40"})]}),e.jsx(ze,{})]});if(p)return e.jsx(P,{children:e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load this device."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void f(),children:"Retry"})]})});if(!c&&l&&o)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{platform:B(l),className:"h-5 w-5"}),e.jsx("h1",{className:"text-base font-semibold",children:C(l)})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This device lives in"," ",l.organization_name??"another workspace",", not this workspace."]}),e.jsx(H,{device:l,organizationId:o,ownerSlug:s})]});if(!c)return e.jsxs(P,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const D=fe(c),A=D?ve(s,D,je()):void 0,X=B(c),Z=ye(c.app_version),ee=be(c,Z),T=()=>{const _=y.trim(),se=c.label?.trim()??"";if(_===se){x(!1);return}g.mutate({deviceWorkerId:c.id,label:_.length===0?null:_},{onSuccess:()=>x(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(Ne,{header:e.jsx(_e,{breadcrumb:e.jsx($e,{crumbs:[e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:O,children:"Connectors"},"connectors"),...A?[e.jsx(E,{to:"/$owner/connectors/app/$appId",params:{owner:s,appId:A.id},className:O,children:A.name},"app")]:[]]}),icon:e.jsx(q,{platform:X,className:"h-5 w-5"}),title:d?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(we,{"aria-label":"Device name",value:y,onChange:_=>k(_.target.value),placeholder:C({...c,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:_=>{_.key==="Enter"?(_.preventDefault(),N||T()):_.key==="Escape"&&(v(!1),k(c.label?.trim()??""),x(!1))}}),N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",c.connector_count>0?`and un-pins ${c.connector_count} connector${c.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(b,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(c.id,{onSuccess:()=>{v(!1),r({to:"/$owner/connectors",params:{owner:s},search:{}})}}),children:[a.isPending?e.jsx(z,{className:"mr-1.5"}):null,a.isPending?"Removing...":"Confirm remove"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>v(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{size:"sm",onClick:T,disabled:g.isPending,children:[g.isPending?e.jsx(z,{className:"mr-1.5"}):null,g.isPending?"Saving...":"Save"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:g.isPending,onClick:()=>{k(c.label?.trim()??""),x(!1)},children:"Cancel"}),e.jsxs(b,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:g.isPending||a.isPending,onClick:()=>v(!0),children:[e.jsx(Ce,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove device"]})]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[C(c),e.jsx(b,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{v(!1),k(c.label?.trim()??""),x(!0)},children:e.jsx(Se,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${c.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),c.online?c.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:ee||void 0,caption:`Last seen ${K(new Date(c.last_seen_at),{addSuffix:!0})}${c.last_sync_at?` · Last sync ${K(new Date(c.last_sync_at),{addSuffix:!0})}`:""}`}),children:[e.jsx(Oe,{device:c,ownerSlug:s}),c.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(ke,{className:"h-3.5 w-3.5 shrink-0"}),c.connector_error_count," connector",c.connector_error_count===1?"":"s"," pinned to this device ",c.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(H,{device:c,organizationId:o,ownerSlug:s,selectedConnection:h,openSettings:m}),S.length>0?e.jsx(R,{title:"Browser auth profiles",children:e.jsx(He,{profiles:S})}):null,e.jsx(R,{title:"Runs",children:e.jsx(Re,{scope:{deviceId:i},ownerSlug:s})})]})})}function He({profiles:s}){return s.length===0?null:e.jsx("div",{className:"rounded-lg border",children:e.jsx("ul",{className:"divide-y",children:s.map(n=>e.jsxs("li",{className:"space-y-2 px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:n.display_name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.connector_key??"Any connector"}),n.browser_kind?e.jsxs("span",{children:["· ",n.browser_kind]}):null,n.captured_at?e.jsxs("span",{title:n.captured_at,children:["· captured ",De(n.captured_at)]}):null,typeof n.cookie_count=="number"?e.jsxs("span",{children:["· ",n.cookie_count," cookie",n.cookie_count===1?"":"s"]}):null]})]}),e.jsx(Ie,{status:n.is_expired?"error":Ae(n.status),showDot:!0,children:n.is_expired?"expired":n.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Refresh the session using the connector’s authorization instructions."})]},n.id))})})}function is(){const{owner:s,deviceId:n}=F.useParams(),{connection:o,settings:h}=F.useSearch();return e.jsx(Pe,{owner:s,children:({ownerSlug:m,organizationId:r})=>e.jsx(Fe,{ownerSlug:m,deviceId:n,organizationId:r,selectedConnection:o,openSettings:h})})}export{is as component};
|
|
2
|
-
//# sourceMappingURL=device._deviceId-
|
|
1
|
+
import{aS as Y,i3 as ne,i4 as U,r as j,j as e,i5 as L,B as b,aa as z,fW as C,aI as V,aC as te,fZ as I,S as R,b9 as B,dH as ae,dJ as ie,C as ce,dN as oe,i6 as re,a0 as le,v as de,aH as me,i7 as ue,i8 as xe,i9 as he,aK as pe,aD as fe,aL as P,b8 as q,L as E,ia as ge,ib as ve,aY as je,ic as ye,id as be,hq as Ne,W as ke,gk as _e,ie as K,I as we,be as Ce,bk as Se,gl as $e,gm as H,bo as De,ig as O,aA as Pe}from"./index-4gCDI7m4.js";import{c as G,C as Le,R as ze}from"./device-pin-tombstone-xGhCTU5_.js";import{R as Ie,S as Re,g as Ae}from"./runs-panel-Bj63_hb9.js";import{c as Ee}from"./connection-label-BobuYiAG.js";import{w as M}from"./workspace-label-o_QfBuCM.js";import"./connector-scope-lists-BibdzKl1.js";import"./status-dot-D3FoDRcc.js";import"./use-scroll-sentinel-Ct-jt7O0.js";import"./use-automations-BHoV0dLs.js";import"./clients-C7Lnuc3S.js";import"./runs-BPtQBTRN.js";import"./filter-bar-BQm-ubB1.js";import"./calendar-DMq3Dtqy.js";import"./table-DFcJRNk7.js";function Me(s,n,o){const h=new Set(s.capabilities??[]),m=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key)),r=new Set(J(s,o).map(t=>t.connector_key));return n.filter(t=>Y(t)&&!!t.required_capability&&h.has(t.required_capability)&&!m.has(t.key)&&!r.has(t.key))}function J(s,n){return s.organization_slug===n?s.update_required:[]}function Be(s,n,o){const h=s.organization_slug;if(!h||h===o)return[];const m=new Set(n.map(t=>t.key)),r=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key));return s.connectors.filter(t=>t.organization_slug!==h||m.has(t.connector_key)||r.has(t.connector_key)?!1:(r.add(t.connector_key),!0))}function Te({device:s,organizationId:n,ownerSlug:o,connectable:h,unavailable:m}){const r=ne(),t=U(),[u,p]=j.useState(null),[g,a]=j.useState(null),[f,N]=j.useState(null),[v,d]=j.useState([]),x=s.organization_id===n,y=async i=>{p(null),N(null),a(i.key);try{x||await t.mutateAsync({deviceWorkerId:s.id,organizationId:n});const w=await r.mutateAsync({connector_key:i.key,device_worker_id:s.id}),S=w.connection_id??w.connection?.id;if(S===void 0)throw new Error(w.instructions??"The connection was not created.");d($=>[...$.filter(D=>D.connectorKey!==i.key),{connectorKey:i.key,name:i.name,connectionId:S,instructions:w.status==="setup_required"?w.instructions:void 0}])}catch(w){N({key:i.key,message:w instanceof Error?w.message:"Could not connect."})}finally{a(null)}},k=new Set(v.map(i=>i.connectorKey)),l=J(s,o),c=h.filter(i=>!k.has(i.key));return e.jsxs("div",{className:"mt-4 space-y-3",children:[v.map(i=>e.jsx(qe,{outcome:i,device:s,organizationId:n},i.connectorKey)),c.length>0?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium",children:"Supported by this device"}),e.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:["Not connected in this workspace yet.",x?null:" Connecting one moves the device here; you will be asked to confirm first."]}),e.jsx("div",{className:"divide-y border-y",children:c.map(i=>e.jsxs("div",{className:"space-y-2 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"min-w-0 flex-1 text-sm font-medium",children:[i.name,i.required_capability&&L[i.required_capability]&&L[i.required_capability]!==i.name?e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:L[i.required_capability]}):null]}),e.jsxs(b,{size:"sm",variant:"outline","aria-label":`Connect ${i.name}`,disabled:g!==null,onClick:()=>x?void y(i):p(i.key),children:[g===i.key?e.jsx(z,{className:"mr-1.5"}):null,"Connect"]})]}),u===i.key?e.jsx(Z,{device:s,ownerSlug:o,title:"Move device to this workspace",intro:`${C(s)} lives in ${s.organization_name??"another workspace"}. A device serves one workspace at a time, so it has to move here before it can be connected.`,confirmLabel:"Move here and connect",onConfirm:()=>void y(i),onCancel:()=>p(null)}):null,f?.key===i.key?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f.message}):null]},i.key))})]}):null,l.length>0?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"text-xs font-medium",children:"Update Lobu on this device"}),e.jsx("ul",{className:"mt-1 space-y-1 text-xs text-muted-foreground",children:l.map(i=>e.jsx("li",{children:`${i.display_name} — this device has ${i.device_version}, this workspace uses ${i.workspace_version}`},i.connector_key))})]}):null,m.length>0?e.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:m.map(i=>e.jsx("li",{children:`${i.display_name} — set up on this device in ${s.organization_name??"its home workspace"}, not available in this workspace yet`},i.connector_key))}):null]})}function Z({device:s,ownerSlug:n,title:o,intro:h,aftermath:m,confirmLabel:r,pending:t=!1,onConfirm:u,onCancel:p}){const g=s.connector_count,a=s.connectors.filter(f=>f.organization_slug===n).length;return e.jsxs("div",{role:"alertdialog","aria-label":o,className:"space-y-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs",children:[e.jsx("p",{children:h}),e.jsxs("p",{className:"text-muted-foreground",children:[g>0?`Moving pauses and unpins all ${g} connection${g===1?"":"s"} pinned to it${a>0?`, including ${a} in this workspace`:""}. They stay paused until you reconnect them.`:"It has no pinned connections, so nothing is paused.",m?` ${m}`:null]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(b,{size:"sm",disabled:t,onClick:u,children:[t?e.jsx(z,{className:"mr-1.5"}):null,r]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:t,onClick:p,children:"Cancel"})]})]})}function qe({outcome:s,device:n,organizationId:o}){const{data:h=[],isLoading:m}=V(o,{connectionIds:[s.connectionId]}),r=h.find(p=>p.id===s.connectionId),t=C(n);if(m)return e.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Checking ",s.name,"…"]});const u=[];if(!r)u.push(`${s.name} was created but could not be loaded yet.`);else if(r.status!=="active"){const p=G(r);u.push(`${s.name} is ${r.status}${p?`: ${p}`:"."}`)}return s.instructions&&u.push(s.instructions),n.online||u.push(`${t} is offline. ${s.name} runs once it reconnects.`),e.jsx("div",{role:"status",className:"rounded-lg border px-3 py-2 text-sm",children:u.length===0?e.jsxs("p",{children:[s.name," is ready on ",t,"."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:[s.name," connected, not ready yet"]}),e.jsx("ul",{className:"mt-1 list-disc pl-4 text-xs text-muted-foreground",children:u.map(p=>e.jsx("li",{children:p},p))})]})})}function W({device:s,organizationId:n,ownerSlug:o,selectedConnection:h,openSettings:m}){const{data:r=[],isLoading:t,isError:u,refetch:p}=te(n),g=new Map(r.map(d=>[d.key,d])),a=new Map,f=[];for(const d of s.connectors){if(d.organization_slug!==o)continue;const x=g.get(d.connector_key);if(!x||!Y(x)){f.push(d);continue}const y=x.required_capability??`connector:${x.key}`,k=a.get(y)??{key:y,name:x.name,connections:[]};k.name=L[y]??x.name,k.connections.push(d),a.set(y,k)}const N=Me(s,r,o),v=Be(s,r,o);return e.jsxs(e.Fragment,{children:[e.jsxs(I,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),s.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!n||t?e.jsx(R,{className:"h-24 w-full"}):u?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load capability settings."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void p(),children:"Retry"})]}):a.size===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No native connections on this device in this workspace."}):e.jsx("div",{className:"divide-y border-y",children:[...a.values()].map(d=>e.jsx(F,{group:d,deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d.key))}),n&&!t&&!u?e.jsx(Te,{device:s,organizationId:n,ownerSlug:o,connectable:N,unavailable:v}):null,B(s)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),n&&f.length>0&&!t&&!u?e.jsxs(I,{title:"Apps and sources",count:String(f.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:[...new Set(f.map(d=>d.connector_key))].map(d=>e.jsx(F,{group:{key:d,name:g.get(d)?.name??d,connections:f.filter(x=>x.connector_key===d)},deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d))})]}):null]})}function F({group:s,deviceId:n,organizationId:o,ownerSlug:h,definitionsByKey:m,selectedConnection:r,openSettings:t}){const u=s.connections.some(a=>a.connection_id===r),[p,g]=j.useState(u);return j.useEffect(()=>{u&&r!==void 0&&g(!0)},[u,r]),e.jsxs(ae,{open:p,onOpenChange:g,children:[e.jsxs(ie,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(ce,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:s.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:s.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":s.connections.length>1?`${s.connections.length} connections`:"Configured"})]}),e.jsx(oe,{className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:s.connections.map(a=>e.jsx(Ke,{summary:a,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m.get(a.connector_key),openSettings:a.connection_id===r&&t},a.connection_id))})})]})}function Ke({summary:s,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m,openSettings:r}){const{data:t=[],isLoading:u,isError:p,refetch:g}=V(o,{connectionIds:[s.connection_id]}),a=t.find(v=>v.id===s.connection_id&&v.device_worker_id===n),f=m?.name??s.connector_key,N=a?G(a):null;return e.jsxs("section",{id:`connection-${s.connection_id}`,"aria-label":f,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:Ee(a)}),e.jsx("span",{children:a.status})]}):null,u||!o?e.jsx(R,{className:"h-24 w-full"}):p?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load this connection."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]}):a?e.jsxs(e.Fragment,{children:[N?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:N}):null,e.jsx("div",{className:"mb-4",children:e.jsx(re,{connection:a})}),e.jsx(Le,{connection:a,connectorDef:m,ownerSlug:h,openSettings:r,showActivity:!1,showShare:!1,embedded:!0})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection is no longer available on this device."})]})}function He({device:s,ownerSlug:n}){const o=j.useId(),{data:h=[]}=le(),m=U(),[r,t]=j.useState(!1),[u,p]=j.useState(null),[g,a]=j.useState(null),f=h.filter(l=>l.is_member).map(l=>({id:l.id,name:l.name,isPersonal:l.is_personal===!0})),N=f.find(l=>l.id===s.organization_id),v=N?M(N):s.organization_name??"No workspace",d=f.filter(l=>l.id!==s.organization_id),x=d.find(l=>l.id===u)??null,y=()=>{t(!1),p(null)},k=async l=>{a(null);try{await m.mutateAsync({deviceWorkerId:s.id,organizationId:l}),y()}catch(c){a(c instanceof Error?c.message:"Could not move the device.")}};return e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Workspace: "}),v]}),!r&&d.length>0?e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{a(null),t(!0)},children:"Change workspace"}):null]}),r?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("label",{htmlFor:o,className:"text-xs text-muted-foreground",children:"Move to"}),e.jsxs("select",{id:o,value:u??"",disabled:m.isPending,onChange:l=>p(l.target.value||null),className:"h-8 rounded-md border border-input bg-background px-2 text-sm",children:[e.jsx("option",{value:"",children:"Choose a workspace"}),d.map(l=>e.jsx("option",{value:l.id,children:M(l)},l.id))]}),x?null:e.jsx(b,{size:"sm",variant:"ghost",onClick:y,children:"Cancel"})]}):null,x?e.jsx(Z,{device:s,ownerSlug:n,title:`Move device to ${x.name}`,intro:`Move ${C(s)} from ${v} to ${M(x)}?`,aftermath:`It is set up fresh in ${x.name}, with its connections there private to you until you share them.`,confirmLabel:"Move device",pending:m.isPending,onConfirm:()=>void k(x.id),onCancel:y}):null,g?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g}):null]})}function Oe({ownerSlug:s,deviceId:n,organizationId:o,selectedConnection:h,openSettings:m}){const r=de(),{data:t=[],isLoading:u,isError:p,refetch:g}=me(),a=ue(),f=xe(),[N,v]=j.useState(!1),[d,x]=j.useState(!1),[y,k]=j.useState(""),l=he(t,n),c=l&&pe(l,s)?l:void 0,i=c?.id??n,{data:w=[]}=fe(o,{profileKind:"browser_session"}),S=j.useMemo(()=>w.filter(_=>_.device_worker_id===i&&_.status!=="revoked"),[w,i]),$=c?.label?.trim()??"";if(j.useEffect(()=>{d||k($)},[$,d]),u)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-6 w-6 rounded"}),e.jsx(R,{className:"h-5 w-40"})]}),e.jsx(ze,{})]});if(p)return e.jsx(P,{children:e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load this device."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]})});if(!c&&l&&o)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{platform:B(l),className:"h-5 w-5"}),e.jsx("h1",{className:"text-base font-semibold",children:C(l)})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This device lives in"," ",l.organization_name??"another workspace",", not this workspace."]}),e.jsx(W,{device:l,organizationId:o,ownerSlug:s})]});if(!c)return e.jsxs(P,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const D=ge(c),A=D?ve(s,D,je()):void 0,Q=B(c),X=ye(c.app_version),ee=be(c,X),T=()=>{const _=y.trim(),se=c.label?.trim()??"";if(_===se){x(!1);return}f.mutate({deviceWorkerId:c.id,label:_.length===0?null:_},{onSuccess:()=>x(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(Ne,{header:e.jsx(_e,{breadcrumb:e.jsx($e,{crumbs:[e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:H,children:"Connectors"},"connectors"),...A?[e.jsx(E,{to:"/$owner/connectors/app/$appId",params:{owner:s,appId:A.id},className:H,children:A.name},"app")]:[]]}),icon:e.jsx(q,{platform:Q,className:"h-5 w-5"}),title:d?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(we,{"aria-label":"Device name",value:y,onChange:_=>k(_.target.value),placeholder:C({...c,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:_=>{_.key==="Enter"?(_.preventDefault(),N||T()):_.key==="Escape"&&(v(!1),k(c.label?.trim()??""),x(!1))}}),N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",c.connector_count>0?`and un-pins ${c.connector_count} connector${c.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(b,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(c.id,{onSuccess:()=>{v(!1),r({to:"/$owner/connectors",params:{owner:s},search:{}})}}),children:[a.isPending?e.jsx(z,{className:"mr-1.5"}):null,a.isPending?"Removing...":"Confirm remove"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>v(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{size:"sm",onClick:T,disabled:f.isPending,children:[f.isPending?e.jsx(z,{className:"mr-1.5"}):null,f.isPending?"Saving...":"Save"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:f.isPending,onClick:()=>{k(c.label?.trim()??""),x(!1)},children:"Cancel"}),e.jsxs(b,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:f.isPending||a.isPending,onClick:()=>v(!0),children:[e.jsx(Ce,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove device"]})]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[C(c),e.jsx(b,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{v(!1),k(c.label?.trim()??""),x(!0)},children:e.jsx(Se,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${c.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),c.online?c.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:ee||void 0,caption:`Last seen ${K(new Date(c.last_seen_at),{addSuffix:!0})}${c.last_sync_at?` · Last sync ${K(new Date(c.last_sync_at),{addSuffix:!0})}`:""}`}),children:[e.jsx(He,{device:c,ownerSlug:s}),c.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(ke,{className:"h-3.5 w-3.5 shrink-0"}),c.connector_error_count," connector",c.connector_error_count===1?"":"s"," pinned to this device ",c.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(W,{device:c,organizationId:o,ownerSlug:s,selectedConnection:h,openSettings:m}),S.length>0?e.jsx(I,{title:"Browser auth profiles",children:e.jsx(We,{profiles:S})}):null,e.jsx(I,{title:"Runs",children:e.jsx(Ie,{scope:{deviceId:i},ownerSlug:s})})]})})}function We({profiles:s}){return s.length===0?null:e.jsx("div",{className:"rounded-lg border",children:e.jsx("ul",{className:"divide-y",children:s.map(n=>e.jsxs("li",{className:"space-y-2 px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:n.display_name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.connector_key??"Any connector"}),n.browser_kind?e.jsxs("span",{children:["· ",n.browser_kind]}):null,n.captured_at?e.jsxs("span",{title:n.captured_at,children:["· captured ",De(n.captured_at)]}):null,typeof n.cookie_count=="number"?e.jsxs("span",{children:["· ",n.cookie_count," cookie",n.cookie_count===1?"":"s"]}):null]})]}),e.jsx(Re,{status:n.is_expired?"error":Ae(n.status),showDot:!0,children:n.is_expired?"expired":n.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Refresh the session using the connector’s authorization instructions."})]},n.id))})})}function is(){const{owner:s,deviceId:n}=O.useParams(),{connection:o,settings:h}=O.useSearch();return e.jsx(Pe,{owner:s,children:({ownerSlug:m,organizationId:r})=>e.jsx(Oe,{ownerSlug:m,deviceId:n,organizationId:r,selectedConnection:o,openSettings:h})})}export{is as component};
|
|
2
|
+
//# sourceMappingURL=device._deviceId-B1H_ivDT.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as a,j as l,
|
|
2
|
-
//# sourceMappingURL=entity-avatar-
|
|
1
|
+
import{r as a,j as l,g1 as A,h as f,cZ as O}from"./index-4gCDI7m4.js";var S="Separator",m="horizontal",k=["horizontal","vertical"],b=a.forwardRef((e,t)=>{const{decorative:r,orientation:o=m,...i}=e,n=I(o)?o:m,c=r?{role:"none"}:{"aria-orientation":n==="vertical"?n:void 0,role:"separator"};return l.jsx(A.div,{"data-orientation":n,...c,...i,ref:t})});b.displayName=S;function I(e){return k.includes(e)}var y=b;const P=a.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},i)=>l.jsx(y,{ref:i,decorative:r,orientation:t,className:f("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...o}));P.displayName=y.displayName;function g(e,t){const r=e?.properties;if(r)return Object.entries(r).find(([,o])=>o[t])?.[0]}function R(e){const t=e.trim(),r=t.split(/[\s._@/-]+/).filter(Boolean),o=r.length>=2?`${r[0][0]}${r[1][0]}`:(r[0]??t).slice(0,2);let i=0;for(let n=0;n<t.length;n++)i=i*31+t.charCodeAt(n)>>>0;return{initials:o.toUpperCase()||"?",hue:i%360}}function T(e){const[t,r]=a.useState();return a.useEffect(()=>{if(!e){r(void 0);return}let o=!1;const i=e.trim().toLowerCase();return crypto.subtle.digest("SHA-256",new TextEncoder().encode(i)).then(n=>{o||r(Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join(""))}),()=>{o=!0}},[e]),t?`https://www.gravatar.com/avatar/${t}?d=identicon&s=80`:void 0}function $({metadata:e,metadataSchema:t,name:r,typeIcon:o,className:i="h-6 w-6",iconClassName:n="h-5 w-5",initialsFallback:s=!1}){const c=g(t,"x-image"),u=g(t,"x-email"),p=c&&e?.[c]||void 0,v=u&&e?.[u]||void 0,x=T(p?void 0:v),d=p||x,[w,h]=a.useState(!1);if(a.useEffect(()=>{h(!1)},[d]),d&&!w)return l.jsx("img",{src:d,alt:r,referrerPolicy:"no-referrer",onError:()=>h(!0),className:f("rounded-full object-cover border border-border",i)});if(s){const E=r.trim()||v||z(e,t)||r,{initials:j,hue:N}=R(E);return l.jsx("span",{role:"img","aria-label":r,className:f("inline-grid place-items-center rounded-full border border-border font-semibold text-white select-none",i),style:{background:`oklch(0.55 0.13 ${N})`,fontSize:"0.85em"},children:j})}return l.jsx(O,{icon:o,className:n})}function z(e,t){if(!e)return;const r=t?.properties,o=["email","handle","username","login","github","x_handle","slug"],i=Object.keys(r||e);for(const n of i)if(o.includes(n.toLowerCase())){const s=e[n];if(typeof s=="string"&&s.trim())return s}}export{$ as E,P as S};
|
|
2
|
+
//# sourceMappingURL=entity-avatar-HloBoalJ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{v as
|
|
2
|
-
//# sourceMappingURL=entity-options-
|
|
1
|
+
import{v as x,au as C,j as e,bz as m,bA as _,bB as S,bC as b,bD as o,f6 as u}from"./index-4gCDI7m4.js";import{c as v}from"./connection-label-BobuYiAG.js";const h="__connection_picker_create_new__";function y({connections:s,value:r,onValueChange:n,connectorKey:a,disabled:d,placeholder:p="Choose a connection",includeWorkspaceEvents:c=!1,ariaLabel:f="Connection"}){const g=x(),l=C().org?.slug,i=a?s.filter(t=>t.connector_key===a):s,j=t=>{if(t===h){if(!l)return;g({to:"/$owner/connectors/create",params:{owner:l},search:a?{connector:a}:{}});return}n(t)};return e.jsxs(m,{value:r,onValueChange:j,disabled:d,children:[e.jsx(_,{"aria-label":f,children:e.jsx(S,{placeholder:p})}),e.jsxs(b,{children:[c?e.jsxs(e.Fragment,{children:[e.jsx(o,{value:"workspace",children:"Current workspace"}),i.length>0?e.jsx(u,{}):null]}):null,i.map(t=>e.jsx(o,{value:String(t.id),children:v(t)},t.id)),l?e.jsxs(e.Fragment,{children:[i.length>0||c?e.jsx(u,{}):null,e.jsx(o,{value:h,children:"Connect an app…"})]}):null]})]})}function w(s){const r=[];for(const n of s)typeof n.id=="number"&&r.push({id:n.id,name:n.name,entityType:n.entity_type}),n.children&&n.children.length>0&&r.push(...w(n.children));return r}export{y as C,w as f};
|
|
2
|
+
//# sourceMappingURL=entity-options-BSW_EG0W.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{db as ke,r as F,b_ as Ne,ji as R,fA as we,ec as se,j as e,B as w,u as Y,jc as Se,S as ae,fI as he,jj as Re,E as Fe,v as pe,b as Ee,b$ as B,au as De,i as Ce,ee as G,em as Le,jd as Be,jk as Pe,bk as $e,cb as ne,eM as Ie,fu as Me,fg as Ve,gY as Oe,gZ as Te,g_ as Ae,g$ as ze,h0 as Ue,jl as He,c2 as Ke,H,I as ie,ep as We,W as qe,fy as re,dG as K,gl as Ge,L as W,gm as q}from"./index-4gCDI7m4.js";import{R as Xe}from"./record-activity-D7bRaMk2.js";import{m as Ye,o as X,j as Qe,q as oe,h as Q,R as xe,r as Ze,t as Je,D as et,S as tt}from"./renderer-7EGgTVX0.js";import{r as st,V as at}from"./views-access-required-DHrDO333.js";import{S as nt,E as it}from"./entity-avatar-HloBoalJ.js";import{a as fe,V as le,M as rt,b as ot}from"./view-param-filters-mKoqDsaD.js";import{a as lt}from"./source-record-panels-Bh5F4C5K.js";import{r as ct,R as ce,b as dt}from"./event-card-Mcxv56DG.js";import{a as ut}from"./record-session-CWXnCVln.js";import"./filter-bar-BQm-ubB1.js";import"./calendar-DMq3Dtqy.js";import"./connection-label-BobuYiAG.js";import"./runs-BPtQBTRN.js";import"./clients-C7Lnuc3S.js";import"./client-activity-scopes-boZOHuPW.js";import"./client-rows-BJ2PxM4J.js";import"./events-feed-BysC9HgU.js";import"./use-scroll-sentinel-Ct-jt7O0.js";import"./use-automations-BHoV0dLs.js";import"./agent-loading-shells-Dnmb6W5Y.js";import"./member-scope-gate-vp3FihBD.js";import"./table-DFcJRNk7.js";import"./card-SFtxv9f2.js";import"./app-bridge-C4nPtae3.js";import"./json-diff-E5D-NGYT.js";import"./index-wHFQv1aT.js";import"./copy-button-2swYh4jb.js";function mt(t,s){if(t===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in t)return t;if(typeof t=="function")return{shouldBlockFn:async()=>await t(),enableBeforeUnload:!0,withResolver:!1};const i=!!(t.condition??!0),n=t.blockerFn;return{shouldBlockFn:async()=>i&&n!==void 0?await n():i,enableBeforeUnload:i,withResolver:n===void 0}}function ht(t,s){const{shouldBlockFn:i,enableBeforeUnload:n=!0,disabled:a=!1,withResolver:c=!1}=mt(t),r=ke(),{history:o}=r,[u,g]=F.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return F.useEffect(()=>{const p=async x=>{function l(f){const j=r.parseLocation(f),y=r.getMatchedRoutes(j.pathname);return y.foundRoute===void 0?{routeId:"__notFound__",fullPath:j.pathname,pathname:j.pathname,params:y.routeParams,search:r.options.parseSearch(f.search)}:{routeId:y.foundRoute.id,fullPath:y.foundRoute.fullPath,pathname:j.pathname,params:y.routeParams,search:r.options.parseSearch(f.search)}}const m=l(x.currentLocation),d=l(x.nextLocation);if(m.routeId==="__notFound__"&&d.routeId!=="__notFound__")return!1;const h=await i({action:x.action,current:m,next:d});if(!c)return h;if(!h)return!1;const N=await new Promise(f=>{g({status:"blocked",current:m,next:d,action:x.action,proceed:()=>f(!1),reset:()=>f(!0)})});return g({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),N};return a?void 0:o.block({blockerFn:p,enableBeforeUnload:n})},[i,n,a,c,o,r]),u}function A(t,s){return se(X(t))===se(X(s))}function pt(t,s){const i={};for(const n of new Set([...Object.keys(t),...Object.keys(s)]))A(t[n],s[n])||(i[n]=X(t[n])??null);return Object.keys(i).length>0?i:void 0}function xt(t,s){return[...new Set([...Object.keys(t),...Object.keys(s)])].filter(i=>{try{return!A(t[i],s[i])}catch{return!0}})}function de(t,s){return{name:t.name,slug:t.slug,metadata:Ye(t.metadata??{},s)}}function ft(t,s,i){const n=new Set(i),a={},c={},r=new Set([...Object.keys(t.values.metadata),...Object.keys(t.baseline.metadata),...Object.keys(s.metadata)]);for(const o of r){const u=n.has(o),g=u?t.values.metadata[o]:t.baseline.metadata[o],p=A(g,s.metadata[o])?g:s.metadata[o];p!==void 0&&(a[o]=p);let x=!1;if(!u)try{x=!A(t.values.metadata[o],t.baseline.metadata[o])}catch{x=!0}const l=x?t.values.metadata[o]:p;l!==void 0&&(c[o]=l)}return{baseline:{name:s.name,slug:s.slug,metadata:a},values:{name:s.name,slug:s.slug,metadata:c}}}function gt({entity:t,schema:s,orgContext:i}){const n=F.useMemo(()=>de(t,s),[t,s]),a=Ne(R(t),n,s),c=we(i),{values:r,baseline:o,commit:u}=a,g=F.useMemo(()=>xt(r.metadata,o.metadata),[r.metadata,o.metadata]),p=r.name!==o.name||r.slug!==o.slug,x=F.useCallback((m,d)=>a.setValues(h=>({...h,metadata:{...h.metadata,[m]:d}})),[a.setValues]),l=async({note:m}={})=>{if(typeof t.id!="number")throw new Error("Source records are read-only");if(!a.canSubmit)return null;const d=pt(r.metadata,o.metadata),h=r.name.trim()!==o.name.trim();if(!d&&!p)return null;const N=await c.mutateAsync({entityId:t.id,name:h?r.name.trim():void 0,slug:r.slug,metadata:d,field_note:d&&m?.trim()||void 0}),f=de(N.entity,s);return u(j=>ft(j,f,Object.keys(d??{})),f),{held:N.blocked_fields??[],approvalUrl:N.approval_url}};return{values:r,baseline:o,revision:a.revision,setValues:a.setValues,setMetadataField:x,reset:a.reset,save:l,saving:c.isPending,dirtyKeys:g,identityDirty:p,isDirty:p||g.length>0,canSubmit:a.canSubmit,hasConflict:a.hasConflict,hasInvalidInput:a.hasInvalidInput}}const vt=3,jt=50;function ge(t){const s=F.useRef(null);return F.useEffect(()=>{t&&(s.current?.scrollIntoView?.({block:"start"}),s.current?.focus())},[t]),s}function I({headingRef:t,children:s}){return e.jsx("h3",{ref:t,tabIndex:-1,className:"text-xs font-medium uppercase tracking-wide text-muted-foreground outline-none",children:s})}function yt({entityId:t,entityName:s,ownerSlug:i,orgContext:n,focus:a,collapsed:c=!1}){const r=Y(),o=ge(a),{data:u,isLoading:g,isError:p,refetch:x}=Se(t,n,{limit:jt});if(t===void 0)return null;if(g)return e.jsxs("section",{className:"space-y-2","aria-busy":"true",children:[e.jsx(I,{headingRef:o,children:"Linked"}),e.jsx(ae,{className:"h-4 w-24"}),e.jsx(ae,{className:"h-6 w-full rounded-md"})]});if(p||!u)return e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:o,children:"Linked"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Could not load this record's links."," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>void x(),children:"Retry"})]})]});if(u.countsByType.length===0&&!u.hasMore&&!u.failures?.length)return a?e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:o,children:"Linked"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No links to other records yet."})]}):null;if(c){const l=u.countsByType.flatMap(m=>{const d=m.count===1?u.rows.find(h=>h.relationship_type_slug===m.relationship_type_slug):void 0;return d?[ct(d,m.relationship_type_name)]:[m.relationship_type_name,String(m.count)]});return e.jsxs("section",{className:"space-y-1","aria-label":"Linked records",children:[e.jsx(I,{headingRef:o,children:"Linked"}),e.jsx(ce,{count:u.failures?.length??0,onRetry:()=>void x()}),e.jsx("p",{"data-testid":"linked-summary",className:"truncate text-sm text-muted-foreground",children:l.join(" · ")})]})}return e.jsxs("section",{className:"space-y-3","aria-label":"Linked records",children:[e.jsx(I,{headingRef:o,children:"Linked"}),e.jsx(ce,{count:u.failures?.length??0,onRetry:()=>void x()}),u.hasMore&&r?e.jsx(w,{type:"button",variant:"ghost",size:"sm",onClick:()=>r.open({href:"",key:`record-links:${t}`,title:"Linked records",recordLinks:{entityId:t,entityName:s,ownerSlug:i,orgContext:n,label:"Linked records"}}),children:"Browse linked records"}):null,u.countsByType.map(l=>{const m=u.rows.filter(h=>h.relationship_type_slug===l.relationship_type_slug).slice(0,vt),d=l.count>m.length;return e.jsxs("div",{className:"space-y-1 text-sm",children:[d||m.length===0?e.jsxs("p",{className:"text-muted-foreground",children:[l.relationship_type_name,d?e.jsxs("span",{className:"tabular-nums text-muted-foreground/70",children:[" ","· ",l.count,u.countsScope==="page"?" shown":""]}):null]}):null,e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-1",children:[m.map(h=>e.jsx(dt,{row:h,label:l.relationship_type_name,entityId:t,ownerSlug:i,orgContext:n},h.id)),d&&r?e.jsxs(w,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary",onClick:()=>r.open({href:"",key:`record-links:${t}:${l.relationship_type_slug}`,title:`${l.relationship_type_name} · ${l.count}`,recordLinks:{entityId:t,entityName:s,ownerSlug:i,orgContext:n,relationshipType:l.relationship_type_slug,label:l.relationship_type_name}}),children:["Show all ",l.count]}):null]})]},l.relationship_type_slug)})]})}function bt({record:t,ownerSlug:s,orgContext:i,focus:n}){const[a,c]=F.useState(n),r=ge(n);return e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:r,children:"Linked"}),a?e.jsx(lt,{record:t,ownerSlug:s,orgContext:i}):e.jsx(w,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:()=>c(!0),children:"Find linked records"})]})}const _t="$name";function ve({outcome:t,schema:s}){if(!t||t.held.length===0)return null;const i=s?.properties??{},n=t.held.map(a=>a===_t?"Name":Qe(a,i[a]??{}));return e.jsxs("div",{role:"status",className:"rounded-md bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-300",children:[n.join(", ")," ",n.length===1?"needs":"need"," approval before ",n.length===1?"it changes":"they change",".",t.approvalUrl?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:t.approvalUrl,className:"underline",children:"Review"})]}):null]})}const kt=320,Nt={},wt=()=>{};function St({view:t,orgSlug:s,recordUrl:i,scope:n}){const a=Y(),c=`${i}${he(t.key)}`,r=a?()=>a.open({href:c,title:t.name}):void 0;return e.jsxs("section",{className:"min-w-0 rounded-lg border","data-testid":"view-card","data-view":t.key,children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-4 pt-3 pb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-sm font-medium",children:t.name}),t.description?e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:t.description}):null]}),r?e.jsxs(w,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:r,"aria-label":`Open ${t.name}`,children:[e.jsx(Re,{className:"h-3.5 w-3.5"}),"Open"]}):null]}),e.jsx("div",{className:"px-4 pb-3",children:e.jsx(fe,{orgSlug:s,viewKey:t.key,scope:n,params:Nt,onParamsChange:wt,contentHash:t.content_hash,title:t.name,minHeight:64,displayMode:"inline",maxHeight:kt,onRequestDisplayMode:r?o=>{o==="fullscreen"&&r()}:void 0})})]})}function Rt({recordUrl:t,dirty:s,onDiscard:i}){const n=ht({disabled:!s,enableBeforeUnload:s,withResolver:!0,shouldBlockFn:({next:c})=>c.pathname!==t&&!c.pathname.startsWith(`${t}${he("")}`)}),a=n.status==="blocked";return e.jsx(Oe,{open:a,onOpenChange:c=>{!c&&a&&n.reset()},children:e.jsxs(Te,{className:"max-w-sm",children:[e.jsxs(Ae,{children:[e.jsx(ze,{children:"Discard unsaved changes?"}),e.jsx(Ue,{children:"This record has edits that are not saved. Leaving discards them."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(w,{type:"button",variant:"ghost",onClick:()=>a&&n.reset(),children:"Keep editing"}),e.jsx(w,{type:"button",variant:"destructive",onClick:()=>{a&&(i(),n.proceed())},children:"Discard"})]})]})})}const ue=6;function Ft({entity:t,ownerSlug:s,orgContext:i,recordUrl:n,schema:a,entityTypeName:c,isTypeLoading:r,record:o,canEdit:u,editing:g,onEditingChange:p,outcome:x,onSaved:l,formId:m,fieldLimit:d,onDeleted:h}){const N=g&&u,f=Y(),j={entity:{id:R(t),name:t.name,entity_type:t.entity_type},ownerSlug:s,orgContext:i,schema:a,record:o,editing:N};ut(j);const y=f?.item?.recordField,S={ownerSlug:s,orgContext:i,controls:t.field_controls,dirtyKeys:o.dirtyKeys,openField:f?E=>f.open(st(j,E.key)):void 0,openFieldKey:y?.entityId===R(t)?y.field:void 0},D=e.jsx(Rt,{recordUrl:n,dirty:N&&o.isDirty,onDiscard:()=>{o.reset(),p(!1)}});if(r)return e.jsx(Ve,{rows:6});if(N)return e.jsxs(e.Fragment,{children:[D,e.jsx(Et,{formId:m,entity:t,entityTypeName:c,schema:a,record:o,orgContext:i,renderControl:(E,b,C)=>Ze(b)?e.jsx(Je,{field:{key:E,prop:b},value:C,context:S}):void 0,onSaved:l,onDeleted:h,onDone:()=>p(!1)})]});const M=Q(o.revision);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{outcome:x,schema:a}),e.jsx(xe,{fields:M,fieldLimit:d,values:o.values.metadata,context:S})]})}function Et({formId:t,entity:s,entityTypeName:i,schema:n,record:a,orgContext:c,renderControl:r,onSaved:o,onDeleted:u,onDone:g}){const p=He(),x=s.field_controls,{name:l,slug:m,metadata:d}=a.values,h=v=>a.setValues(_=>({..._,name:v})),N=v=>a.setValues(_=>({..._,slug:v})),f=v=>a.setValues(_=>({..._,metadata:v})),[j,y]=B(R(s),""),[S,D]=B(R(s),null),[M,E]=B(R(s),null),[b,C]=B(R(s),!1),[P,$]=B(R(s),null),z=a.dirtyKeys.length>0,U=async v=>{if(v.preventDefault(),!!a.canSubmit){if(D(null),!l.trim()){D("Name is required");return}try{const _=await a.save({note:j});E(_),o(_),y(""),_?.held.length||g()}catch(_){D(_ instanceof Error?_.message:"Failed to update entity")}}},T=async()=>{$(null);try{if(typeof s.id!="number")throw new Error("Source records are read-only");await p.mutateAsync({entityId:s.id}),C(!1),u?.()}catch(v){$(v instanceof Error?v.message:"Failed to delete entity")}},L=[s.total_content>0&&`${s.total_content} content item${s.total_content===1?"":"s"}`,s.automations_count>0&&`${s.automations_count} Automation${s.automations_count===1?"":"s"}`,s.active_connections>0&&`${s.active_connections} connector${s.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return e.jsxs("form",{id:t,onSubmit:U,className:"space-y-4",children:[e.jsx(Ke,{visible:a.hasConflict,onReload:a.reset}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(H,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ie,{id:"sidebar-name",value:l,onChange:v=>h(v.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(H,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(ie,{id:"sidebar-slug",value:m,onChange:v=>N(v.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),a.revision&&Object.keys(a.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(nt,{}),e.jsx(et,{schema:a.revision,values:d,onValuesChange:f,fieldControls:x,orgContext:c,renderControl:r})]}),z&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(H,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(We,{id:"sidebar-correction-note",value:j,onChange:v=>y(v.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),S&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:S}),e.jsx(ve,{outcome:M,schema:n}),b?e.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 text-sm",children:[e.jsx(qe,{className:"h-4 w-4 shrink-0 text-destructive mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:['Delete "',s.name,'"?']}),L&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",L,". This cannot be easily undone."]})]})]}),P&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:P}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(w,{type:"button",variant:"ghost",size:"sm",onClick:()=>{C(!1),$(null)},children:"Cancel"}),e.jsx(w,{type:"button",variant:"destructive",size:"sm",onClick:T,disabled:p.isPending,children:p.isPending?"Deleting...":`Delete ${i||"entity"}`})]})]}):e.jsx("div",{className:"pt-2",children:e.jsx(w,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>C(!0),children:"Delete"})})]})}function je(t,s){const i=new Set(t.measure_columns??[]),n=s?.properties??{};return Object.keys(t.metadata??{}).filter(a=>a!=="id"&&a!=="slug"&&a!=="name"&&!Ie(n[a])&&n[a]?.const===void 0).map(a=>({key:a,prop:n[a]??{},label:n[a]?.["x-table-label"]??(i.has(a)?a:Me(a.replace(/_/g," "))),numeric:i.has(a)}))}function Dt({entity:t,schema:s,ownerSlug:i,fieldLimit:n}){const a=je(t,s);return e.jsxs("div",{children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Managed by the source"}),e.jsx(xe,{fields:a,fieldLimit:n,values:t.metadata??{},context:{ownerSlug:i}})]})}const Ct=720,me="owletto:record-details-expanded";function Lt(){const[t,s]=F.useState(()=>{try{return window.localStorage.getItem(me)==="1"}catch{return!1}});return[t,n=>{s(n);try{window.localStorage.setItem(me,n?"1":"0")}catch{}}]}function Bt({schema:t,metadata:s}){const i=Q(t).filter(({key:n,prop:a})=>a["x-table-column"]===!0&&!a["x-image"]&&s[n]!==void 0&&s[n]!==null&&s[n]!=="");return i.length===0?null:e.jsx("p",{"data-testid":"record-summary",className:"-mt-2 truncate text-sm text-muted-foreground tabular-nums",children:i.map(({key:n,prop:a},c)=>e.jsxs("span",{children:[c>0?" · ":null,e.jsx(tt,{value:s[n],prop:a})]},n))})}function Pt({namespace:t,entity:s,recordUrl:i,viewKey:n,title:a,onDeleted:c}){const r=Fe({strict:!1}),o=pe(),u=F.useRef(null),g=Ee(u,Ct),[p,x]=Lt(),[l,m]=B(R(s),!1),d={slug:t.slug,organizationId:t.id},{isMember:h,isLoading:N}=De(t.slug),f=Ce({...d,organizationId:h?t.id:null}),{data:j,isLoading:y}=G(s.entity_type,d),S=j?.metadata_schema,{isAdmin:D,isLoading:M}=Le(h?d.organizationId:void 0),E=h&&D&&!M&&!s.is_derived,b=gt({entity:s,schema:S,orgContext:d}),[C,P]=B(R(s),null),$=`record-form-${s.id}`,z=l&&E,U=h?f.data??[]:[],T=Be(U,{type:s.entity_type,id:R(s)}),L=Pe(T,n),v=!n&&r.tab==="relationships",_=k=>void o({to:".",search:k,replace:!0}),Z={type:s.entity_type,entity:s.is_derived?s.slug:s.id??s.slug},V=g&&!p&&!l&&!v,J=s.is_derived?oe(je(s,S),s.metadata??{}).length:oe(Q(b.revision),b.values.metadata).length,ee=V?ue:void 0,te=e.jsxs("div",{className:"space-y-6",children:[s.is_derived?e.jsxs(e.Fragment,{children:[e.jsx(Dt,{entity:s,schema:S,ownerSlug:t.slug,fieldLimit:ee}),e.jsx(bt,{record:{type:s.entity_type,key:s.slug},ownerSlug:t.slug,orgContext:d,focus:v})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ft,{entity:s,ownerSlug:t.slug,orgContext:d,recordUrl:i,schema:S,entityTypeName:j?.name,isTypeLoading:y,record:b,canEdit:E,editing:l,onEditingChange:m,outcome:C,onSaved:P,formId:$,fieldLimit:ee,onDeleted:c}),e.jsx(yt,{entityId:typeof s.id=="number"?s.id:void 0,entityName:s.name,ownerSlug:t.slug,orgContext:d,focus:v,collapsed:V})]}),g&&!l&&!v?e.jsx(w,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary","aria-expanded":!V,onClick:()=>x(V),children:V?J>ue?`Show all ${J} fields`:"Show all details":"Show fewer"}):null]}),ye=k=>e.jsx("div",{ref:u,className:"min-w-0 space-y-4",children:g?e.jsxs(e.Fragment,{children:[e.jsx(Bt,{schema:S,metadata:s.metadata??{}}),e.jsx("section",{"aria-label":"Details","data-testid":"record-details",children:te}),k]}):e.jsxs("div",{className:"grid grid-cols-[18rem_minmax(0,1fr)] gap-6",children:[e.jsx("aside",{className:"sticky top-12 max-h-[calc(100dvh-7rem)] min-w-0 self-start overflow-y-auto overscroll-contain pr-2 pb-16",children:te}),k]})}),be=z?e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(w,{type:"button",variant:"ghost",size:"sm",onClick:()=>{b.reset(),P(null),m(!1)},children:"Cancel"}),e.jsx(w,{type:"submit",form:$,size:"sm",disabled:!b.canSubmit||!b.isDirty||b.saving||!b.values.name.trim(),children:b.saving?"Saving...":"Save"})]}):E&&!y?e.jsxs(w,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:()=>{P(null),m(!0)},children:[e.jsx($e,{className:"h-3.5 w-3.5"}),"Edit"]}):null,O=k=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"record-header",className:"sticky top-0 z-30 -mx-4 flex h-12 items-center justify-between gap-3 bg-background px-4 lg:-mx-6 lg:px-6",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:a}),be]}),k]});if(n&&!h)return O(N?null:e.jsx(at,{}));if(n&&f.data===void 0)return O(f.isError?e.jsx(le,{onRetry:()=>void f.refetch()}):null);if(L.kind==="missing")return O(e.jsx(rt,{viewKey:L.key,backTo:i,backLabel:`Back to ${s.name}`}));if(L.kind==="view"){const{view:k}=L;return O(e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsx(ot,{decls:k.params,params:ne(r),onParamsChange:_e=>void o({to:".",search:_e})}),e.jsx(fe,{orgSlug:t.slug,viewKey:k.key,scope:Z,params:ne(r),onParamsChange:_,contentHash:k.content_hash,title:k.name,minHeight:320})]}))}return O(ye(e.jsxs("div",{className:"min-w-0 space-y-4",children:[h&&f.isError&&e.jsx(le,{onRetry:()=>void f.refetch()}),T.map(k=>e.jsx(St,{view:k,orgSlug:t.slug,recordUrl:i,scope:Z},k.key)),e.jsxs("section",{"aria-labelledby":"record-activity-heading",className:"min-w-0",children:[e.jsx("h2",{id:"record-activity-heading",className:"mb-2 text-sm font-medium text-muted-foreground",children:"Activity"}),e.jsx(Xe,{entity:s,organizationId:t.id,ownerSlug:t.slug})]})]})))}function $t(t){return t?.trim()?t:void 0}function cs({namespace:t,path:s,entity:i,viewKey:n}){const a=pe(),{data:c}=G(i.entity_type,{slug:t.slug}),r=s[0]?.entity_type??i.entity_type,{data:o}=G(r,{slug:t.slug}),u=$t(c?.icon),g=s.map(l=>({entity_type:l.entity_type,slug:l.slug})),p=`/${t.slug}/${re(i.entity_type)}`,x=K(t.slug,g);return e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col gap-4 px-4 pt-2.5 pb-8 lg:px-6",children:[e.jsx(Ge,{crumbs:[...r==="$member"?[]:[e.jsx(W,{to:"/$owner/data",params:{owner:t.slug},className:q,children:"Memory"},"memory")],e.jsx(W,{to:`/${t.slug}/${re(r)}`,className:q,children:r==="$member"?"Team":o?.name??r},"type"),...s.slice(0,-1).map((l,m)=>e.jsx(W,{to:K(t.slug,g.slice(0,m+1)),className:q,children:l.name},l.id))],current:i.name}),e.jsx(Pt,{namespace:t,entity:i,recordUrl:x,viewKey:n,title:e.jsxs(e.Fragment,{children:[e.jsx(it,{metadata:i.metadata,metadataSchema:c?.metadata_schema,name:i.name,typeIcon:u,className:"h-6 w-6 shrink-0"}),e.jsx("h2",{className:"truncate text-lg font-semibold leading-tight",children:i.name})]}),onDeleted:()=>{const l=s.slice(0,-1);l.length>0?a({to:K(t.slug,l)}):a({to:p})}})]})}export{cs as EntityPage};
|
|
2
|
+
//# sourceMappingURL=entity-page-D-WDWrAe.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as e,t as $,f2 as me,fL as xe,f5 as Y,bJ as ae,r as x,f3 as he,f4 as pe,dx as ge,dz as fe,B as f,c_ as V,dy as je,H as C,bz as q,bA as P,bB as M,bC as L,bD as R,I as O,aa as ve,fb as Ne,fM as ye,V as K,eb as be,X as W,cB as ne,C as re,Y as we,be as le,fN as ie,fO as Se,W as oe,fP as Ce,fD as ke,b_ as Ee,b$ as Q,c2 as _e,ep as Re,bK as Oe,fQ as Te,fR as De,h as G,L as Ae}from"./index-4gCDI7m4.js";import{C as Fe,J as B}from"./json-diff-E5D-NGYT.js";import{C as ce}from"./code-editor-rX0t1g5C.js";function ze({entry:s}){return e.jsxs("div",{className:"relative pl-6 pb-6 last:pb-0",children:[e.jsx("div",{className:"absolute left-0 top-1.5 h-3 w-3 rounded-full border-2 border-border bg-background"}),e.jsx("div",{className:"absolute left-[5px] top-5 bottom-0 w-px bg-border last:hidden"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Fe,{operation:s.action,actor:s.actor,createdAt:s.created_at}),s.action==="update"&&e.jsx(B,{before:s.before_payload,after:s.after_payload}),s.action==="create"&&s.after_payload&&e.jsx(B,{before:null,after:s.after_payload}),s.action==="delete"&&s.before_payload&&e.jsx(B,{before:s.before_payload,after:null})]})]})}function qe({entityType:s}){const{orgContext:a}=$(),{data:c,isLoading:n}=me(a),{data:r}=xe(a),t=(c||[]).filter(m=>m.status==="active"),i=t.filter(m=>!m.organization_slug||m.organization_slug===a?.slug),o=i.filter(m=>m.purpose!==Y),d=i.filter(m=>m.purpose===Y),h=t.filter(m=>m.organization_slug&&m.organization_slug!==a?.slug);return e.jsx("div",{className:"space-y-4 py-4",children:n?e.jsx(ae,{label:"relationships",variant:"rows",rows:4}):e.jsxs(e.Fragment,{children:[e.jsx(U,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]}),d.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Managed by access control"}),e.jsx(U,{entityTypeSlug:s.slug,relationshipTypes:d,allEntityTypes:r||[],readOnly:!0})]}),h.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"From public catalogs"}),e.jsx(U,{entityTypeSlug:s.slug,relationshipTypes:h,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Le,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]})]})})}function U({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c,readOnly:n=!1}){return e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(Pe,{relationshipType:r,entityTypeSlug:s,allEntityTypes:c,readOnly:n},r.id))})}function Pe({relationshipType:s,entityTypeSlug:a,allEntityTypes:c,readOnly:n=!1}){const{orgContext:r}=$(),{data:t}=Ne(s.slug,r),i=ye(),o=(t||[]).filter(h=>h.source_entity_type_slug===a||h.target_entity_type_slug===a);if(o.length===0)return null;const d=new Map(c.map(h=>[h.slug,h.name]));return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx("code",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:s.slug}),s.is_symmetric&&e.jsx(K,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"symmetric"}),n&&e.jsx(K,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"read-only"})]}),o.map(h=>e.jsx(Me,{rule:h,entityTypeSlug:a,entityTypeNameMap:d,onRemove:()=>i.mutate(h.id),isRemoving:i.isPending,readOnly:n},h.id))]})}function Me({rule:s,entityTypeSlug:a,entityTypeNameMap:c,onRemove:n,isRemoving:r,readOnly:t=!1}){const[i,o]=x.useState(!1),d=s.source_entity_type_slug===a,h=d?s.target_entity_type_slug:s.source_entity_type_slug,m=c.get(h)||h;return e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-3 rounded-md border border-border bg-muted/30 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:d?"this":m}),e.jsx(be,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:d?m:"this"}),t?null:i?e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(f,{variant:"destructive",size:"sm",className:"h-6 px-2 text-xs",onClick:n,disabled:r,children:r?"Removing...":"Remove"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>o(!1),disabled:r,children:"Cancel"})]}):e.jsx("div",{className:"ml-auto",children:e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive",onClick:()=>o(!0),disabled:r,children:e.jsx(W,{className:"h-3 w-3"})})})]})}function Le({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c}){const{orgContext:n}=$(),r=c.filter(l=>!l.organization_slug||l.organization_slug===n?.slug),[t,i]=x.useState(!1),[o,d]=x.useState("existing"),[h,m]=x.useState(""),[S,N]=x.useState(""),[y,b]=x.useState("source"),[g,j]=x.useState(""),[k,E]=x.useState(""),[D,w]=x.useState(!1),[A,_]=x.useState(null),u=he(),p=pe(),v=()=>{d("existing"),m(""),N(""),b("source"),j(""),E(""),w(!1),_(null)},T=l=>{i(l),l||v()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),J=async()=>{_(null);try{let l=h;if(o==="new"){if(!g.trim()){_("Name is required");return}const H=k.trim()||F(g);if(!H){_("Slug is required");return}l=(await u.mutateAsync({slug:H,name:g.trim(),is_symmetric:D})).relationship_type.slug}if(!l){_("Select a relationship type");return}if(!S){_("Select a target entity type");return}const I=y==="source"?s:S,ue=y==="source"?S:s;await p.mutateAsync({slug:l,source_entity_type_slug:I,target_entity_type_slug:ue}),T(!1)}catch(l){_(l instanceof Error?l.message:"An error occurred")}},z=u.isPending||p.isPending;return e.jsxs(ge,{open:t,onOpenChange:T,children:[e.jsx(fe,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1.5"}),"Add Relationship Rule"]})}),e.jsx(je,{className:"w-80 p-4",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Relationship Type"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(f,{variant:o==="existing"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("existing"),children:"Existing"}),e.jsx(f,{variant:o==="new"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("new"),children:"Create New"})]})]}),o==="existing"?e.jsxs(q,{value:h,onValueChange:m,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select relationship type..."})}),e.jsxs(L,{children:[a.map(l=>e.jsx(R,{value:l.slug,children:l.name},l.slug)),a.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No relationship types yet. Create one."})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{placeholder:"Name (e.g. Integrates With)",className:"h-8 text-sm",value:g,onChange:l=>{j(l.target.value),k||E("")}}),e.jsx(O,{placeholder:g?F(g)||"slug":"Slug (auto-generated)",className:"h-8 text-sm",value:k,onChange:l=>E(l.target.value)}),e.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:l=>w(l.target.checked),className:"rounded"}),"Symmetric (A↔B = B↔A)"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Direction"}),e.jsxs(q,{value:y,onValueChange:l=>b(l),children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"source",children:"This type → other"}),e.jsx(R,{value:"target",children:"Other → this type"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(C,{className:"text-xs",children:[y==="source"?"Target":"Source"," Entity Type"]}),e.jsxs(q,{value:S,onValueChange:N,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select entity type..."})}),e.jsx(L,{children:r.map(l=>e.jsxs(R,{value:l.slug,children:[l.icon?`${l.icon} `:"",l.name]},l.slug))})]})]}),A&&e.jsx("p",{className:"text-xs text-destructive",children:A}),e.jsx(f,{size:"sm",className:"w-full",onClick:J,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Ie({options:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const i=c.trim();i&&!s.includes(i)&&(a([...s,i]),n(""))},t=i=>{a(s.filter((o,d)=>d!==i))};return e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((i,o)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-sm px-2 py-0.5 rounded",children:[i,e.jsx("button",{type:"button",onClick:()=>t(o),className:"text-muted-foreground hover:text-foreground",children:e.jsx(W,{className:"h-3 w-3"})})]},i))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(O,{value:c,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),r())},placeholder:"Add option...",className:"h-7 text-sm"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}const Ve=[{value:"string",label:"Text"},{value:"number",label:"Number"},{value:"integer",label:"Whole number"},{value:"boolean",label:"Yes/No"},{value:"enum",label:"Choice"}];function Je({examples:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const t=c.trim();t&&!s.includes(t)&&(a([...s,t]),n(""))};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((t,i)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-xs px-2 py-0.5 rounded",children:[t,e.jsx("button",{type:"button",onClick:()=>a(s.filter((o,d)=>d!==i)),className:"text-muted-foreground hover:text-foreground",children:e.jsx(W,{className:"h-3 w-3"})})]},t))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(O,{value:c,onChange:t=>n(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),r())},placeholder:"Add example...",className:"h-7 text-xs"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}function Be({field:s,onChange:a,onDelete:c}){const[n,r]=x.useState(!!(s.description||s.default||s.role||s.examples&&s.examples.length>0));return e.jsxs("div",{className:"rounded-md border border-border p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-muted-foreground hover:text-foreground shrink-0",children:n?e.jsx(ne,{className:"h-3.5 w-3.5"}):e.jsx(re,{className:"h-3.5 w-3.5"})}),e.jsx(O,{value:s.name,onChange:t=>a({...s,name:t.target.value}),placeholder:"Field name",className:"h-8 flex-1"}),e.jsxs(q,{value:s.type,onValueChange:t=>a({...s,type:t,enumOptions:t==="enum"?s.enumOptions||[]:void 0,role:t==="enum"||s.role!=="workflowState"?s.role:void 0}),children:[e.jsx(P,{className:"h-8 w-32",children:e.jsx(M,{})}),e.jsx(L,{children:Ve.map(t=>e.jsx(R,{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground whitespace-nowrap",children:[e.jsx(we,{checked:s.required,onCheckedChange:t=>a({...s,required:t===!0})}),e.jsx("span",{children:"Required"})]}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:c,children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),s.type==="enum"&&e.jsx("div",{className:"pl-6",children:e.jsx(Ie,{options:s.enumOptions||[],onChange:t=>a({...s,enumOptions:t})})}),n&&e.jsxs("div",{className:"pl-6 space-y-2 pt-1",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Description"}),e.jsx(O,{value:s.description||"",onChange:t=>a({...s,description:t.target.value||void 0}),placeholder:"Field description",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default"}),e.jsx(O,{value:s.default||"",onChange:t=>a({...s,default:t.target.value||void 0}),placeholder:s.type==="boolean"?"true / false":"Default value",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"View role"}),e.jsxs(q,{value:s.role||"none",onValueChange:t=>a({...s,role:t==="workflowState"||t==="sortRank"?t:void 0}),children:[e.jsx(P,{className:"h-7 text-xs mt-0.5",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"none",children:"None"}),e.jsx(R,{value:"workflowState",disabled:s.type!=="enum",children:"Workflow state (board)"}),e.jsx(R,{value:"sortRank",children:"Sort rank"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Examples"}),e.jsx("div",{className:"mt-0.5",children:e.jsx(Je,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function X({value:s,onChange:a,readonly:c,error:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:s,onChange:a,readonly:c,placeholder:'{ "type": "object", "properties": {} }',minHeight:"200px"}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Z(s){if(s.type!=="object")return!1;const a=s.properties;if(!a||typeof a!="object")return Object.keys(s).length<=1;for(const c of Object.values(a)){if(!c||typeof c!="object")return!1;const n=c,r=n.type;if(!n.enum&&(!r||!["string","number","integer","boolean"].includes(r)||n.properties||n.items||n.allOf||n.oneOf||n.anyOf))return!1}return!0}function de(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`field-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ee(s){const a=s.properties||{},c=s.required||[];return Object.entries(a).map(([n,r])=>{const t=r["x-lobu"]?.role||r["x-lobu-role"],i=t==="workflowState"?"workflowState":t==="sortRank"?"sortRank":void 0,o={id:de(),name:n,required:c.includes(n),description:r.description||void 0,default:r.default!==void 0?String(r.default):void 0,examples:Array.isArray(r.examples)?r.examples.map(String):void 0,role:i};return r.enum?{...o,type:"enum",enumOptions:r.enum||[]}:{...o,type:r.type||"string"}})}function se(s,a){if(a==="number"||a==="integer"){const c=Number(s);return Number.isNaN(c)?s:c}return a==="boolean"?s==="true"?!0:s==="false"?!1:s:s}function Ue(s,a="auto"){const c={},n=[];for(const t of s){if(!t.name.trim())continue;const i={};t.type==="enum"?i.enum=t.enumOptions||[]:i.type=t.type,t.description?.trim()&&(i.description=t.description.trim()),t.default!==void 0&&t.default!==""&&(i.default=se(t.default,t.type)),t.examples&&t.examples.length>0&&(i.examples=t.examples.map(o=>se(o,t.type))),t.role&&(i["x-lobu"]={role:t.role,...t.role==="workflowState"&&t.type==="enum"?{states:(t.enumOptions||[]).map(o=>({value:o,label:o.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase()),terminal:["done","complete","completed","closed","archived"].includes(o.toLowerCase())}))}:{}}),c[t.name]=i,t.required&&n.push(t.name)}const r={type:"object",properties:c};return n.length>0&&(r.required=n),a&&a!=="auto"&&(r["x-lobu"]={defaultView:a}),r}function te(s){const a=s["x-lobu"]?.defaultView;return a==="table"||a==="board"?a:"auto"}function $e({value:s,onChange:a,readonly:c=!1}){const[n,r]=x.useState("visual"),[t,i]=x.useState([]),[o,d]=x.useState("auto"),[h,m]=x.useState(""),[S,N]=x.useState(null),[y,b]=x.useState(!1),g=x.useRef(!1);x.useEffect(()=>{if(g.current){g.current=!1;return}if(!s||Object.keys(s).length===0){i([]),d("auto"),m(""),b(!1);return}const u=JSON.stringify(s,null,2);m(u),d(te(s)),Z(s)?(i(ee(s)),b(!1)):(b(!0),r("json"))},[s]);const j=x.useCallback((u,p)=>{g.current=!0;const v=Ue(u,p),T=u.some(F=>F.name.trim());m(T?JSON.stringify(v,null,2):""),a(T?v:void 0)},[a]),k=x.useCallback(u=>{i(u),j(u,o)},[j,o]),E=x.useCallback(u=>{d(u),j(t,u)},[j,t]),D=x.useCallback(u=>{if(g.current=!0,m(u),!u.trim()){N(null),i([]),d("auto"),a(void 0);return}try{const p=JSON.parse(u);N(null),d(te(p)),Z(p)?(i(ee(p)),b(!1)):b(!0),a(p)}catch(p){N(p instanceof Error?p.message:"Invalid JSON")}},[a]),w=()=>{k([...t,{id:de(),name:"",type:"string",required:!1}])},A=(u,p)=>{const v=[...t];v[u]=p,k(v)},_=u=>{k(t.filter((p,v)=>v!==u))};return c?e.jsx(X,{value:h,onChange:()=>{},readonly:!0}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(f,{type:"button",variant:n==="visual"?"default":"outline",size:"sm",onClick:()=>!y&&r("visual"),disabled:y,className:"h-7 text-xs",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(f,{type:"button",variant:n==="json"?"default":"outline",size:"sm",onClick:()=>r("json"),className:"h-7 text-xs",children:[e.jsx(Se,{className:"h-3 w-3 mr-1"}),"JSON"]})]}),y&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-amber-500/10 text-amber-600 text-xs",children:[e.jsx(oe,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsx("span",{children:"This schema uses advanced features (nested objects, allOf, etc.) that can only be edited in JSON mode."})]}),n==="visual"?e.jsxs("div",{className:"space-y-3",children:[t.map((u,p)=>e.jsx(Be,{field:u,onChange:v=>A(p,v),onDelete:()=>_(p)},u.id)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:w,className:"w-full",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1"}),"Add Field"]}),t.some(u=>u.name.trim())&&e.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border p-2.5",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default view"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Which view this type opens in. Auto picks from your fields (a workflow field → board, otherwise table)."})]}),e.jsxs(q,{value:o,onValueChange:u=>E(u),children:[e.jsx(P,{className:"h-8 w-32 text-xs",children:e.jsx(M,{})}),e.jsxs(L,{children:[e.jsx(R,{value:"auto",children:"Auto"}),e.jsx(R,{value:"table",children:"Table"}),e.jsx(R,{value:"board",children:"Board"})]})]})]})]}):e.jsx(X,{value:h,onChange:D,error:S})]})}function We(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function He({entityType:s,onCancel:a,onSaved:c}){const n=!!s,r=Ce(),t=ke(),i=s?.slug??"new",o=Ee(i,{name:s?.name??"",slug:s?.slug??"",description:s?.description??"",icon:s?.icon??"",color:s?.color??"",metadataSchema:s?.metadata_schema??void 0,backingSql:s?.backing_sql??""}),[d,h]=o.field("name"),[m,S]=o.field("slug"),[N,y]=o.field("description"),[b,g]=o.field("icon"),[j,k]=o.field("color"),[E,D]=o.field("metadataSchema"),[w,A]=o.field("backingSql"),[_,u]=Q(i,n),[p,v]=Q(i,null),T=w.trim().length>0,F=l=>{h(l),!n&&!_&&S(We(l))},J=async()=>{if(!o.canSubmit)return;if(v(null),!d.trim()){v("Name is required");return}if(!n&&!m.trim()){v("Slug is required");return}const l=T?{sql:w.trim()}:null;try{n?await t.mutateAsync({slug:s.slug,name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:T?void 0:E,backing:l}):await r.mutateAsync({slug:m.trim(),name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:T?void 0:E,backing:l}),c()}catch(I){v(I instanceof Error?I.message:"An error occurred")}},z=r.isPending||t.isPending;return e.jsxs("div",{className:"space-y-5",children:[e.jsx(_e,{visible:o.hasConflict,onReload:o.reset}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-name",children:"Name"}),e.jsx(O,{id:"et-name",value:d,onChange:l=>F(l.target.value),placeholder:"e.g. Product"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-slug",children:"Slug"}),e.jsx(O,{id:"et-slug",value:m,onChange:l=>{u(!0),S(l.target.value)},placeholder:"e.g. topic",disabled:n}),n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-desc",children:"Description"}),e.jsx(Re,{id:"et-desc",value:N,onChange:l=>y(l.target.value),placeholder:"Optional description...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-icon",children:"Icon (emoji)"}),e.jsx(O,{id:"et-icon",value:b,onChange:l=>g(l.target.value),placeholder:"e.g. 📦"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-color",children:"Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(O,{id:"et-color",value:j,onChange:l=>k(l.target.value),placeholder:"e.g. #6366f1",className:"flex-1"}),j&&e.jsx("div",{className:"h-9 w-9 rounded-md border border-border shrink-0",style:{backgroundColor:j}})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Backing query (SQL)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. A read-only SELECT turns this into a derived (view) type — rows are computed from the query, not stored. Leave empty for a normal stored type. Table references are auto-scoped to your organization."}),e.jsx(ce,{value:w,onChange:A,minHeight:"120px",placeholder:"SELECT (metadata->>'vendor') AS vendor, SUM((metadata->>'amount')::numeric) AS total FROM events GROUP BY 1"})]}),T?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-muted px-3 py-2 text-sm text-muted-foreground",children:[e.jsx(ie,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("span",{children:"Derived view — columns are computed from the query, so there's no stored-row schema to define."})]}),s?.measure_columns&&s.measure_columns.length>0&&e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx(C,{children:"Measure columns"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.measure_columns.map(l=>e.jsx("span",{className:"rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:l},l))})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Metadata Schema"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define the structure of metadata fields for entities of this type."}),e.jsx($e,{value:E,onChange:D})]}),n&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Relationships"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define how this entity type relates to others."}),e.jsx(qe,{entityType:s})]}),p&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:p}),e.jsx(Oe,{onCancel:a,cancelDisabled:z,className:"pt-2",children:e.jsx(f,{onClick:J,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function Xe({entityType:s,onClose:a,orgContext:c,hideDelete:n=!1,compact:r=!1}){const t=!!s,[i,o]=x.useState(!1),[d,h]=x.useState(!1),[m,S]=x.useState(null),N=Te(),{data:y,isLoading:b}=De(i&&s?s.slug:null,c),g=s?.entity_count??0,j=g>0,k=async()=>{if(s){S(null);try{await N.mutateAsync(s.slug),a()}catch(w){S(w instanceof Error?w.message:"Failed to delete")}}},E=t?`${s?.icon||"📄"} ${s?.name}`:"Create Entity Type",D=t?"Edit entity type configuration.":"Define a new entity type for your workspace.";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:G("space-y-1.5",!t&&!r&&"text-center"),children:[e.jsx("h1",{className:G("font-semibold leading-tight",r?"text-lg":"text-2xl"),children:E}),e.jsx("p",{className:"text-sm text-muted-foreground",children:D})]}),e.jsx("div",{className:"py-4",children:e.jsx(He,{entityType:s,onCancel:a,onSaved:a})}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[c.slug&&s?e.jsx(Ae,{to:"/$owner/events",params:{owner:c.slug},search:{semantic_types:"change",event_category:"config",resource_kind:"entity-type",resource_id:s.slug},className:"text-sm text-primary underline underline-offset-4",children:"View configuration history in Events"}):null,e.jsxs("button",{type:"button",onClick:()=>o(!i),className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[i?e.jsx(ne,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),"Schema audit records"]}),i&&e.jsx("div",{className:"mt-3",children:b?e.jsx(ae,{label:"history",variant:"rows",rows:4}):y&&y.length>0?e.jsx("div",{className:"relative ml-1.5",children:y.map(w=>e.jsx(ze,{entry:w},w.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No audit history found."})})]}),!n&&e.jsx("div",{className:"border-t border-border pt-4 mt-4",children:d?e.jsxs("div",{className:"space-y-3",children:[j?e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md bg-amber-500/10 text-amber-600",children:[e.jsx(oe,{className:"h-5 w-5 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium",children:"Cannot delete this entity type"}),e.jsxs("p",{className:"mt-1 text-amber-600/80",children:["There ",g===1?"is":"are"," ",g," entit",g===1?"y":"ies",' of type "',s.name,'". Migrate or delete them first.']})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Are you sure you want to delete "',s.name,'"? This action will soft-delete the entity type. It can be restored by a database administrator.']}),m&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{h(!1),S(null)},children:"Cancel"}),e.jsx(f,{variant:"destructive",size:"sm",onClick:k,disabled:j||N.isPending,children:N.isPending?"Deleting...":"Delete"})]})]}):e.jsxs(f,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>h(!0),children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete entity type"]})})]})]})}export{Xe as E};
|
|
2
|
+
//# sourceMappingURL=entity-type-page-BCBdFndu.js.map
|