@mohsinonxrm/pptb-dataverse-request-studio 1.5.0 → 1.6.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/CHANGELOG.md +330 -0
- package/README.md +30 -12
- package/dist/assets/ActionParamForm-DvTh6hUs.js +1 -0
- package/dist/assets/AllOrNothingOption-C7wGq_-r.js +1 -0
- package/dist/assets/AssociateMode-Dj-iEObO.js +1 -0
- package/dist/assets/BatchMode-Dsa1JVpd.js +10 -0
- package/dist/assets/BinaryColumnPickers-NAaoPcPt.js +1 -0
- package/dist/assets/BinaryPipelineCard-CSklRaME.js +1 -0
- package/dist/assets/BulkDeleteMode-Cqpb47QI.js +1 -0
- package/dist/assets/BulkWriteMode-CRkiw89Q.js +6 -0
- package/dist/assets/CodeView-C65Y5vXN.js +874 -0
- package/dist/assets/CreateMode-CwGffdDR.js +1 -0
- package/dist/assets/DeleteMode-CaWEZkJ1.js +1 -0
- package/dist/assets/DisassociateMode-Ddk9Jm3g.js +2 -0
- package/dist/assets/ExecuteActionMode-BbN_9350.js +1 -0
- package/dist/assets/ExecuteFunctionMode-G3PFBDpl.js +1 -0
- package/dist/assets/ExecuteWorkflowMode-D2MxIt5s.js +1 -0
- package/dist/assets/FieldSetEditor-Dg6WsDgG.js +3 -0
- package/dist/assets/ImportCurlDialog-BiURYtjH.js +7 -0
- package/dist/assets/ManageAttachmentMode-D14EZog8.js +1 -0
- package/dist/assets/ManageFileMode-DMLRV2xg.js +1 -0
- package/dist/assets/ManageImageMode-CoSAt9yh.js +1 -0
- package/dist/assets/MergeMode-PfbLAjOh.js +1 -0
- package/dist/assets/OptionGroup-DYAAm_pt.js +1 -0
- package/dist/assets/PredefinedQueryMode-CdT1I6jB.js +1 -0
- package/dist/assets/RetrieveNextLinkMode-BK9KD3q6.js +1 -0
- package/dist/assets/RetrieveSingleMode-_y2Z1G7C.js +1 -0
- package/dist/assets/UpdateMode-Dvd6cr4i.js +1 -0
- package/dist/assets/UpsertMode-BuyV7FEg.js +1 -0
- package/dist/assets/WriteResultCard-N_Ewu4dP.js +1 -0
- package/dist/assets/bypassAdvisories-BhBeq_oI.js +1 -0
- package/dist/assets/decodeForDisplay-D55DM53E.js +1 -0
- package/dist/assets/index-NW0Z4UWR.js +42 -0
- package/dist/assets/javascript-Dti3Ss-T.js +1 -0
- package/dist/assets/{jsonMode-DOHFeg2H.js → jsonMode-YuJX0ZcQ.js} +1 -1
- package/dist/assets/jsonWorkerInPage-CTjyykdK.js +33 -0
- package/dist/assets/{monacoSetup-CEhMjQNN.js → monacoSetup-Bxl8fgYX.js} +176 -176
- package/dist/assets/multipart-Bd_eOd8a.js +4 -0
- package/dist/assets/{python-DDgBOsRh.js → python-CZnGM3Qv.js} +1 -1
- package/dist/assets/writeResultName-Dw705_0B.js +1 -0
- package/dist/assets/writeState-DgYICTBE.js +1 -0
- package/dist/assets/{xml-BXhJpCm5.js → xml-gySD1GMR.js} +1 -1
- package/dist/index.html +7 -1
- package/index.html +6 -0
- package/package.json +1 -1
- package/dist/assets/AssociateMode-mu2ai0TV.js +0 -1
- package/dist/assets/AssociateTargetsEditor-BoH9Qxe8.js +0 -1
- package/dist/assets/BatchMode-BVAfFgPy.js +0 -11
- package/dist/assets/BinaryColumnPickers-DYpKoRIO.js +0 -1
- package/dist/assets/BulkDeleteMode-Df-XirlR.js +0 -1
- package/dist/assets/BulkWriteMode-UXREEvbe.js +0 -6
- package/dist/assets/DisassociateMode-CKBL5nUo.js +0 -2
- package/dist/assets/ExecuteWorkflowMode-4EWco-ze.js +0 -1
- package/dist/assets/ManageFileMode-BFNwxuEY.js +0 -1
- package/dist/assets/ManageImageMode-DX0AdPN1.js +0 -1
- package/dist/assets/MergeMode-BzyXLu1b.js +0 -1
- package/dist/assets/PredefinedQueryMode-BT-HdZHF.js +0 -1
- package/dist/assets/RetrieveNextLinkMode-QBuIwdgS.js +0 -1
- package/dist/assets/abap-CRCWOmpq.js +0 -1
- package/dist/assets/apex-DnsZk_dE.js +0 -1
- package/dist/assets/azcli-1IWB1ccx.js +0 -1
- package/dist/assets/bat-DPkNLes8.js +0 -1
- package/dist/assets/bicep-Corcdgou.js +0 -2
- package/dist/assets/cameligo-CGrWLZr3.js +0 -1
- package/dist/assets/clojure-D9WOWImG.js +0 -1
- package/dist/assets/coffee-B7EJu28W.js +0 -1
- package/dist/assets/cpp-SEyurbux.js +0 -1
- package/dist/assets/csp-C46ZqvIl.js +0 -1
- package/dist/assets/css-DQU6DXDx.js +0 -3
- package/dist/assets/css.worker-CwQehIRV.js +0 -93
- package/dist/assets/cssMode-DRNC4UuD.js +0 -4
- package/dist/assets/cypher-D84EuPTj.js +0 -1
- package/dist/assets/dart-D8lhlL1r.js +0 -1
- package/dist/assets/dockerfile-DLk6rpji.js +0 -1
- package/dist/assets/ecl-BO6FnfXk.js +0 -1
- package/dist/assets/elixir-BRjLKONM.js +0 -1
- package/dist/assets/flow9-Cac8vKd7.js +0 -1
- package/dist/assets/freemarker2-BITb8GyO.js +0 -3
- package/dist/assets/fsharp-fd1GTHhf.js +0 -1
- package/dist/assets/go-O9LJTZXk.js +0 -1
- package/dist/assets/graphql-LQdxqEYJ.js +0 -1
- package/dist/assets/handlebars-BbDVduNH.js +0 -1
- package/dist/assets/hcl-DxDQ3s82.js +0 -1
- package/dist/assets/html-Ru2Cy2VS.js +0 -1
- package/dist/assets/html.worker-4xVL0wjo.js +0 -470
- package/dist/assets/htmlMode-DeMh8vPt.js +0 -4
- package/dist/assets/index-XmEQbXiX.js +0 -703
- package/dist/assets/ini-BvajGCUy.js +0 -1
- package/dist/assets/java-SYsfObOQ.js +0 -1
- package/dist/assets/javascript-DLj2yjBO.js +0 -1
- package/dist/assets/julia-DQXNmw_w.js +0 -1
- package/dist/assets/kotlin-qQ0MG-9I.js +0 -1
- package/dist/assets/less-GGFNNJHn.js +0 -2
- package/dist/assets/lexon-Canl7DCW.js +0 -1
- package/dist/assets/liquid-udbJGOUP.js +0 -1
- package/dist/assets/lua-D28Ae8-K.js +0 -1
- package/dist/assets/m3-DPitgjJI.js +0 -1
- package/dist/assets/markdown-B811l8j2.js +0 -1
- package/dist/assets/mdx-B6ABiFDH.js +0 -1
- package/dist/assets/mips-CdjsipkG.js +0 -1
- package/dist/assets/msdax-CYqgjx_P.js +0 -1
- package/dist/assets/mysql-BHd6q0vd.js +0 -1
- package/dist/assets/objective-c-B1aVtJYH.js +0 -1
- package/dist/assets/pascal-BhNW15KB.js +0 -1
- package/dist/assets/pascaligo-5jv8CcQD.js +0 -1
- package/dist/assets/perl-DlYyT36c.js +0 -1
- package/dist/assets/pgsql-Dy0bjov7.js +0 -1
- package/dist/assets/php-120yhfDK.js +0 -1
- package/dist/assets/pla-CjnFlu4u.js +0 -1
- package/dist/assets/postiats-CQpG440k.js +0 -1
- package/dist/assets/powerquery-DdJtto1Z.js +0 -1
- package/dist/assets/protobuf-IBS6jZEB.js +0 -2
- package/dist/assets/pug-kFxLfcjb.js +0 -1
- package/dist/assets/qsharp-q7JyzKFN.js +0 -1
- package/dist/assets/r-BIFz-_sK.js +0 -1
- package/dist/assets/razor-DGf0KCTP.js +0 -1
- package/dist/assets/redis-CHOsPHWR.js +0 -1
- package/dist/assets/redshift-CBifECDb.js +0 -1
- package/dist/assets/restructuredtext-CghPJEOS.js +0 -1
- package/dist/assets/ruby-CYWGW-b1.js +0 -1
- package/dist/assets/rust-DMDD0SHb.js +0 -1
- package/dist/assets/sb-BYAiYHFx.js +0 -1
- package/dist/assets/scala-Bqvq8jcR.js +0 -1
- package/dist/assets/scheme-Dhb-2j9p.js +0 -1
- package/dist/assets/scss-CTwUZ5N7.js +0 -3
- package/dist/assets/solidity-CME5AdoB.js +0 -1
- package/dist/assets/sophia-RYC1BQQz.js +0 -1
- package/dist/assets/sparql-KEyrF7De.js +0 -1
- package/dist/assets/sql-BdTr02Mf.js +0 -1
- package/dist/assets/st-C7iG7M4S.js +0 -1
- package/dist/assets/swift-D7IUmUK8.js +0 -1
- package/dist/assets/systemverilog-DgMryOEJ.js +0 -1
- package/dist/assets/tcl-PloMZuKG.js +0 -1
- package/dist/assets/ts.worker-B8Ae6930.js +0 -51330
- package/dist/assets/tsMode-D4ZDTisA.js +0 -11
- package/dist/assets/twig-BfRIq3la.js +0 -1
- package/dist/assets/typescript-CJFgy1iR.js +0 -1
- package/dist/assets/typespec-CzxlYoT_.js +0 -1
- package/dist/assets/vb-BwAE3J76.js +0 -1
- package/dist/assets/wgsl-Dksx_ONF.js +0 -298
- package/dist/assets/yaml-B7iGwJkY.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as M,r as b,by as et,bz as xe,aF as ce,bA as tt,j as e,M as $,m as E,ay as G,bB as Q,av as ae,bC as rt,aW as we,s as at,bD as st,bE as it,B as X,t as o,bg as Ie,C as D,az as ot,aA as te,aQ as Ce,bv as nt,bF as lt,bG as se,bt as ie,bd as oe,an as ne,aB as dt,T as ct,bH as ut,bI as gt,f as pt,bh as bt,R as ht,u as Pe,U as ft,bJ as mt,x as yt,bK as xt,bL as jt,aH as St,aI as vt,X as kt,bM as Ft,bl as Tt,Y as re,Z as je,_ as Nt,bN as Me,bO as wt,bP as Se,a$ as De,b0 as It,a7 as Ct,a8 as Pt,aP as le,a9 as Mt,ad as ve,ae as Dt,af as Lt,ag as Rt,ah as Bt,ai as At,bQ as ke,bR as Ot,b8 as zt,o as Le,au as Re,be as $t,$ as Et,b9 as Vt,ax as Ut,bx as Ht,aj as _t,bS as Gt}from"./index-NW0Z4UWR.js";import{L as Wt}from"./FieldSetEditor-Dg6WsDgG.js";import{d as qt,s as Kt,B as Qt}from"./bypassAdvisories-BhBeq_oI.js";import{C as Xt}from"./CodeView-C65Y5vXN.js";import{d as Jt}from"./writeState-DgYICTBE.js";import"./multipart-Bd_eOd8a.js";const Yt=new Set(["createdon","modifiedon","createdby","modifiedby","createdonbehalfby","modifiedonbehalfby","versionnumber","importsequencenumber","overriddencreatedon","utcconversiontimezonecode","timezoneruleversionnumber","statecode","statuscode"]),Zt=s=>Yt.has(s.logicalName)||s.attributeType==="File"||s.attributeType==="Image"||s.attributeType==="Uniqueidentifier"&&s.isPrimaryKey===!0;function er(s){const{table:a,target:i,sub:t,fieldChoices:d,customValues:c,setFieldChoice:g,setCustomValue:n}=s,u=M(a),[h,S]=b.useState(""),[k,I]=b.useState(!0),F=b.useMemo(()=>!u||!i||!t?[]:u.columns.filter(x=>!Zt(x)&&x.isValidForUpdate!==!1&&!et(x)).map(x=>{const v=xe(i,x),T=xe(t,x),V=v==null||v==="",C=T==null||T==="";let w;return V&&C?w="both-empty":V&&!C?w="auto-fill":!V&&C?w="sub-empty":ce(x)?w=tt(v,T)?"same":"differs":w=String(v)===String(T)?"same":"differs",{col:x,targetVal:v,subVal:T,state:w}}),[u,i,t]),L=b.useMemo(()=>{let m=F;if(k&&(m=m.filter(y=>y.state==="differs"||y.state==="auto-fill")),h){const y=h.toLowerCase();m=m.filter(x=>x.col.displayName.toLowerCase().includes(y)||x.col.logicalName.toLowerCase().includes(y))}return m},[F,k,h]),N=b.useMemo(()=>{const m=Object.values(d).filter(v=>v!=="target").length,y=F.filter(v=>v.state==="differs").length,x=F.filter(v=>v.state==="auto-fill").length;return{overrides:m,differs:y,autoFill:x}},[d,F]);return u?!i||!t?e.jsxs("div",{children:[e.jsx(G,{icon:Q,title:"Field comparison",sub:"Pick both Target and Subordinate to see a side-by-side diff.",group:"write"}),e.jsx($,{layout:"multiline",intent:"info",style:{maxWidth:720},children:e.jsx(E,{children:!i&&!t?"Pick a Target (the record that survives) and a Subordinate (the duplicate to merge away) to start.":i?"Pick a Subordinate record on the left rail.":"Pick a Target record on the left rail."})})]}):e.jsxs("div",{children:[e.jsxs(G,{icon:Q,title:"Field comparison",sub:e.jsxs("span",{children:["For each differing field, pick what the merged row should carry — the Target's value, the Subordinate's value, or your own."," ",e.jsx("strong",{children:"Empty Target fields get auto-filled"})," from the Subordinate by the server."]}),group:"write",children:[e.jsx(ae,{contentBefore:e.jsx(rt,{}),"aria-label":"Filter fields",placeholder:"Filter fields…",value:h,onChange:(m,y)=>S(y.value),size:"small",style:{width:220}}),e.jsx(we,{content:k?"Showing only differing / auto-fill rows":"Showing every column",relationship:"description",children:e.jsx(at,{size:"small",appearance:k?"primary":"outline",icon:k?e.jsx(st,{}):e.jsx(it,{}),onClick:()=>I(m=>!m),children:k?"Diff only":"All fields"})}),e.jsxs(X,{appearance:"tint",color:N.overrides>0?"brand":"subtle",children:[N.overrides," override",N.overrides===1?"":"s"]}),e.jsxs(X,{appearance:"ghost",children:[N.differs," differ · ",N.autoFill," auto-fill"]})]}),e.jsx("div",{style:{maxWidth:1200,overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"separate",borderSpacing:0},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(q,{style:{width:"20%"},children:"Field"}),e.jsx(q,{tone:"target",children:"Target (survives)"}),e.jsx(q,{tone:"sub",children:"Subordinate"}),e.jsx(q,{style:{width:"34%"},children:"Final value"})]})}),e.jsxs("tbody",{children:[L.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,style:{padding:"24px 8px",textAlign:"center",color:o.colorNeutralForeground3,fontStyle:"italic"},children:k?'No differing fields. Toggle "All fields" to see the full row.':"No fields match the search."})}),L.map(m=>e.jsx(tr,{tbl:u,row:m,choice:d[m.col.logicalName]??"target",customValue:c[m.col.logicalName],onChoice:y=>g(m.col.logicalName,y),onCustom:y=>n(m.col.logicalName,y)},m.col.logicalName))]})]})})]}):e.jsx($,{layout:"multiline",intent:"error",children:e.jsxs(E,{children:["Unknown table ",e.jsx("code",{children:a}),"."]})})}function tr({tbl:s,row:a,choice:i,customValue:t,onChoice:d,onCustom:c}){const g=Ie(),{col:n,targetVal:u,subVal:h,state:S}=a,k=S==="differs",I=S==="auto-fill",F=!(h==null||h==="");return e.jsxs("tr",{children:[e.jsx(K,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx("span",{style:{fontWeight:500,color:o.colorNeutralForeground1,fontSize:12},children:n.displayName}),e.jsxs(D,{style:{color:o.colorNeutralForeground3,fontFamily:o.fontFamilyMonospace,fontSize:10},children:[n.logicalName," ·"," ",e.jsx("span",{style:{color:o.colorBrandForeground2},children:n.attributeType})]}),I&&e.jsx(we,{content:"Target is empty — server will auto-fill from Subordinate. No override needed.",relationship:"description",children:e.jsx(X,{appearance:"tint",color:"success",size:"small",style:{alignSelf:"flex-start"},children:"auto-fill"})})]})}),e.jsx(K,{tone:"target",children:e.jsx(Fe,{col:n,value:u})}),e.jsx(K,{tone:"sub",children:e.jsx(Fe,{col:n,value:h})}),e.jsx(K,{children:e.jsxs("div",{className:nt(g.inlineCard),style:{padding:"6px 8px"},children:[e.jsxs(ot,{layout:"horizontal",value:i,onChange:(L,N)=>d(N.value),children:[e.jsx(te,{value:"target",label:e.jsxs("span",{style:{fontSize:11},children:["Target",!k&&!I&&e.jsx("span",{style:{color:o.colorNeutralForeground3},children:" · default"})]})}),e.jsx(te,{value:"subordinate",disabled:!F,label:e.jsxs("span",{style:{fontSize:11},children:["Subordinate",!F&&e.jsx("span",{style:{color:o.colorNeutralForeground3},children:" · empty"})]})}),e.jsx(te,{value:"custom",label:e.jsx("span",{style:{fontSize:11},children:"Custom"})})]}),i==="custom"&&e.jsx("div",{style:{marginTop:6},children:e.jsx(rr,{col:n,value:t,onChange:c,fallback:typeof u=="object"?"":String(u??""),parentTable:s.logicalName})}),i==="subordinate"&&e.jsxs("div",{style:{marginTop:6,display:"flex",alignItems:"center",gap:6},children:[e.jsx(Ce,{style:{width:14,height:14,color:o.colorBrandForeground1}}),e.jsxs(D,{style:{color:o.colorBrandForeground2,fontWeight:500},children:["Will overwrite Target with: ",e.jsx("strong",{children:Be(n,h)})]})]})]})})]})}function q({children:s,style:a,tone:i}){const t=i==="target"?{background:"rgba(31,127,56,.08)",color:o.colorPaletteGreenForeground1}:i==="sub"?{background:"rgba(242,176,80,.08)",color:o.colorPaletteDarkOrangeForeground1}:{};return e.jsx("th",{style:{textAlign:"left",padding:"8px 10px",fontSize:11,fontWeight:600,color:o.colorNeutralForeground2,borderBottom:`2px solid ${o.colorNeutralStroke2}`,whiteSpace:"nowrap",...t,...a},children:s})}function K({children:s,tone:a}){const i=a==="target"?{background:"rgba(31,127,56,.025)",borderLeft:`2px solid ${o.colorPaletteGreenBorderActive}`}:a==="sub"?{background:"rgba(242,176,80,.025)",borderLeft:`2px solid ${o.colorPaletteDarkOrangeBorderActive}`}:{};return e.jsx("td",{style:{padding:"8px 10px",verticalAlign:"top",borderBottom:`1px solid ${o.colorNeutralStroke3}`,fontSize:12,...i},children:s})}function Fe({col:s,value:a}){if(a==null||a==="")return e.jsx("span",{style:{color:o.colorNeutralForeground3,fontStyle:"italic",fontSize:11},children:"(empty)"});const i=Be(s,a);return e.jsx("span",{style:{fontFamily:s.attributeType==="Uniqueidentifier"||ce(s)&&!a.name?o.fontFamilyMonospace:o.fontFamilyBase,fontSize:12,color:o.colorNeutralForeground1,wordBreak:"break-word"},children:i})}function Be(s,a){if(a==null||a==="")return"(empty)";if(s.attributeType==="Boolean")return a===!0||a==="1"||a===1?s.trueOption.label:s.falseOption.label;if(ce(s)&&typeof a=="object"&&"id"in a)return ut(a);const i=se(s);if(i){const t=Number(a);if(Number.isFinite(t)){const d=i.find(c=>c.value===t);if(d)return`${d.label} · ${t}`}if(s.attributeType==="MultiSelectPicklist"&&typeof a=="string")return a.split(",").map(d=>{const c=i.find(g=>String(g.value)===d);return c?c.label:d}).join(", ")}if(s.attributeType==="Money"){const t=Number(a);if(Number.isFinite(t))return t.toLocaleString(void 0,{style:"currency",currency:"USD"})}return s.attributeType==="DateTime"&&typeof a=="string"?gt(a,s):String(a)}function rr({col:s,value:a,onChange:i,fallback:t,parentTable:d}){switch(lt(d,s.logicalName),s.attributeType){case"Memo":return e.jsx(ct,{"aria-label":`${s.displayName} (custom value)`,rows:2,size:"small",value:a??t,onChange:(c,g)=>i(g.value),style:{fontFamily:o.fontFamilyMonospace,fontSize:12}});case"Integer":case"BigInt":case"Decimal":case"Double":case"Money":return e.jsx(dt,{"aria-label":`${s.displayName} (custom value)`,size:"small",value:Number(a??0),onChange:(c,g)=>{const n=g.value??Number(g.displayValue??0);Number.isFinite(n)&&i(n)}});case"Boolean":return e.jsx(ne,{checked:a===!0,onChange:(c,g)=>i(g.checked),label:a===!0?s.trueOption.label:s.falseOption.label});case"Picklist":case"State":case"Status":case"EntityName":{const c=se(s)??[],g=c.find(n=>n.value===a);return e.jsx(ie,{"aria-label":`${s.displayName} (custom value)`,size:"small",value:g?.label??(a!=null?String(a):""),selectedOptions:a!=null?[String(a)]:[],onOptionSelect:(n,u)=>u.optionValue&&i(Number(u.optionValue)),placeholder:"Pick a value…",children:c.map(n=>e.jsx(oe,{value:String(n.value),text:n.label,children:n.label},n.value))})}case"Lookup":case"Customer":case"Owner":return e.jsx(Wt,{col:s,value:a,onChange:i});case"MultiSelectPicklist":{const c=se(s)??[],g=Array.isArray(a)?a:typeof a=="string"&&a?a.split(",").map(n=>Number(n.trim())).filter(n=>Number.isFinite(n)):[];return e.jsx(ie,{"aria-label":`${s.displayName} (custom value)`,size:"small",multiselect:!0,value:g.map(n=>c.find(u=>u.value===n)?.label??String(n)).join(", "),selectedOptions:g.map(String),onOptionSelect:(n,u)=>{const h=(u.selectedOptions??[]).map(S=>Number(S)).filter(S=>Number.isFinite(S));i(h)},placeholder:"Pick one or more…",children:c.map(n=>e.jsx(oe,{value:String(n.value),text:n.label,children:n.label},n.value))})}case"DateTime":return e.jsx(ae,{"aria-label":`${s.displayName} (custom value)`,size:"small",type:s.format==="DateOnly"?"date":"datetime-local",value:typeof a=="string"?a.slice(0,16):"",onChange:(c,g)=>i(g.value),style:{fontFamily:o.fontFamilyMonospace,fontSize:12}});default:return e.jsx(ae,{"aria-label":`${s.displayName} (custom value)`,size:"small",value:a??t,onChange:(c,g)=>i(g.value)})}}const de=["account","contact","lead","incident"],Ae="account, contact, lead, and incident",ar=s=>de.includes(s),sr=()=>({table:"",targetId:null,subordinateId:null,fieldChoices:{},customValues:{},performParentingChecks:!0,suppressDuplicateDetection:!1,bypass:Jt(),headers:_t(),dirty:new Set,targetSnapshot:null,subordinateSnapshot:null}),z=Ot;function fr({themeMode:s}){const a=pt("merge"),i=bt("merge",ke,sr),[t,d]=b.useState(i.state),{table:c}=ht(t.table||null),{allEntities:g}=Pe(),[n,u]=b.useState("target"),[h,S]=b.useState("builder"),[k,I]=b.useState(null),[F,L]=b.useState(!1),[N,m]=ft("merge"),[y,x]=b.useState(i.lastSavedId),[v,T]=b.useState(i.lastSavedHash),[V,C]=b.useState(!1),[w,J]=b.useState(!1),j=M(t.table),Y=b.useMemo(()=>{const r=t.subordinateSnapshot;if(!j||!r)return[];const p=new Set;for(const[l,f]of Object.entries(t.fieldChoices)){if(f!=="subordinate")continue;const A=j.columns.find(Ze=>Ze.logicalName===l),O=A&&mt(r,A)?.targetEntity;O&&p.add(O)}return[...p].sort()},[j,t.subordinateSnapshot,t.fieldChoices]),Oe=Y.join("|"),[ze,$e]=b.useState([]);b.useEffect(()=>{for(const r of Y)M(r)||yt.getTable(r).catch(()=>{}).then(p=>{p||$e(l=>l.includes(r)?l:[...l,r])})},[Oe]);const W=Y.filter(r=>!M(r)),ue=W.filter(r=>ze.includes(r)),U=b.useMemo(()=>xt(t),[t,c]),Ee=W.join("|"),Ve=b.useMemo(()=>jt(t),[t,c,Ee]);b.useEffect(()=>{let r=!1;if(!t.table||!t.targetId||!j||!z(t.targetId)){d(l=>({...l,targetSnapshot:null}));return}if(typeof window>"u"||!window.dataverseAPI?.queryData)return;C(!0);const p=`/${j.entitySetName}(${t.targetId})`;return window.dataverseAPI.queryData(p).then(l=>{if(r)return;const f=l?.value,A=Array.isArray(f)?f[0]??null:f&&typeof f=="object"?f:l&&typeof l=="object"&&j.primaryKey in l?l:null;d(O=>({...O,targetSnapshot:A})),C(!1)}).catch(()=>{r||(d(l=>({...l,targetSnapshot:null})),C(!1))}),()=>{r=!0}},[t.table,t.targetId,j]),b.useEffect(()=>{let r=!1;if(!t.table||!t.subordinateId||!j||!z(t.subordinateId)){d(l=>({...l,subordinateSnapshot:null}));return}if(typeof window>"u"||!window.dataverseAPI?.queryData)return;J(!0);const p=`/${j.entitySetName}(${t.subordinateId})`;return window.dataverseAPI.queryData(p).then(l=>{if(r)return;const f=l?.value,A=Array.isArray(f)?f[0]??null:f&&typeof f=="object"?f:l&&typeof l=="object"&&j.primaryKey in l?l:null;d(O=>({...O,subordinateSnapshot:A})),J(!1)}).catch(()=>{r||(d(l=>({...l,subordinateSnapshot:null})),J(!1))}),()=>{r=!0}},[t.table,t.subordinateId,j]);const ge=r=>d(p=>{const l=new Set(p.dirty);return l.add(r),{...p,dirty:l}}),R=(r,p,l)=>{d(f=>({...f,[r]:p})),l&&ge(l)},Ue=(r,p)=>{d(l=>{const f={...l.fieldChoices};return p==="target"?delete f[r]:f[r]=p,{...l,fieldChoices:f,dirty:new Set(l.dirty).add("fielddiff")}})},He=(r,p)=>{d(l=>({...l,customValues:{...l.customValues,[r]:p},dirty:new Set(l.dirty).add("fielddiff")}))},Z=t.targetSnapshot,ee=t.subordinateSnapshot,H=Object.values(t.fieldChoices).filter(r=>r!=="target").length,_e=j?ar(j.logicalName)?t.targetId?z(t.targetId)?t.subordinateId?z(t.subordinateId)?t.targetId===t.subordinateId?"Target and Subordinate must be different records.":t.headers.some(r=>r.enabled&&!r.name)?"Fix empty header name.":ue.length>0?`Couldn't load metadata for ${ue.join(", ")}, so a lookup kept from the Subordinate can’t be bound. Pick Target or Custom for it instead.`:W.length>0?`Loading metadata for ${W.join(", ")} to bind the lookups kept from the Subordinate…`:null:"Subordinate record id is not a valid GUID.":"Pick a Subordinate record (the loser).":"Target record id is not a valid GUID.":"Pick a Target record (the winner).":`Merge is only supported for ${Ae}.`:"Pick a target table first.",Ge=async()=>{L(!0);const r=await Vt.merge(t,ve(pe,null));I(r),L(!1),S("results"),m(Ut({snapshot:B,modeId:"merge",url:U.relativeUrl,method:"POST",status:r.status,ms:r.ms,rowCount:r.ok?1:0})),d(p=>({...p,dirty:new Set}))},pe=b.useMemo(()=>St(t),[t]),be=b.useMemo(()=>{const r=[...qt(t.bypass,"bypass"),...vt({op:"merge",bypass:t.bypass})];return t.targetId&&!z(t.targetId)&&r.push({id:"merge-bad-target-guid",severity:"error",source:"validation",focusNode:"target",title:"Invalid Target record id",body:`"${t.targetId}" isn't a valid GUID. The merge will fail at the wire.`}),t.subordinateId&&!z(t.subordinateId)&&r.push({id:"merge-bad-sub-guid",severity:"error",source:"validation",focusNode:"subordinate",title:"Invalid Subordinate record id",body:`"${t.subordinateId}" isn't a valid GUID. The merge will fail at the wire.`}),r},[t.bypass,t.targetId,t.subordinateId]),We=kt(be),B=b.useMemo(()=>Ft(t),[t]);Tt("merge",B,y,v);const qe=b.useMemo(()=>re(B),[B]),he=v===null?!0:qe!==v,Ke=r=>{x(r.id),T(re(r.state))},fe=r=>{if(r.modeId!=="merge")return;const p=r.state;if(g.length>0&&!g.some(l=>l.logicalName===p.table)){zt(`Can't load "${r.name}": entity \`${p.table}\` isn't available in this environment. The solution may have been removed or you may be connected to a different org.`);return}d(ke(p)),x(r.id),T(re(p)),I(null),u("target")},Qe=r=>{const p=Ht(r,"merge");if(!p)return;const l=y,f=v;fe(p),x(l),T(f)},me=je(Ke),ye=je(fe);Nt(b.useMemo(()=>t.table?{state:B,modeId:"merge",dirty:he,lastSavedId:y,onSaved:me,onLoadSaved:ye}:null,[B,he,y,t.table,me,ye]));const Xe=[{id:"target",label:"Target",meta:j?.displayName??"Pick a table",items:[{id:"target",icon:wt,iconFilled:Me,label:"Master (survives)",badge:t.targetId?"✓":null,badgeAppearance:"ghost",dirty:t.dirty.has("target")||t.dirty.has("entity")}]},{id:"subordinate-section",label:"Subordinate",meta:t.subordinateId?"will be deactivated":"pick a record",items:[{id:"subordinate",icon:Se,iconFilled:Q,label:"Subordinate record",badge:t.subordinateId?"✓":null,badgeAppearance:"ghost",dirty:t.dirty.has("subordinate")}]},{id:"override",label:"Override fields",meta:`${H} override${H===1?"":"s"}`,items:[{id:"fielddiff",icon:Se,iconFilled:Q,label:"Field comparison",badge:H||null,badgeAppearance:"tint",badgeColor:H>0?"brand":"subtle",dirty:t.dirty.has("fielddiff")}]},{id:"settings",label:"Settings",meta:(t.performParentingChecks?1:0)+(t.suppressDuplicateDetection?1:0)==0?"defaults":`${(t.performParentingChecks?1:0)+(t.suppressDuplicateDetection?1:0)} set`,items:[{id:"options",icon:It,iconFilled:De,label:"Merge options",badge:(t.performParentingChecks?1:0)+(t.suppressDuplicateDetection?1:0)||null,badgeAppearance:"ghost",dirty:t.dirty.has("options")}]},{id:"headers",label:"Headers",meta:`${t.headers.filter(r=>r.enabled).length} active`,items:[{id:"headers",icon:Pt,iconFilled:Ct,label:"HTTP headers",badge:t.headers.filter(r=>r.enabled).length||null,dirty:t.dirty.has("headers")},{id:"bypass",icon:le,iconFilled:le,label:"Bypass logic",badge:Kt(t.bypass),badgeAppearance:t.bypass.businessLogic!=="none"||t.bypass.suppressFlows?"tint":"ghost",badgeColor:t.bypass.businessLogic!=="none"||t.bypass.suppressFlows?"warning":"subtle",dirty:t.dirty.has("bypass")}]}];let P;switch(n){case"target":P=e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx(nr,{state:t,setState:d,markDirty:ge,onEntityChange:()=>{x(void 0),T(null)}}),e.jsx(Ne,{title:"Master record",sub:"The record that keeps its identity. Subordinate is merged into it.",table:t.table,selectedId:t.targetId,onPick:r=>R("targetId",r,"target")})]});break;case"subordinate":P=e.jsx(Ne,{title:"Subordinate (deactivated)",sub:"The duplicate to merge away. Its relationships re-parent to the Target; the row gets statecode=Inactive.",table:t.table,selectedId:t.subordinateId,onPick:r=>R("subordinateId",r,"subordinate"),conflictWith:t.targetId});break;case"fielddiff":P=e.jsxs("div",{children:[e.jsx(ir,{overrideCount:H,subordinateName:_(j,ee??void 0)}),e.jsx(or,{table:t.table,target:Z??void 0,subordinate:ee??void 0,targetLoading:V,subordinateLoading:w}),e.jsx(er,{table:t.table,target:t.targetSnapshot??null,sub:t.subordinateSnapshot??null,fieldChoices:t.fieldChoices,customValues:t.customValues,setFieldChoice:Ue,setCustomValue:He})]});break;case"options":P=e.jsx(lr,{performParentingChecks:t.performParentingChecks,setPerformParentingChecks:r=>R("performParentingChecks",r,"options"),suppressDuplicateDetection:t.suppressDuplicateDetection,setSuppressDuplicateDetection:r=>R("suppressDuplicateDetection",r,"options")});break;case"headers":P=e.jsx(Mt,{items:t.headers,setItems:r=>R("headers",r,"headers"),group:"write"});break;case"bypass":P=e.jsx(Qt,{value:t.bypass,onChange:r=>R("bypass",r,"bypass"),group:"write"});break}const Je=ve(pe,null),Ye={method:"POST",built:U,headers:Je,body:Ve,entityLogical:U.entityLogical};return e.jsx(Dt,{sidebar:e.jsx(At,{type:a,urlPreview:U.relativeNoBase,sections:Xe,activeNode:n,onSelect:r=>{u(r),S("builder")},recents:N,onRecentClick:Qe}),urlBar:e.jsx(Bt,{method:"POST",url:U.relativeUrl,executeVerb:a.executeVerb,writeConfirm:{operation:"Merge Records",table:t.table,scope:{kind:"text",text:"2 records: the subordinate merges into the master and is deactivated"},highImpact:!0},disabledReason:_e??We,loading:F,onExecute:Ge,advisories:be,onAdvisoryFocus:u}),children:e.jsxs(Lt,{tab:h,onTabChange:S,resultCount:k?.ok?1:null,children:[h==="builder"&&P,h==="code"&&e.jsx(Xt,{themeMode:s,inputs:Ye}),h==="results"&&e.jsx(Rt,{result:k,mode:"single",table:t.table,writeContext:{operation:"merge",table:t.table,recordId:t.targetId,recordName:_(j,Z??void 0),targetName:_(j,Z??void 0),subordinateName:_(j,ee??void 0)}})]})})}function ir({overrideCount:s,subordinateName:a}){return e.jsx($,{layout:"multiline",intent:"warning",icon:e.jsx(le,{}),style:{marginBottom:14},children:e.jsxs(E,{children:[e.jsx(Le,{children:"Merge is irreversible."}),a?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a})," will be deactivated,"," "]}):"The subordinate will be deactivated, ","its related records re-parent to the Target, and ",e.jsx("strong",{children:s})," field",s===1?"":"s"," on the Target will be overwritten by your overrides. The server also auto-fills any empty Target fields from the Subordinate."]})})}function or({table:s,target:a,subordinate:i,targetLoading:t,subordinateLoading:d}){const c=Ie(),g=M(s);return g?e.jsxs("div",{className:c.inlineCard,style:{padding:14,marginBottom:14,display:"grid",gridTemplateColumns:"1fr 44px 1fr",gap:10,alignItems:"stretch"},children:[e.jsx(Te,{tone:"target",chip:"TARGET",chipDescription:"survives the merge",row:a,tbl:g,emptyHint:t?"Loading Target record…":"Pick a Target record."}),e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",color:o.colorNeutralForeground3},children:e.jsx(Ce,{style:{width:28,height:28}})}),e.jsx(Te,{tone:"sub",chip:"SUBORDINATE",chipDescription:"will be deactivated",row:i,tbl:g,emptyHint:d?"Loading Subordinate record…":"Pick a Subordinate record."})]}):null}function Te({tone:s,chip:a,chipDescription:i,row:t,tbl:d,emptyHint:c}){const g=s==="target"?{border:`1px solid ${o.colorPaletteGreenBorderActive}`,background:o.colorPaletteGreenBackground1}:{border:`1px solid ${o.colorPaletteDarkOrangeBorderActive}`,background:o.colorPaletteDarkOrangeBackground1},n=s==="target"?o.colorPaletteGreenForeground1:o.colorPaletteDarkOrangeForeground1,u=_(d,t),h=t?String(t[d.primaryKey]??""):null,S=t?.createdon?String(t.createdon):null,k=S?new Date(S).toLocaleDateString(void 0,{year:"numeric",month:"short"}):null;return e.jsxs("div",{style:{...g,borderRadius:o.borderRadiusMedium,padding:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx(X,{appearance:"filled",style:{background:n,color:o.colorNeutralForegroundOnBrand,fontWeight:700,letterSpacing:.4},children:a}),e.jsx(D,{style:{color:o.colorNeutralForeground3},children:i})]}),t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[e.jsx(Gt,{size:"small",name:u??"?",avatar:{color:"colorful"}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600},children:u??"(no name)"}),e.jsx("div",{style:{fontFamily:o.fontFamilyMonospace,fontSize:10,color:o.colorNeutralForeground3},children:h??""})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,fontSize:11,color:o.colorNeutralForeground3},children:[k&&e.jsxs("div",{children:["Created:"," ",e.jsx("strong",{style:{color:o.colorNeutralForeground2},children:k})]}),t.accountnumber!=null&&e.jsxs("div",{children:["Account #:"," ",e.jsx("strong",{style:{color:o.colorNeutralForeground2,fontFamily:o.fontFamilyMonospace},children:String(t.accountnumber)})]}),t.revenue!=null&&e.jsxs("div",{children:["Revenue:"," ",e.jsx("strong",{style:{color:o.colorNeutralForeground2},children:Number(t.revenue).toLocaleString(void 0,{style:"currency",currency:"USD",maximumFractionDigits:0})})]}),t.emailaddress1!=null&&e.jsxs("div",{children:["Email:"," ",e.jsx("strong",{style:{color:o.colorNeutralForeground2},children:String(t.emailaddress1)})]})]})]}):e.jsx("div",{style:{padding:"20px 4px",color:o.colorNeutralForeground3,fontSize:12,fontStyle:"italic",textAlign:"center"},children:c})]})}function nr({state:s,setState:a,markDirty:i,onEntityChange:t}){const d=M(s.table),{allEntities:c,allLoading:g}=Pe(),n=b.useMemo(()=>de.map(u=>c.find(h=>h.logicalName===u)).filter(u=>!!u),[c]);return e.jsxs("div",{children:[e.jsx(G,{icon:Et,title:"Merge entity type",sub:`Pick the table to merge. The Merge action is restricted to ${Ae}.`,group:"write"}),e.jsxs("div",{style:{maxWidth:560},children:[e.jsx(Re,{label:"Entity",hint:g?"Loading tables…":n.length===0?`No Merge-supported table (${de.join(", ")}) was found in this environment.`:void 0,children:e.jsx(ie,{value:d?.displayName??"",selectedOptions:[s.table],onOptionSelect:(u,h)=>{h.optionValue&&(a(S=>({...S,table:h.optionValue,targetId:null,subordinateId:null,fieldChoices:{},customValues:{},targetSnapshot:null,subordinateSnapshot:null})),i("entity"),i("target"),i("subordinate"),i("fielddiff"),t())},children:n.map(u=>e.jsx(oe,{value:u.logicalName,text:u.displayName,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx("span",{children:u.displayName}),e.jsxs(D,{style:{color:o.colorNeutralForeground3},children:[u.entitySetName," · supports Merge"]})]})},u.logicalName))})}),e.jsx($,{layout:"multiline",intent:"info",style:{marginTop:14},children:e.jsxs(E,{children:["Merge requires both records be the ",e.jsx("strong",{children:"same entity type"}),"."," ",e.jsx("code",{children:"incident"})," behaves differently — per docs, the ",e.jsx("code",{children:"UpdateContent"})," ","parameter is ",e.jsx("strong",{children:"ignored"})," for incident, and the merge runs in the user's security context (not system)."]})})]})]})}function Ne({title:s,sub:a,table:i,selectedId:t,onPick:d,conflictWith:c}){const g=M(i),n=c&&t&&c===t;return e.jsxs("div",{children:[e.jsx(G,{icon:Me,title:s,sub:a,group:"write"}),e.jsxs("div",{style:{maxWidth:480},children:[e.jsx(Re,{label:"Record",children:e.jsx($t,{table:i,selectedId:t,onPick:u=>d(u?.id??null),placeholder:`Search ${g?.displayName??""} records…`})}),n&&e.jsx($,{layout:"multiline",intent:"error",style:{marginTop:14},children:e.jsx(E,{children:"Target and Subordinate must be different records."})}),!t&&e.jsx(D,{style:{display:"block",marginTop:8,color:o.colorNeutralForeground3},children:"Tip: use the search box to filter by primary name (e.g. account name, contact full name)."})]})]})}function lr({performParentingChecks:s,setPerformParentingChecks:a,suppressDuplicateDetection:i,setSuppressDuplicateDetection:t}){return e.jsxs("div",{children:[e.jsx(G,{icon:De,title:"Merge options",sub:"Controls applied during the merge operation.",group:"write"}),e.jsxs("div",{style:{maxWidth:720,display:"flex",flexDirection:"column",gap:16},children:[e.jsx("div",{style:{padding:12,border:`1px solid ${o.colorNeutralStroke2}`,borderRadius:o.borderRadiusMedium},children:e.jsx(ne,{checked:s,onChange:(d,c)=>a(c.checked),label:e.jsxs("span",{children:[e.jsx("strong",{children:"PerformParentingChecks"}),e.jsx(D,{style:{display:"block",color:o.colorNeutralForeground3,marginTop:2},children:"When enabled, the merge fails if the Target and Subordinate have different parent records. Useful for child entities (e.g. contacts under different accounts)."})]})})}),e.jsx("div",{style:{padding:12,border:`1px solid ${o.colorNeutralStroke2}`,borderRadius:o.borderRadiusMedium},children:e.jsx(ne,{checked:i,onChange:(d,c)=>t(c.checked),label:e.jsxs("span",{children:[e.jsx("strong",{children:"MSCRM.SuppressDuplicateDetection"})," ",e.jsx("code",{style:{fontFamily:o.fontFamilyMonospace,fontSize:11},children:"= true"}),e.jsxs(D,{style:{display:"block",color:o.colorNeutralForeground3,marginTop:2},children:["Skip duplicate detection rules when applying ",e.jsx("code",{children:"UpdateContent"})," to the Target. Adds the ",e.jsx("code",{children:"MSCRM.SuppressDuplicateDetection: true"})," request header."]})]})})}),e.jsx($,{layout:"multiline",intent:"warning",children:e.jsxs(E,{children:[e.jsx(Le,{children:"Merge is destructive."}),"The Subordinate is deactivated (",e.jsx("code",{children:"statecode=Inactive"}),") and most of its relationships re-parent to the Target. Some Target fields take Subordinate's value only when the Target's value is empty. Use ",e.jsx("strong",{children:"UpdateContent"})," (the Field comparison pane) to override that."]})})]})]})}function _(s,a){if(!s||!a)return null;const i=a[s.primaryName];return i!=null?String(i):null}export{fr as MergeMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as s,e0 as r,e1 as p,e2 as u,e3 as a}from"./index-NW0Z4UWR.js";const n=s.forwardRef((t,o)=>{const e=r(t,o);return p(e),u("useOptionGroupStyles_unstable")(e),a(e)});n.displayName="OptionGroup";export{n as O};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{bb as Be,r as d,R as K,j as t,au as U,bc as He,bd as W,C as f,t as c,S as Se,be as We,bf as Ue,z as ke,f as Xe,bg as Ve,bh as _e,u as Ge,U as Ye,bi as Ze,bj as Je,W as Ke,X as et,bk as tt,bl as at,Y as Z,Z as de,_ as rt,bm as st,bn as nt,a1 as ue,a2 as it,bo as lt,bp as ot,a$ as dt,b0 as ut,a7 as ct,a8 as pt,b1 as ce,a9 as mt,b2 as ht,bq as yt,ay as ft,M as pe,m as me,o as he,ab as gt,br as bt,bs as ye,bt as xt,bu as J,B as R,aW as vt,bv as jt,ad as fe,ae as St,af as kt,ag as Nt,ah as wt,ai as Tt,bw as ge,b8 as qt,b9 as Ft,ax as Pt,ba as Ct,bx as $t,b6 as Rt,e as It}from"./index-NW0Z4UWR.js";import{M as Mt,C as Lt}from"./CodeView-C65Y5vXN.js";import{O as be}from"./OptionGroup-DYAAm_pt.js";import"./multipart-Bd_eOd8a.js";function xe(u,n=!1,h){const y=new Set,a=[];for(const r of u.navigationProperties){if(r.cardinality==="OneToMany"||!Ue(r,n)&&r.relationshipName!==h)continue;const m=`${r.relationshipName}|${r.targetEntity}`;y.has(m)||(y.add(m),a.push({relationshipName:r.relationshipName,sourceTable:r.targetEntity,via:r.referencingAttribute??r.name,manyToMany:r.cardinality==="ManyToMany"}))}return a.sort((r,m)=>r.sourceTable.localeCompare(m.sourceTable)||r.relationshipName.localeCompare(m.relationshipName))}function Qt(u,n,h){return u.navigationProperties.find(a=>a.relationshipName===n&&a.cardinality!=="ManyToOne"&&a.targetEntity===h)?.name??null}function Et({table:u,value:n,onChange:h}){const y=Be(),a=d.useMemo(()=>xe(u,y,n.relationshipName),[u,y,n.relationshipName]),{table:r,loading:m}=K(n.sourceTable||null);d.useEffect(()=>{if(!r||!n.relationshipName)return;const i=Qt(r,n.relationshipName,u.logicalName)??"";i!==n.navProperty&&h({...n,navProperty:i})},[r,n.relationshipName,u.logicalName]);const x=i=>`${i.relationshipName}|${i.sourceTable}`,v=a.find(i=>i.relationshipName===n.relationshipName&&i.sourceTable===n.sourceTable),g=i=>`${ke(i.sourceTable)?.displayName??i.sourceTable} · ${i.relationshipName}`;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsx(U,{label:"Relationship",hint:a.length?`Rows of ${u.displayName} related to one row of another table.`:void 0,validationState:a.length?"none":"warning",validationMessage:a.length?void 0:y&&xe(u).length>0?`None of ${u.displayName}'s lookups or many-to-many relationships are shown in Advanced Find. Turn off "Advanced Find only" in Settings to see them.`:`${u.displayName} has no lookups or many-to-many relationships.`,children:t.jsx(He,{placeholder:"Pick a relationship…",value:v?g(v):"",selectedOptions:v?[x(v)]:[],onOptionSelect:(i,P)=>{const k=a.find(I=>x(I)===P.optionValue);k&&h({sourceTable:k.sourceTable,relationshipName:k.relationshipName,navProperty:"",recordId:k.sourceTable===n.sourceTable?n.recordId:null,recordName:k.sourceTable===n.sourceTable?n.recordName:void 0})},listbox:{style:{maxHeight:360}},children:a.map(i=>t.jsx(W,{value:x(i),text:g(i),children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[t.jsx("span",{children:g(i)}),t.jsx(f,{style:{color:c.colorNeutralForeground3,fontFamily:c.fontFamilyMonospace},children:i.manyToMany?`many-to-many · ${i.via}`:`via ${i.via}`})]})},x(i)))})}),n.sourceTable&&m&&!r&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(Se,{size:"tiny"}),t.jsxs(f,{children:["Loading ",n.sourceTable," metadata…"]})]}),r&&n.relationshipName&&!n.navProperty&&t.jsxs(f,{style:{color:c.colorPaletteRedForeground1},children:[r.displayName," has no collection navigation property for ",n.relationshipName,"."]}),r&&n.navProperty&&t.jsx(U,{label:`${r.displayName} row`,hint:t.jsxs("span",{children:["Collection: ",t.jsx("code",{children:`${r.entitySetName}(…)/${n.navProperty}`})]}),children:t.jsx(We,{table:r.logicalName,selectedId:n.recordId,onPick:i=>h({...n,recordId:i?.id??null,recordName:i?.primary})})})]})}const At=()=>({table:"",queryId:null,queryType:"savedQuery",top:50,prefer:{...It(),formattedValues:!0},headers:Rt(),dirty:new Set}),ve={sourceTable:"",relationshipName:"",navProperty:"",recordId:null};function je(u){if(!u)return[];const n=[...u.matchAll(/<cell\s+([^>]+?)\s*\/?>/g)],h=[];for(const y of n){const a=y[1],r=/name="([^"]+)"/.exec(a);if(!r)continue;const m=r[1],x=/width="([^"]+)"/.exec(a),v=x&&parseInt(x[1],10)||100,g=m.indexOf(".");g>=0?h.push({fullName:m,width:v,isLink:!0,linkAlias:m.slice(0,g),attr:m.slice(g+1)}):h.push({fullName:m,width:v,isLink:!1,attr:m})}return h}function Dt(u){switch(u){case 0:return"Main view";case 1:return"Advanced Find";case 2:return"Subgrid";case 4:return"Quick Find";case 8:return"Reserved";case 16:return"Lookup";case 32:return"Marketing list";case 64:return"Address book";case 128:return"Main (no subj)";case 256:return"Outlook filter";case 512:return"Reserved";case 1024:return"Offline filter";case 2048:return"Outlook template";case 4096:return"Reserved";case 8192:return"Svc mgmt app";default:return`Type ${u}`}}function Wt({themeMode:u}){const n=Xe("predefined-query"),h=Ve(),y=_e("predefined-query",ge,At),[a,r]=d.useState(y.state),{table:m}=K(a.table||null),{allEntities:x}=Ge(),[v,g]=d.useState("target"),[i,P]=d.useState("builder"),[k,I]=d.useState(null),[Ne,we]=d.useState(void 0),[Te,ee]=d.useState(!1),[qe,Fe]=Ye("predefined-query"),[M,L]=d.useState(y.lastSavedId),[Q,E]=d.useState(y.lastSavedHash),[T,A]=d.useState([]),[X,V]=d.useState(!1),[te,_]=d.useState(null),[N,D]=d.useState(""),{table:Pe}=K(a.related?.sourceTable||null),C=d.useMemo(()=>Ze(a),[a,m,Pe]),G=ke(a.table),o=T.find(e=>e.id===a.queryId)??null,z=T.filter(e=>e.kind==="savedQuery"),O=T.filter(e=>e.kind==="userQuery"),B=d.useMemo(()=>{const e=N.trim().toLowerCase();return e?z.filter(l=>l.name.toLowerCase().includes(e)):z},[z,N]),H=d.useMemo(()=>{const e=N.trim().toLowerCase();return e?O.filter(l=>l.name.toLowerCase().includes(e)):O},[O,N]);d.useEffect(()=>{D(o?.name??"")},[o?.name,a.table]),d.useEffect(()=>{let e=!1;if(!a.table){A([]),_(null);return}if(typeof window>"u"||!window.dataverseAPI?.queryData){A([]);return}V(!0),_(null);const l="savedqueryid,name,description,fetchxml,layoutxml,returnedtypecode,querytype,isdefault,isquickfindquery,iscustomizable,ismanaged",p="userqueryid,name,description,fetchxml,layoutxml,returnedtypecode,querytype",b=`savedqueries?$select=${l}&$filter=returnedtypecode eq '${a.table}' and statecode eq 0&$orderby=name asc`,De=`userqueries?$select=${p}&$filter=returnedtypecode eq '${a.table}' and statecode eq 0&$orderby=name asc`;return Promise.all([window.dataverseAPI.queryData(b).catch(j=>{throw j instanceof Error?j:new Error(String(j))}),window.dataverseAPI.queryData(De).catch(()=>({value:[]}))]).then(([j,Y])=>{if(e)return;const ze=j?.value??[],Oe=Y?.value??[],oe=[...ze.map(s=>{const S=s.layoutxml!=null?String(s.layoutxml):null;return{id:String(s.savedqueryid??""),name:String(s.name??"(unnamed)"),description:s.description!=null?String(s.description):null,fetchXml:s.fetchxml!=null?String(s.fetchxml):null,layoutXml:S,layoutColumns:je(S),returnedTypeCode:String(s.returnedtypecode??a.table),queryType:typeof s.querytype=="number"?s.querytype:0,isDefault:s.isdefault===!0,isQuickFind:s.isquickfindquery===!0,isCustom:s.iscustomizable?.Value===!0,isManaged:s.ismanaged===!0,kind:"savedQuery"}}),...Oe.map(s=>{const S=s.layoutxml!=null?String(s.layoutxml):null;return{id:String(s.userqueryid??""),name:String(s.name??"(unnamed)"),description:s.description!=null?String(s.description):null,fetchXml:s.fetchxml!=null?String(s.fetchxml):null,layoutXml:S,layoutColumns:je(S),returnedTypeCode:String(s.returnedtypecode??a.table),queryType:typeof s.querytype=="number"?s.querytype:0,isDefault:!1,isQuickFind:!1,isCustom:!0,isManaged:!1,kind:"userQuery"}})];oe.sort((s,S)=>s.kind!==S.kind?s.kind==="savedQuery"?-1:1:s.isDefault!==S.isDefault?s.isDefault?-1:1:s.name.localeCompare(S.name)),A(oe),V(!1)}).catch(j=>{if(e)return;const Y=j instanceof Error?j.message:String(j);_(Y),A([]),V(!1)}),()=>{e=!0}},[a.table]);const $=e=>r(l=>{const p=new Set(l.dirty);return p.add(e),{...l,dirty:p}}),w=(e,l,p)=>{r(b=>({...b,[e]:l})),p&&$(p)},Ce=e=>{r(l=>({...l,table:e,queryId:null})),$("target"),L(void 0),E(null)},$e=async()=>{ee(!0),we(C.relativeUrl);const e=await Ft.predefined(a,fe(a.headers,null));I(e),ee(!1),P("results"),Fe(Pt({snapshot:q,modeId:"predefined-query",url:C.relativeUrl,method:"GET",status:e.status,ms:e.ms,rowCount:Ct(e.body)??0})),r(l=>({...l,dirty:new Set}))},ae=Je([["Query id",a.queryId],["Source row id",a.related?.recordId]],[["Relationship",a.related?.navProperty]]),re=Ke([{when:!a.table,id:"pq-table",title:"Pick a table first.",focusNode:"target"},{when:!a.queryId,id:"pq-query",title:"Pick a saved query or user view.",focusNode:"target"},{when:a.related&&!(a.related.navProperty&&a.related.recordId),id:"pq-related",title:"Pick the relationship and the row whose related records to query.",focusNode:"target"},{when:ae,id:"pq-url-part",title:ae??"",focusNode:"target"}]),Re=et(re),q=d.useMemo(()=>tt(a),[a]);at("predefined-query",q,M,Q);const Ie=d.useMemo(()=>Z(q),[q]),se=Q===null?!0:Ie!==Q,Me=e=>{L(e.id),E(Z(e.state))},ne=e=>{if(e.modeId!=="predefined-query")return;const l=e.state;if(x.length>0&&!x.some(p=>p.logicalName===l.table)){qt(`Can't load "${e.name}": entity \`${l.table}\` isn't available in this environment. The solution may have been removed or you may be connected to a different org.`);return}r(ge(l)),L(e.id),E(Z(l)),I(null),g("target")},Le=e=>{const l=$t(e,"predefined-query");if(!l)return;const p=M,b=Q;ne(l),L(p),E(b)},ie=de(Me),le=de(ne);rt(d.useMemo(()=>a.table?{state:q,modeId:"predefined-query",dirty:se,lastSavedId:M,onSaved:ie,onLoadSaved:le}:null,[q,se,M,a.table,ie,le]));const Qe=[{id:"target",label:"Target",meta:G?.displayName,items:[{id:"target",icon:nt,iconFilled:st,label:o?.name??(a.table?"Pick a query":"Pick a table"),badge:o?.kind==="savedQuery"?"system":o?.kind==="userQuery"?"user":null,badgeAppearance:"ghost",dirty:a.dirty.has("target")}]},{id:"conditions",label:"Conditions",items:[{id:"conditions",icon:it,iconFilled:ue,label:"Filter (read-only)",badge:o?"inherited":null,badgeAppearance:"ghost"}]},{id:"top",label:"Top",items:[{id:"top",icon:ot,iconFilled:lt,label:"$top",code:!0,badge:a.top?a.top.toString():"default",badgeAppearance:"ghost",dirty:a.dirty.has("top")}]},{id:"prefer",label:"Prefer",items:[{id:"prefer",icon:ut,iconFilled:dt,label:"Prefer header",badge:ce(a.prefer)?"on":null,badgeAppearance:"ghost",dirty:a.dirty.has("prefer")}]},{id:"headers",label:"Headers",meta:`${a.headers.filter(e=>e.enabled).length} active`,items:[{id:"headers",icon:pt,iconFilled:ct,label:"HTTP headers",badge:a.headers.filter(e=>e.enabled).length||null,dirty:a.dirty.has("headers")}]}];let F;switch(v){case"target":F=t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsx(gt,{table:a.table,onTableChange:e=>{Ce(e),a.related&&w("related",ve)},group:"read",sub:"Pick the table whose saved queries (system views) or user queries (personal views) you want to execute."}),a.table&&t.jsxs("div",{style:{maxWidth:640,display:"flex",flexDirection:"column",gap:14},children:[t.jsx(U,{label:"Run against",hint:a.related?"The query runs over one row’s related records: /<set>(<id>)/<nav>?savedQuery=…":"The query runs over the whole table: /<set>?savedQuery=…",children:t.jsxs(bt,{ariaLabel:"Run the query against",children:[t.jsx(ye,{checked:!a.related,onClick:()=>{a.related&&w("related",null,"target")},children:"Table"}),t.jsx(ye,{checked:!!a.related,onClick:()=>{a.related||w("related",ve,"target")},children:"Related records of a row"})]})}),a.related&&G&&t.jsx(Et,{table:G,value:a.related,onChange:e=>w("related",e,"target")}),t.jsx(U,{label:"View",hint:T.length>0?`${z.length} system · ${O.length} personal`:void 0,children:t.jsxs(xt,{freeform:!0,clearable:!0,value:N,selectedOptions:a.queryId?[a.queryId]:[],placeholder:X?"Loading queries…":T.length===0?"No queries on this table":"Search views by name…",disabled:X,onChange:e=>{const l=e.target.value;D(l),l===""&&a.queryId&&(r(p=>({...p,queryId:null})),$("target"))},onOptionSelect:(e,l)=>{if(!l.optionValue){r(b=>({...b,queryId:null})),D(""),$("target");return}const p=T.find(b=>b.id===l.optionValue);p&&(r(b=>({...b,queryId:p.id,queryType:p.kind})),D(p.name),$("target"))},listbox:{style:{maxHeight:420}},children:[B.length===0&&H.length===0&&N.trim()&&t.jsx(W,{value:"__none",text:"",disabled:!0,children:t.jsxs(f,{style:{color:c.colorNeutralForeground3},children:['No views match "',N.trim(),'"']})}),B.length>0&&t.jsx(be,{label:`System views (${B.length})`,children:B.map(e=>t.jsx(W,{value:e.id,text:e.name,children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1,minWidth:0},children:[t.jsx(J,{style:{fontWeight:e.isDefault?600:400},children:e.name}),e.description&&t.jsx(f,{style:{color:c.colorNeutralForeground3},children:e.description})]})},e.id))}),H.length>0&&t.jsx(be,{label:`Personal views (${H.length})`,children:H.map(e=>t.jsx(W,{value:e.id,text:e.name,children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:1,minWidth:0},children:[t.jsx(J,{children:e.name}),e.description&&t.jsx(f,{style:{color:c.colorNeutralForeground3},children:e.description})]})},e.id))})]})}),X&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:c.colorNeutralForeground3},children:[t.jsx(Se,{size:"tiny"}),t.jsx(f,{children:"Fetching saved + user queries…"})]}),te&&t.jsx(pe,{intent:"error",layout:"multiline",children:t.jsxs(me,{children:[t.jsx(he,{children:"Couldn't load queries"}),te]})}),o&&t.jsxs("div",{className:jt(h.inlineCard),style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx(J,{style:{fontWeight:600},children:o.name}),t.jsx(R,{appearance:"ghost",size:"small",children:Dt(o.queryType)}),o.isDefault&&t.jsx(R,{appearance:"tint",color:"brand",size:"small",children:"default view"}),o.isQuickFind&&t.jsx(R,{appearance:"tint",color:"informative",size:"small",children:"quick find"}),o.kind==="savedQuery"&&o.isManaged&&t.jsx(R,{appearance:"ghost",size:"small",children:"managed"}),o.kind==="savedQuery"&&!o.isManaged&&t.jsx(R,{appearance:"ghost",size:"small",children:"unmanaged"})]}),t.jsxs("div",{children:[t.jsx(f,{style:{fontWeight:600,color:c.colorNeutralForeground2},children:"Query GUID"}),t.jsx("div",{children:t.jsx("code",{style:{fontFamily:c.fontFamilyMonospace,fontSize:11,color:c.colorNeutralForeground2},children:o.id})})]}),o.layoutColumns.length>0&&t.jsxs("div",{children:[t.jsxs(f,{style:{fontWeight:600,color:c.colorNeutralForeground2},children:["Result columns (",o.layoutColumns.length,") — from layoutxml"]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:o.layoutColumns.map(e=>t.jsx(vt,{relationship:"description",content:e.isLink?`${e.fullName} — joined column via link alias \`${e.linkAlias}\` · width ${e.width}px`:`${e.fullName} — width ${e.width}px`,children:t.jsx("span",{style:{fontFamily:c.fontFamilyMonospace,fontSize:11,padding:"2px 6px",borderRadius:4,background:e.isLink?c.colorPaletteBlueBackground2:c.colorNeutralBackground3,color:e.isLink?c.colorPaletteBlueForeground2:c.colorNeutralForeground1,cursor:"help"},children:e.isLink?`${e.linkAlias}.${e.attr}`:e.attr})},e.fullName))}),o.layoutColumns.some(e=>e.isLink)&&t.jsx(f,{style:{display:"block",marginTop:6,color:c.colorNeutralForeground3},children:"Blue pills are joined columns (link-entity in FetchXml)."})]})]})]})]});break;case"conditions":F=t.jsxs("div",{children:[t.jsx(ft,{icon:ue,title:"Conditions",sub:"Read-only summary — predefined queries embed their own FetchXml. Edit the saved query in the model-driven app to change conditions."}),t.jsx(pe,{layout:"multiline",intent:"warning",style:{marginBottom:12},children:t.jsxs(me,{children:[t.jsx(he,{children:"$select / $filter / $orderby / $expand are locked"}),"With ",t.jsx("code",{children:"?savedQuery=…"})," / ",t.jsx("code",{children:"?userQuery=…"}),", the FetchXml in the query owns column projection, filter, sort and joins. Only ",t.jsx("code",{children:"$top"})," and"," ",t.jsx("code",{children:"Prefer"})," headers remain editable."]})}),o?.fetchXml?t.jsx("div",{style:{border:`1px solid ${c.colorNeutralStroke2}`,borderRadius:c.borderRadiusMedium,overflow:"hidden",height:480},children:t.jsx(Mt,{height:"100%",language:"xml",value:o.fetchXml,theme:u==="dark"?"vs-dark":"light",options:{readOnly:!0,domReadOnly:!0,lineNumbers:"on",renderLineHighlight:"line",minimap:{enabled:!1},scrollBeyondLastLine:!1,fontFamily:"Cascadia Mono, Consolas, monospace",fontSize:13,tabSize:2,wordWrap:"on",automaticLayout:!0,padding:{top:12,bottom:12},bracketPairColorization:{enabled:!0},guides:{bracketPairs:!0,indentation:!0},smoothScrolling:!0}})}):o?t.jsx(f,{style:{color:c.colorNeutralForeground3},children:"(No FetchXml available for this query — it may be a layout-only definition.)"}):t.jsx(f,{style:{color:c.colorNeutralForeground3},children:"Pick a query in Target to see its FetchXml."})]});break;case"top":F=t.jsx(yt,{top:a.top,setTop:e=>w("top",e,"top"),maxPageSize:a.prefer.maxpagesize});break;case"prefer":F=t.jsx(ht,{spec:a.prefer,setSpec:e=>w("prefer",e,"prefer"),sendsPageSize:!0});break;case"headers":F=t.jsx(mt,{policy:"read",items:a.headers,setItems:e=>w("headers",e,"headers")});break}const Ee=fe(a.headers,ce(a.prefer)),Ae={method:"GET",built:C,headers:Ee};return t.jsx(St,{sidebar:t.jsx(Tt,{type:n,urlPreview:C.relativeNoBase,sections:Qe,activeNode:v,onSelect:e=>{g(e),P("builder")},recents:qe,onRecentClick:Le}),urlBar:t.jsx(wt,{method:"GET",url:C.relativeUrl,executeVerb:n.executeVerb,disabledReason:Re,loading:Te,onExecute:$e,advisories:re,onAdvisoryFocus:e=>g(e)}),children:t.jsxs(kt,{tab:i,onTabChange:P,resultCount:k?.body?.value?.length??null,children:[i==="builder"&&F,i==="code"&&t.jsx(Lt,{themeMode:u,inputs:Ae}),i==="results"&&t.jsx(Nt,{result:k,mode:"multi",table:a.table,requestUrl:Ne,preferredColumnOrder:o?.layoutColumns.map(e=>e.fullName)})]})})}export{Wt as PredefinedQueryMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as Y,y as Z,r as i,U as J,u as K,aY as Q,aZ as X,a_ as T,aS as ee,a$ as te,b0 as se,a7 as ae,a8 as re,b1 as w,j as e,a9 as ne,b2 as ie,ay as le,M as C,m as U,o as P,aW as k,s as j,b3 as oe,b4 as de,au as ue,T as ce,t as l,C as he,aq as pe,ad as N,ae as me,af as xe,ag as be,b5 as F,ah as ge,ai as ye,b6 as fe,e as ke,b7 as je,b8 as M,b9 as ve,ax as Re,ba as Se}from"./index-NW0Z4UWR.js";import{C as Le}from"./CodeView-C65Y5vXN.js";import{d as Te}from"./decodeForDisplay-D55DM53E.js";import"./multipart-Bd_eOd8a.js";const we=()=>({url:"",prefer:ke(),headers:fe(),dirty:new Set});function Ce(b,u){const d={ok:!1,url:null,host:"",path:"",entitySet:null,skiptoken:null,params:[],errors:[]};if(!b.trim())return d;let t;try{t=new URL(b)}catch{return{...d,errors:["Not a valid URL — paste the full https://… string."]}}const n=[];t.protocol!=="https:"&&n.push("Must be https:// — Dataverse rejects plain HTTP.");const c=t.pathname.match(/^\/api\/data\/v\d+\.\d+\/([^/?]+)/);c||n.push("Path doesn't look like a Dataverse Web API URL (expected /api/data/v<x>.<x>/<entityset>)."),u&&t.host&&t.host.toLowerCase()!==u.toLowerCase()&&n.push(`URL host (${t.host}) doesn't match the connected environment (${u}). Switch connections or paste a URL from the current org.`);const x=[];t.searchParams.forEach((p,g)=>x.push({key:g,value:p}));const h=t.searchParams.get("$skiptoken");return{ok:n.length===0,url:t,host:t.host,path:t.pathname,entitySet:c?c[1]:null,skiptoken:h,params:x,errors:n}}function Me({themeMode:b}){const u=Y("retrieve-nextlink"),d=Z(),[t,n]=i.useState(we),[c,x]=i.useState("url"),[h,p]=i.useState("builder"),[g,B]=i.useState(null),[v,E]=i.useState(void 0),[$,R]=i.useState(!1),[z,H]=J("retrieve-nextlink"),{allEntities:S}=K(),f=i.useMemo(()=>Q(t,s=>S.find(a=>a.entitySetName===s)?.logicalName),[t,S]),r=i.useMemo(()=>Ce(t.url,d.host),[t.url,d.host]),L=X({value:t.url,onChange:s=>m("url",s,"url"),mode:"url",multiline:!0}),q=s=>n(a=>{const o=new Set(a.dirty);return o.add(s),{...a,dirty:o}}),m=(s,a,o)=>{n(_=>({..._,[s]:a})),o&&q(o)},D=i.useMemo(()=>r.errors.map((s,a)=>({id:`nl-err-${a}`,severity:"error",source:"validation",focusNode:"url",title:"Invalid next-link URL",body:s})),[r]),A=async()=>{if(!r.ok)return;R(!0),E(t.url.trim());const s=await ve.nextLink(t,N(t.headers,null));B(s),R(!1),p("results"),H(Re({modeId:"retrieve-nextlink",url:t.url,method:"GET",status:s.status,ms:s.ms,rowCount:Se(s.body)??0})),n(a=>({...a,dirty:new Set}))},G=t.url.trim()?r.ok?null:r.errors[0]??"URL is not safe to follow.":"Paste an @odata.nextLink URL first.",I=async()=>{const s=await je();s?.trim()?m("url",s.trim(),"url"):s===null?M("The clipboard couldn't be read here. Click in the URL box and press Ctrl+V.",{title:"Couldn't paste",intent:"warning"}):M("The clipboard has no text to paste.",{title:"Nothing to paste",intent:"info"})},V=[{id:"url",label:"Target",meta:"Server-issued",items:[{id:"url",icon:ee,iconFilled:T,label:"@odata.nextLink",badge:r.entitySet??(t.url?"invalid":"empty"),badgeAppearance:"ghost",badgeColor:r.errors.length?"danger":r.entitySet?"informative":"subtle",dirty:t.dirty.has("url")}]},{id:"prefer",label:"Prefer",items:[{id:"prefer",icon:se,iconFilled:te,label:"Prefer header",badge:w(t.prefer)?"on":null,badgeAppearance:"ghost",dirty:t.dirty.has("prefer")}]},{id:"headers",label:"Headers",meta:`${t.headers.filter(s=>s.enabled).length} active`,items:[{id:"headers",icon:re,iconFilled:ae,label:"HTTP headers",badge:t.headers.filter(s=>s.enabled).length||null,dirty:t.dirty.has("headers")}]}];let y;switch(c){case"url":y=e.jsxs("div",{children:[e.jsx(le,{icon:T,title:"Next-link URL",sub:"Paste the @odata.nextLink returned by the previous page. The URL is opaque — clauses are not editable here."}),e.jsx(C,{layout:"multiline",intent:"info",style:{marginBottom:12},children:e.jsxs(U,{children:[e.jsx(P,{children:"Why no clause editor?"}),"The next page must use the ",e.jsx("strong",{children:"same shape"})," as the original query. Dataverse encodes paging state in a ",e.jsx("code",{children:"$skiptoken"})," cookie — editing any other clause invalidates the cursor."]})}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:8},children:[e.jsx(k,{content:"Paste from clipboard",relationship:"description",children:e.jsx(j,{icon:e.jsx(oe,{}),appearance:"outline",size:"small",onClick:I,children:"Paste"})}),e.jsx(k,{content:"Clear the URL field",relationship:"description",children:e.jsx(j,{icon:e.jsx(de,{}),appearance:"subtle",size:"small",disabled:!t.url,onClick:()=>m("url","","url"),children:"Clear"})})]}),e.jsx(ue,{label:"@odata.nextLink",hint:"The full URL including https://. Skiptoken cookies are URL-encoded inside.",children:e.jsx(ce,{rows:6,value:t.url,...L.fieldProps,placeholder:`https://${d.host}${d.apiBase}/<entityset>?$select=…&$skiptoken=…`,style:{fontFamily:l.fontFamilyMonospace,fontSize:11}})}),L.list,r.errors.map((s,a)=>e.jsx(C,{intent:"error",layout:"multiline",style:{marginTop:12},children:e.jsxs(U,{children:[e.jsx(P,{children:"Can't follow this URL"}),s]})},a)),r.url&&r.ok&&e.jsxs("div",{style:{marginTop:16,padding:12,border:`1px solid ${l.colorNeutralStroke2}`,borderRadius:l.borderRadiusMedium,background:l.colorNeutralBackground1},children:[e.jsx(he,{style:{display:"block",fontWeight:600,marginBottom:8,color:l.colorNeutralForeground2},children:"Parsed (read-only)"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr",rowGap:4,columnGap:12,fontFamily:l.fontFamilyMonospace,fontSize:11},children:[e.jsx("span",{style:{color:l.colorNeutralForeground3},children:"host"}),e.jsx("span",{children:r.host}),e.jsx("span",{style:{color:l.colorNeutralForeground3},children:"entityset"}),e.jsx("span",{children:r.entitySet??"—"}),r.params.map((s,a)=>e.jsxs("span",{style:{display:"contents"},children:[e.jsx("span",{style:{color:l.colorBrandForeground1},children:s.key}),e.jsx("span",{style:{wordBreak:"break-all"},children:Te(s.value)})]},a))]})]}),r.ok&&e.jsx("div",{style:{marginTop:16},children:e.jsx(k,{content:"Open the parsed URL in a new tab (auth will be required)",relationship:"description",children:e.jsx(j,{icon:e.jsx(pe,{}),appearance:"outline",onClick:()=>window.open(t.url,"_blank","noopener"),children:"Open in new tab"})})})]});break;case"prefer":y=e.jsx(ie,{spec:t.prefer,setSpec:s=>m("prefer",s,"prefer"),sendsPageSize:!0});break;case"headers":y=e.jsx(ne,{policy:"read",items:t.headers,setItems:s=>m("headers",s,"headers")});break}const O=N(t.headers,w(t.prefer)),W={method:"GET",built:f,headers:O,isNextLink:!0,rawNextLink:t.url};return e.jsx(me,{sidebar:e.jsx(ye,{type:u,urlPreview:f.relativeNoBase,sections:V,activeNode:c,onSelect:s=>{x(s),p("builder")},recents:z}),urlBar:e.jsx(ge,{method:"GET",url:f.relativeUrl,executeVerb:u.executeVerb,disabledReason:G,loading:$,onExecute:A,advisories:D,onAdvisoryFocus:s=>x(s)}),children:e.jsxs(xe,{tab:h,onTabChange:p,resultCount:g?.body?.value?.length??null,children:[h==="builder"&&y,h==="code"&&e.jsx(Le,{themeMode:b,inputs:W}),h==="results"&&e.jsx(be,{result:g,mode:"next",requestUrl:v||void 0,onUseEntitySet:(s,a)=>{const o=F(t.url,s,a);m("url",o!==t.url?o:F(v??"",s,a),"url"),p("builder")}})]})})}export{Me as RetrieveNextLinkMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as Ie,bh as Te,r,R as Fe,cJ as ke,u as Ee,U as $e,cK as Ne,z as w,cL as Pe,bl as Me,Y as C,Z as _,cM as je,_ as Le,cN as we,cO as Ce,$ as Ue,a0 as He,cP as X,cQ as ee,bB as te,bP as ae,a$ as Ae,b0 as De,a7 as Ge,a8 as Be,b1 as re,j as n,cR as Ve,a9 as ze,b2 as qe,cS as We,ab as Ke,ad as se,ae as Oe,af as Je,ag as Qe,ah as Ye,ai as Ze,cT as ne,b8 as _e,bR as Xe,b6 as et,e as tt,b9 as at,ax as rt,V as st,a1 as nt,a2 as dt,cU as lt,cV as ot,bo as it,bp as ct,b$ as ut,t as bt,bx as gt,cW as pt}from"./index-NW0Z4UWR.js";import{C as ht}from"./CodeView-C65Y5vXN.js";import"./multipart-Bd_eOd8a.js";const U=()=>({table:"",recordId:null,select:[],expand:[],prefer:{...tt(),formattedValues:!0},headers:et(),dirty:new Set}),E=Xe;function yt({themeMode:de}){const H=Ie("retrieve-single"),$=Te("retrieve-single",ne,U),[e,l]=r.useState($.state),{table:N}=Fe(e.table||null),h=ke(e.table||null,{expand:e.expand}),{allEntities:A}=Ee(),[x,c]=r.useState("target"),[R,I]=r.useState("builder"),[D,f]=r.useState(null),[le,oe]=r.useState(void 0),[P,G]=r.useState(!1),[ie,ce]=$e("retrieve-single"),[T,v]=r.useState($.lastSavedId),[F,m]=r.useState($.lastSavedHash),y=r.useMemo(()=>Ne(e),[e,N,h.version]),o=w(e.table),u=r.useMemo(()=>Pe(e),[e]);Me("retrieve-single",u,T,F);const ue=r.useMemo(()=>C(u),[u]),B=F===null?!0:ue!==F,be=t=>l(a=>{const d=new Set(a.dirty);return d.add(t),{...a,dirty:d}}),S=(t,a,d)=>{l(g=>({...g,[t]:a})),d&&be(d)},ge=t=>{v(t.id),m(C(t.state))},V=t=>{if(t.modeId!=="retrieve-single")return;const a=t.state;if(A.length>0&&!A.some(s=>s.logicalName===a.table)){_e(`Can't load "${t.name}": entity \`${a.table}\` isn't available in this environment. The solution may have been removed or you may be connected to a different org.`);return}l(ne(a)),v(t.id),m(C(a)),f(null),c("target")},pe=t=>{const a=gt(t,"retrieve-single");if(!a)return;const d=T,g=F;V(a),v(d),m(g)},z=_(ge);je("retrieve-single",t=>{t.modeId==="retrieve-single"&&(l(pt(U(),t)),f(null),I("builder"),c("target"))});const q=_(V);Le(r.useMemo(()=>e.table?{state:u,modeId:"retrieve-single",dirty:B,lastSavedId:T,onSaved:z,onLoadSaved:q}:null,[u,B,T,e.table,z,q]));const he=h.pending.join(","),fe=h.failed.join(","),ve=r.useMemo(()=>{const t=[];return e.table&&!e.recordId&&t.push({id:"rs-no-record",severity:"error",source:"validation",focusNode:"target",title:"No record selected",body:`Pick a ${o?.displayName??"record"} or paste a GUID before executing.`}),e.recordId&&!E(e.recordId)&&t.push({id:"rs-bad-guid",severity:"error",source:"validation",focusNode:"target",title:"Invalid record id",body:`"${e.recordId}" doesn't look like a GUID. Dataverse record ids are 36-char UUIDs (with or without braces).`}),t.push(...we(h.pending,h.failed)),t},[e.table,e.recordId,o?.displayName,he,fe]),W=async()=>{G(!0),oe(y.relativeUrl);const t=await at.retrieveSingle(e,se(e.headers,null));f(t),G(!1),I("results"),ce(rt({snapshot:u,modeId:"retrieve-single",url:y.relativeUrl,method:"GET",status:t.status,ms:t.ms,rowCount:t.outcome==="ok"?1:0})),l(a=>({...a,dirty:new Set}))},M=e.table?e.recordId?E(e.recordId)?e.headers.some(t=>t.enabled&&!t.name)?"Fix empty header name.":null:"Record id is not a valid GUID.":"Pick a record first.":"Pick a table first.",[K,O]=r.useState(!1);r.useEffect(()=>{const t=Ce("retrieve-single");t&&(l({...U(),table:t.table,recordId:t.recordId}),v(void 0),m(null),f(null),c("target"),O(!!t.autoExecute))},[]),r.useEffect(()=>{!K||P||!N||!o?.entitySetName||M||(O(!1),W())},[K,N,o?.entitySetName,M,P]);function J(t,a,d){const g=w(d);return t.map(s=>{const k=g?.navigationProperties.find(Re=>Re.name===s.nav),j=k?w(k.targetEntity):void 0,L=k?.cardinality,Y=L==="OneToMany"||L==="ManyToMany",Z=L==="ManyToMany",i=`${a}/${s.id}`,xe=s.filter?st(s.filter):0,p=[];return p.push({id:`${i}/select`,icon:ee,iconFilled:X,label:"$select",code:!0,badge:s.select.length||null}),p.push({id:`${i}/filter`,icon:dt,iconFilled:nt,label:"$filter",code:!0,badge:xe||null}),Y&&(p.push({id:`${i}/orderby`,icon:ot,iconFilled:lt,label:"$orderby",code:!0,badge:s.orderby.length||null}),p.push({id:`${i}/top`,icon:ct,iconFilled:it,label:"$top",code:!0,badge:s.top?s.top.toString():null,badgeAppearance:"ghost"})),Z||p.push({id:`${i}/expand`,icon:ae,iconFilled:te,label:"$expand",code:!0,badge:s.nestedExpand?.length||null,children:j&&s.nestedExpand?.length?J(s.nestedExpand,`${i}/expand`,j.logicalName):void 0}),{id:i,icon:ut,label:n.jsxs("span",{children:[s.nav," ",n.jsxs("span",{style:{color:bt.colorNeutralForeground3,fontWeight:400},children:["→ ",j?.displayName??k?.targetEntity??"?"]})]}),badge:Z?"N:N":Y?"many":"one",badgeAppearance:"ghost",children:p}})}const Q=J(e.expand,"expand",e.table),me=[{id:"target",label:"Target",meta:o?`${o.displayName} record`:"Pick a table",items:[{id:"target",icon:He,iconFilled:Ue,label:e.recordId?`${o?.displayName??""} (selected)`:"Pick a record",badge:e.recordId?E(e.recordId)?"✓":"⚠":null,badgeAppearance:"ghost",badgeColor:e.recordId&&!E(e.recordId)?"danger":void 0,dirty:e.dirty.has("target")}]},{id:"anatomy",label:"Request anatomy",items:[{id:"select",icon:ee,iconFilled:X,label:"$select",code:!0,badge:e.select.length||null,dirty:e.dirty.has("select")},{id:"expand",icon:ae,iconFilled:te,label:"$expand",code:!0,badge:e.expand.length||null,dirty:e.dirty.has("expand"),children:Q.length?Q:void 0}]},{id:"prefer",label:"Prefer",items:[{id:"prefer",icon:De,iconFilled:Ae,label:"Prefer header",badge:re(e.prefer)?"on":null,badgeAppearance:"ghost",dirty:e.dirty.has("prefer")}]},{id:"headers",label:"Headers",meta:`${e.headers.filter(t=>t.enabled).length} active`,items:[{id:"headers",icon:Be,iconFilled:Ge,label:"HTTP headers",badge:e.headers.filter(t=>t.enabled).length||null,dirty:e.dirty.has("headers")}]}];let b;if(x.startsWith("expand"))b=n.jsx(Ve,{path:x,rootEntity:e.table,rootExpand:e.expand,setRootExpand:t=>S("expand",t,"expand"),setActivePath:c});else switch(x){case"target":b=n.jsx(Ke,{table:e.table,onTableChange:a=>{l(d=>({...d,table:a,recordId:null,select:[],expand:[],dirty:new Set(["target"])})),f(null),v(void 0),m(null)},recordId:e.recordId,onRecordChange:a=>S("recordId",a,"target"),sub:"Single-record fetch — pick the entity set and the record GUID.",onResetRequest:()=>{l(a=>({...a,select:[],expand:[],dirty:new Set(["select","expand"])}))}});break;case"select":b=n.jsx(We,{table:e.table,selectedIds:e.select,setSelectedIds:a=>S("select",a,"select")});break;case"prefer":b=n.jsx(qe,{spec:e.prefer,setSpec:a=>S("prefer",a,"prefer")});break;case"headers":b=n.jsx(ze,{policy:"read",items:e.headers,setItems:a=>S("headers",a,"headers")});break}const ye=se(e.headers,re(e.prefer)),Se={method:"GET",built:y,headers:ye};return n.jsx(Oe,{sidebar:n.jsx(Ze,{type:H,urlPreview:y.relativeNoBase,sections:me,activeNode:x,onSelect:t=>{c(t),I("builder")},recents:ie,onRecentClick:pe}),urlBar:n.jsx(Ye,{method:"GET",url:y.relativeUrl,executeVerb:H.executeVerb,disabledReason:M,loading:P,onExecute:W,advisories:ve,onAdvisoryFocus:t=>c(t)}),children:n.jsxs(Je,{tab:R,onTabChange:I,resultCount:D?.outcome==="ok"?1:null,children:[R==="builder"&&b,R==="code"&&n.jsx(ht,{themeMode:de,inputs:Se}),R==="results"&&n.jsx(Qe,{result:D,mode:"single",table:e.table,requestUrl:le})]})})}export{yt as RetrieveSingleMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as _,r as i,bz as Xe,j as t,M as R,m as I,ay as G,bB as ne,S as Ze,C as O,t as l,o as Se,aW as Ie,s as ae,bD as Qe,bE as et,B as tt,aF as J,bA as rt,a_ as nt,bH as ot,bG as at,bI as st,f as lt,bh as it,R as dt,u as ct,U as ut,d1 as pt,d2 as ht,d3 as ft,d4 as mt,bl as gt,Y as te,Z as we,cM as yt,_ as bt,cZ as xt,d5 as Te,aH as jt,aI as St,X as wt,$ as Tt,a0 as kt,cn as Ae,co as vt,aJ as Ue,aK as Ft,bP as Pt,d6 as Ct,d7 as Nt,a$ as Bt,b0 as Rt,cP as It,cQ as At,a7 as Ut,a8 as Lt,aP as ke,b1 as ve,a9 as Mt,cS as Ht,b2 as Dt,d8 as Vt,ab as $t,ad as Fe,ae as Ot,af as Et,ag as zt,ah as Wt,ai as qt,d9 as Pe,bR as Gt,b8 as _t,I as Jt,bb as Kt,da as Yt,au as Xt,bt as Zt,bd as Ce,b9 as Qt,ax as er,bx as tr,aj as rr,e as nr,cz as or,db as ar}from"./index-NW0Z4UWR.js";import{F as Le}from"./FieldSetEditor-Dg6WsDgG.js";import{d as sr,s as lr,B as ir}from"./bypassAdvisories-BhBeq_oI.js";import{C as dr}from"./CodeView-C65Y5vXN.js";import{d as cr}from"./writeState-DgYICTBE.js";import"./multipart-Bd_eOd8a.js";const ur=new Set(["createdon","modifiedon","createdby","modifiedby","createdonbehalfby","modifiedonbehalfby","versionnumber","importsequencenumber","overriddencreatedon","utcconversiontimezonecode","timezoneruleversionnumber"]);function pr({table:o,recordId:n,fieldValues:a,original:e,originalLoading:d,onDrillColumn:u,sourceNote:m}){const g=_(o),[h,S]=i.useState(!1),j=i.useMemo(()=>{if(!g||!e)return[];const f=[];for(const w of g.columns){if(ur.has(w.logicalName)||w.attributeType==="File"||w.attributeType==="Image")continue;const s=Xe(e,w),y=w.logicalName in a,E=a[w.logicalName],A=y?oe(w,E):s,U=y&&!mr(w,s,E);f.push({col:w,before:s,after:A,changed:U})}return f},[g,e,a]),b=j.filter(f=>f.changed).length,F=j.length-b,P=h?j:j.filter(f=>f.changed);if(!g)return t.jsx(R,{layout:"multiline",intent:"error",children:t.jsxs(I,{children:["Unknown table ",t.jsx("code",{children:o}),"."]})});if(!e)return t.jsxs("div",{children:[t.jsx(G,{icon:ne,title:"Diff",sub:"Pick a record to compare against.",group:"write"}),n?d?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 0"},children:[t.jsx(Ze,{size:"small"}),t.jsx(O,{style:{color:l.colorNeutralForeground3},children:"Loading the current record from Dataverse — this anchors the “before” column of the diff."})]}):t.jsx(R,{layout:"multiline",intent:"warning",style:{maxWidth:720},children:t.jsxs(I,{children:[t.jsx(Se,{children:"Couldn't load the record."}),"GUID ",t.jsx("code",{children:n})," didn't resolve in ",t.jsx("code",{children:o}),". The record may have been deleted, or you might not have read access. You can still author the PATCH — the diff just won't show a “before” column."]})}):t.jsx(R,{layout:"multiline",intent:"info",style:{maxWidth:720},children:t.jsxs(I,{children:["No record selected — switch to the ",t.jsx("strong",{children:"Target"})," pane and pick one. The diff compares your edits against the record's current persisted state."]})})]});const H=String(e[g.primaryName]??"");return t.jsxs("div",{children:[t.jsxs(G,{icon:ne,title:H||"(unnamed record)",sub:b>0?t.jsxs(t.Fragment,{children:[b," field",b===1?"":"s"," changed · ",F," ","unchanged"]}):t.jsxs(t.Fragment,{children:["No changes yet — edit fields in the ",t.jsx("strong",{children:"Field set"})," pane to populate the diff."]}),group:"write",children:[t.jsx(Ie,{content:h?"Hiding unchanged rows":"Showing unchanged rows",relationship:"description",children:t.jsx(ae,{size:"small",appearance:h?"primary":"outline",icon:h?t.jsx(Qe,{}):t.jsx(et,{}),onClick:()=>S(f=>!f),children:h?"All fields":"Changes only"})}),t.jsxs(tt,{appearance:"tint",color:b>0?"brand":"subtle",children:[b," change",b===1?"":"s"]})]}),m&&t.jsx(R,{layout:"multiline",intent:m.intent,style:{marginBottom:14,maxWidth:720},children:t.jsx(I,{children:m.text})}),b===0&&!h&&t.jsx(R,{layout:"multiline",intent:"info",style:{marginBottom:14},children:t.jsxs(I,{children:[t.jsx(Se,{children:"No diff to render."}),"PATCH sends only the fields in the body — edit one or more columns in the"," ",t.jsx("strong",{children:"Field set"})," pane to see the before → after diff. You can also drill into any column for a single-property ",t.jsx("code",{children:"PUT"})," instead."]})}),t.jsx("div",{style:{maxWidth:1080,overflowX:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"separate",borderSpacing:0},children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx(V,{style:{width:"22%"},children:"Field"}),t.jsx(V,{tone:"before",children:"Before"}),t.jsx(V,{children:"—"}),t.jsx(V,{tone:"after",children:"After"}),t.jsx(V,{style:{width:88},children:"Drill"})]})}),t.jsxs("tbody",{children:[P.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:5,style:{padding:"24px 8px",textAlign:"center",color:l.colorNeutralForeground3,fontStyle:"italic"},children:h?"No fields on this record (somehow).":'No changes — toggle "All fields" to see the unchanged rows.'})}),P.map(f=>t.jsx(hr,{row:f,onDrill:()=>u(f.col.logicalName)},f.col.logicalName))]})]})})]})}function hr({row:o,onDrill:n}){const{col:a,before:e,after:d,changed:u}=o,m=u?{}:{opacity:.45};return t.jsxs("tr",{style:m,children:[t.jsx($,{children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontFamily:l.fontFamilyMonospace,fontSize:12,color:l.colorNeutralForeground1,fontWeight:500},children:a.logicalName}),t.jsxs(O,{style:{color:l.colorNeutralForeground3,fontSize:10},children:[a.displayName," ·"," ",t.jsx("span",{style:{color:l.colorBrandForeground2},children:a.attributeType})]})]})}),t.jsx($,{tone:"before",children:t.jsx(Ne,{col:a,value:e,faded:!u})}),t.jsx($,{children:t.jsx("span",{style:{color:u?l.colorBrandForeground1:l.colorNeutralForeground3,fontSize:18,fontWeight:700},children:u?"→":"="})}),t.jsx($,{tone:u?"after":void 0,children:t.jsx(Ne,{col:a,value:d,faded:!u,highlight:u})}),t.jsx($,{children:t.jsx(Ie,{content:`Switch to PUT /${a.logicalName}`,relationship:"description",children:t.jsx(ae,{size:"small",appearance:"subtle",icon:t.jsx(nt,{}),onClick:n,"aria-label":`Drill into ${a.logicalName}`,children:"PUT"})})})]})}function V({children:o,style:n,tone:a}){const e=a==="before"?{background:"rgba(125,125,125,.06)"}:a==="after"?{background:"rgba(31,127,56,.08)",color:l.colorPaletteGreenForeground1}:{};return t.jsx("th",{style:{textAlign:"left",padding:"8px 10px",fontSize:11,fontWeight:600,color:l.colorNeutralForeground2,borderBottom:`2px solid ${l.colorNeutralStroke2}`,whiteSpace:"nowrap",...e,...n},children:o})}function $({children:o,tone:n}){const a=n==="before"?{background:"rgba(125,125,125,.025)"}:n==="after"?{background:"rgba(31,127,56,.04)",borderLeft:`2px solid ${l.colorPaletteGreenBorderActive}`}:{};return t.jsx("td",{style:{padding:"8px 10px",verticalAlign:"top",borderBottom:`1px solid ${l.colorNeutralStroke3}`,fontSize:12,...a},children:o})}function Ne({col:o,value:n,faded:a,highlight:e}){return n==null||n===""?t.jsx("span",{style:{color:l.colorNeutralForeground3,fontStyle:"italic",fontSize:11},children:"(empty)"}):t.jsx("span",{style:{fontFamily:o.attributeType==="Uniqueidentifier"||J(o)?l.fontFamilyMonospace:l.fontFamilyBase,fontSize:12,color:e?l.colorPaletteGreenForeground1:l.colorNeutralForeground1,fontWeight:e?600:400,opacity:a&&!e?.7:1,wordBreak:"break-word"},children:fr(o,n)})}function fr(o,n){if(n==null||n==="")return"(empty)";if(o.attributeType==="Boolean")return n===!0||n==="1"||n===1?o.trueOption.label:o.falseOption.label;if(J(o)){if(typeof n=="object"&&n!==null&&"id"in n)return ot(n);if(typeof n=="string")return n}const a=at(o);if(a){const e=Number(n);if(Number.isFinite(e)){const d=a.find(u=>u.value===e);if(d)return`${d.label} · ${e}`}if(o.attributeType==="MultiSelectPicklist"){if(Array.isArray(n))return n.map(d=>a.find(u=>u.value===d)?.label??String(d)).join(", ");if(typeof n=="string")return n.split(",").map(d=>a.find(u=>String(u.value)===d.trim())?.label??d).join(", ")}}if(o.attributeType==="Money"){const e=Number(n);if(Number.isFinite(e))return e.toLocaleString(void 0,{style:"currency",currency:"USD"})}return o.attributeType==="DateTime"&&typeof n=="string"?st(n,o):String(n)}function oe(o,n){if(n==null)return null;if(J(o)){const a=n;return a?.id?a:null}return o.attributeType==="MultiSelectPicklist"&&Array.isArray(n)?n.join(","):n}function mr(o,n,a){if(J(o))return rt(n,oe(o,a));const e=oe(o,a);return n==null&&(e==null||e==="")?!0:e==null?!1:String(n)===String(e)}const Be=()=>({table:"",recordId:null,method:"PATCH",putColumn:null,fieldValues:{},nullFields:[],rawBody:null,prefer:{...nr(),formattedValues:!0,returnRepresentation:!1},headers:rr(),returnSelect:[],concurrency:{kind:"update-only"},bypass:cr(),dirty:new Set}),re=Gt;function Fr({themeMode:o}){const n=lt("update"),a=it("update",Pe,Be),[e,d]=i.useState(a.state),{loading:u,table:m}=dt(e.table||null),{allEntities:g}=ct(),[h,S]=i.useState("target"),[j,b]=i.useState("builder"),[F,P]=i.useState(null),[H,f]=i.useState(!1),[w,s]=i.useState(!1),[y,E]=ut("update"),[A,U]=i.useState(a.lastSavedId),[z,W]=i.useState(a.lastSavedHash),[K,se]=i.useState(null),le=K&&e.recordId&&K.id.toLowerCase()===e.recordId.toLowerCase()?K.name:"",D=i.useMemo(()=>pt(e),[e,m]),Y=i.useMemo(()=>ht(e),[e,m]),x=_(e.table),ie=i.useMemo(()=>{const r=ft(x,e.rawBody,e.fieldValues,e.nullFields);if(!r.fromJson)return{values:r.values,note:null};if(r.error)return{values:r.values,note:{intent:"warning",text:`The JSON body is invalid (${r.error}), so there is nothing to compare.`}};const c=r.unmapped.map(p=>p.key);return{values:r.values,note:{intent:"info",text:"Compared against the typed JSON body."+(c.length>0?` Not shown (no matching column, or a value the diff can't map): ${c.join(", ")}.`:"")}}},[e.rawBody,e.fieldValues,e.nullFields,x,m]),X=r=>d(c=>{const p=new Set(c.dirty);return p.add(r),{...c,dirty:p}}),T=(r,c,p)=>{d(k=>({...k,[r]:c})),p&&X(p)},[C,L]=i.useState(null),[Me,Z]=i.useState(!1),[He,de]=i.useState(null);i.useEffect(()=>{let r=!1;if(de(null),!e.recordId||!e.table||!x){L(null);return}if(!re(e.recordId)){L(null);return}if(typeof window>"u"||!window.dataverseAPI?.queryData){L(null);return}L(null),Z(!0);const c=`/${x.entitySetName}(${e.recordId})`;return window.dataverseAPI.queryData(c).then(p=>{if(r)return;const k=p?.value;let q=null;if(Array.isArray(k))q=k[0]??null;else if(k&&typeof k=="object")q=k;else if(p&&typeof p=="object"){const ee=p;(x.primaryKey in ee||Object.keys(ee).some(Ye=>Ye.startsWith("@odata.")))&&(q=ee)}L(q),Z(!1)}).catch(p=>{if(r)return;const k=p instanceof Error?p.message:String(p);L(null),Z(!1),de(k)}),()=>{r=!0}},[e.recordId,e.table,x]);const Q=i.useMemo(()=>{if(!C)return null;const r=C["@odata.etag"];return typeof r=="string"&&r?r:null},[C]),De=r=>{d(c=>({...c,method:"PUT",putColumn:r})),S("method"),X("method")},ce=()=>{d(r=>({...r,method:"PATCH",putColumn:null})),X("method")},M=i.useMemo(()=>mt(e),[e]);gt("update",M,A,z);const Ve=i.useMemo(()=>te(M),[M]),ue=z===null?!0:Ve!==z,$e=r=>{U(r.id),W(te(r.state))},pe=r=>{if(r.modeId!=="update")return;const c=r.state;if(g.length>0&&!g.some(p=>p.logicalName===c.table)){_t(`Can't load "${r.name}": entity \`${c.table}\` isn't available in this environment. The solution may have been removed or you may be connected to a different org.`);return}d(Pe(c)),U(r.id),W(te(c)),P(null),S("target")},Oe=r=>{const c=tr(r,"update");if(!c)return;const p=A,k=z;pe(c),U(p),W(k)},he=we($e);yt("update",r=>{r.modeId==="update"&&(d(ar(Be(),r)),P(null),b("builder"),S("target"))});const fe=we(pe);bt(i.useMemo(()=>e.table?{state:M,modeId:"update",dirty:ue,lastSavedId:A,onSaved:he,onLoadSaved:fe}:null,[M,ue,A,e.table,he,fe]));const Ee=e.rawBody!=null,ze=e.method==="PATCH"?xt(e.rawBody):null,B=Ee?Object.keys(Y).length:Object.keys(e.fieldValues).length,me=e.method!=="PUT"||e.putColumn!=null&&e.fieldValues[e.putColumn]!=null,We=x?e.recordId?re(e.recordId)?e.method==="PUT"?e.putColumn?me?null:`Set a value for ${e.putColumn}.`:"Pick a column for the PUT.":ze||(B===0?"No field changes — nothing to PATCH. Pick at least one field to update.":Object.keys(Y).length===0?"Body is empty — set at least one value.":null)||(e.concurrency.kind==="etag"&&Te(e.concurrency.etag)?Te(e.concurrency.etag):e.headers.some(r=>r.enabled&&!r.name)?"Fix empty header name.":null):"Record id is not a valid GUID.":"Pick a record to update.":"Pick a target table first.",qe=async()=>{s(!0);const r=await Qt.update(e,Fe(ge,null));P(r),f(e.prefer.returnRepresentation),s(!1),b("results"),E(er({snapshot:M,modeId:"update",url:D.relativeUrl,method:e.method,status:r.status,ms:r.ms,rowCount:r.ok?1:0})),d(c=>({...c,dirty:new Set}))},ge=i.useMemo(()=>jt(e),[e]),ye=i.useMemo(()=>{const r=[...sr(e.bypass,"bypass"),...St({op:"update",concurrency:e.concurrency,bypass:e.bypass})];return e.table&&e.recordId&&!re(e.recordId)&&r.push({id:"upd-bad-guid",severity:"error",source:"validation",focusNode:"target",title:"Invalid record id",body:`"${e.recordId}" isn't a valid GUID. The update will fail at the wire.`}),e.method==="PUT"&&r.push({id:"upd-put-unsupported",severity:"error",source:"validation",focusNode:"method",title:"PUT single-column isn't supported by the PPTB host",body:t.jsxs(t.Fragment,{children:["DRS authors the correct request"," ",t.jsxs("code",{children:["PUT /",x?.entitySetName??"<set>","(<id>)/",e.putColumn??"<column>"]})," ","with body ",t.jsx("code",{children:'{ "value": <scalar> }'}),", but PPTB's"," ",t.jsx("code",{children:"dataverseAPI.update"})," is PATCH-only — there's no raw-request hook for property-path URLs. To set one column from inside PPTB, switch back to"," ",t.jsx("strong",{children:"PATCH"})," with a single field in the body — it's functionally equivalent. To use the PUT pattern, copy the URL + body from the Code tab and run it from Postman / curl / the JS SDK / Power Automate."]})}),r},[e.bypass,e.concurrency,e.table,e.recordId,e.method,e.putColumn,x]),Ge=wt(ye),be=e.prefer.returnRepresentation,N=e.method==="PUT",xe=N?`PUT /${e.putColumn??"?"}`:`PATCH · ${B} field${B===1?"":"s"}`,je=e.concurrency.kind==="update-only"?"* (any)":e.concurrency.kind==="etag"&&Q&&e.concurrency.etag.includes(Q)?"current etag":e.concurrency.kind==="etag"?"custom etag":"none",_e=[{id:"target",label:"Target",meta:x?He?"fetch failed — see Diff":`${x.displayName} record`:"Pick a table",items:[{id:"target",icon:kt,iconFilled:Tt,label:le||(C&&x?String(C[x.primaryName]??""):"")||(e.recordId?"(loading record…)":"Pick a record"),dirty:e.dirty.has("target")}]},{id:"method",label:"Method",meta:xe,items:[{id:"method",icon:vt,iconFilled:Ae,label:N?"PUT — single column":"PATCH — multi-field",badge:xe,badgeAppearance:"ghost",dirty:e.dirty.has("method")}]},{id:"body",label:"Field set",meta:N?"single column":`${B} changed`,items:[{id:"fieldset",icon:Ft,iconFilled:Ue,label:N?`Value (${e.putColumn??"?"})`:"Field set",badge:N?me?"✓":"?":B||null,badgeAppearance:"ghost",dirty:e.dirty.has("fieldset")},...N?[]:[{id:"diff",icon:Pt,iconFilled:ne,label:"Diff",badge:B||null,badgeAppearance:"tint",badgeColor:B>0?"brand":"subtle",dirty:e.dirty.has("diff")}]]},{id:"precondition",label:"Precondition",meta:je,items:[{id:"precondition",icon:Nt,iconFilled:Ct,label:"Optimistic concurrency",badge:je,badgeAppearance:"ghost",dirty:e.dirty.has("precondition")}]},...N?[]:[{id:"prefer",label:"Prefer",meta:be?"return=representation":"204 No Content",items:[{id:"prefer",icon:Rt,iconFilled:Bt,label:"Prefer header",badge:ve(e.prefer)?"on":null,badgeAppearance:"ghost",dirty:e.dirty.has("prefer")},...be?[{id:"returnselect",icon:At,iconFilled:It,label:"$select (response)",code:!0,badge:e.returnSelect.length||null,dirty:e.dirty.has("returnselect")}]:[]]}],{id:"headers",label:"Headers",meta:`${e.headers.filter(r=>r.enabled).length} active`,items:[{id:"headers",icon:Lt,iconFilled:Ut,label:"HTTP headers",badge:e.headers.filter(r=>r.enabled).length||null,dirty:e.dirty.has("headers")},{id:"bypass",icon:ke,iconFilled:ke,label:"Bypass logic",badge:lr(e.bypass),badgeAppearance:e.bypass.businessLogic!=="none"||e.bypass.suppressFlows?"tint":"ghost",badgeColor:e.bypass.businessLogic!=="none"||e.bypass.suppressFlows?"warning":"subtle",dirty:e.dirty.has("bypass")}]}];let v;switch(h){case"target":v=t.jsx($t,{table:e.table,onTableChange:r=>{d(c=>({...c,table:r,recordId:null,fieldValues:{},rawBody:null,method:"PATCH",putColumn:null,returnSelect:[],dirty:new Set(["target","fieldset","method"])})),P(null),se(null),U(void 0),W(null)},recordId:e.recordId,onRecordChange:(r,c)=>{T("recordId",r,"target"),se(r&&c?{id:r,name:c}:null)},group:"write",sub:"Single-record update — pick the entity set and the record GUID."});break;case"method":v=t.jsx(gr,{method:e.method,putColumn:e.putColumn,setMethod:r=>T("method",r,"method"),setPutColumn:r=>T("putColumn",r,"method"),table:e.table,onExitPut:ce});break;case"diff":v=t.jsx(pr,{table:e.table,recordId:e.recordId,fieldValues:ie.values,sourceNote:ie.note,original:C,originalLoading:Me||u,onDrillColumn:De});break;case"fieldset":v=N?t.jsx(yr,{table:e.table,column:e.putColumn,value:e.putColumn?e.fieldValues[e.putColumn]:void 0,onChange:r=>{e.putColumn&&T("fieldValues",{...e.fieldValues,[e.putColumn]:r},"fieldset")},onSwapMethod:ce,themeMode:o}):t.jsx(Le,{table:e.table,values:e.fieldValues,setValues:r=>T("fieldValues",r,"fieldset"),nullFields:e.nullFields,setNullFields:r=>T("nullFields",r,"fieldset"),rawBody:e.rawBody??null,setRawBody:r=>T("rawBody",r,"fieldset"),group:"write",themeMode:o,purpose:"update"});break;case"precondition":v=t.jsx(Vt,{mode:e.concurrency,setMode:r=>T("concurrency",r,"precondition"),available:["none","update-only","etag"],currentEtag:Q,group:"write"});break;case"prefer":v=t.jsx(Dt,{spec:e.prefer,setSpec:r=>T("prefer",r,"prefer"),group:"write"});break;case"returnselect":v=t.jsx(Ht,{table:e.table,selectedIds:e.returnSelect,setSelectedIds:r=>T("returnSelect",r,"returnselect"),group:"write"});break;case"headers":v=t.jsx(Mt,{items:e.headers,setItems:r=>T("headers",r,"headers"),group:"write"});break;case"bypass":v=t.jsx(ir,{value:e.bypass,onChange:r=>T("bypass",r,"bypass"),group:"write"});break}const Je=Fe(ge,ve(e.prefer)),Ke={method:e.method,built:D,headers:Je,body:Y,entityLogical:D.entityLogical};return t.jsx(Ot,{sidebar:t.jsx(qt,{type:n,urlPreview:D.relativeNoBase,sections:_e,activeNode:h,onSelect:r=>{S(r),b("builder")},recents:y,onRecentClick:Oe}),urlBar:t.jsx(Wt,{method:e.method,url:D.relativeUrl,executeVerb:n.executeVerb,writeConfirm:{operation:"Update Record",table:e.table,scope:{kind:"records",count:1},highImpact:!1},disabledReason:We??Ge,loading:w,onExecute:qe,advisories:ye,onAdvisoryFocus:S}),children:t.jsxs(Et,{tab:j,onTabChange:b,resultCount:F?.ok?1:null,children:[j==="builder"&&v,j==="code"&&t.jsx(dr,{themeMode:o,inputs:Ke}),j==="results"&&t.jsx(zt,{result:F,mode:"single",table:e.table,writeContext:{operation:"update",table:e.table,recordId:e.recordId,returnRepresentation:H,recordName:le||(C&&x?String(C[x.primaryName]??""):null)}})]})})}function gr({method:o,putColumn:n,setMethod:a,setPutColumn:e,table:d,onExitPut:u}){const m=_(d),g=Kt(),h=i.useMemo(()=>(m?.columns??[]).filter(s=>(Yt(s,g)||s.logicalName===n)&&s.attributeType!=="Uniqueidentifier"&&s.attributeType!=="File"&&s.attributeType!=="Image"&&s.attributeType!=="Lookup"&&s.attributeType!=="Customer"&&s.attributeType!=="Owner"&&s.isValidForUpdate!==!1).slice().sort((s,y)=>s.displayName.localeCompare(y.displayName)),[m,g,n]),[S,j]=i.useState(""),[b,F]=i.useState(!1);i.useEffect(()=>{n||(j(""),F(!1))},[n]);const H=(n?h.find(s=>s.logicalName===n):void 0)?.displayName??n??"",f=i.useMemo(()=>{if(!S)return h;const s=S.toLowerCase();return h.filter(y=>y.displayName.toLowerCase().includes(s)||y.logicalName.toLowerCase().includes(s)||y.attributeType.toLowerCase().includes(s))},[h,S]),w=b?S:H;return t.jsxs("div",{children:[t.jsx(G,{icon:Ae,title:"Method",sub:"PATCH for multi-field updates, PUT for single-column writes via the property URL.",group:"write"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:12,maxWidth:760},children:[t.jsx(Re,{title:"PATCH — multi-field",description:"Send a JSON body of changed fields. Body shape: { col1: val1, col2: val2, ... }",syntax:"/{entitySet}({id})",selected:o==="PATCH",onClick:()=>{a("PATCH"),u()}}),t.jsx(Re,{title:"PUT — single column",description:'Set ONE column via the property URL. Body: { "value": <scalar> }. Lookups use $ref (Associate) instead.',syntax:"/{entitySet}({id})/{column}",selected:o==="PUT",onClick:()=>a("PUT")})]}),o==="PUT"&&t.jsxs("div",{style:{marginTop:18,maxWidth:480},children:[t.jsx(Xt,{label:"Column to PUT",hint:`${h.length} eligible column${h.length===1?"":"s"}. Type to filter. Lookups aren't supported via this path — use Associate (POST /$ref) instead.`,children:t.jsxs(Zt,{freeform:!0,clearable:!0,value:w,selectedOptions:n?[n]:[],onChange:s=>{const y=s.target.value;j(y),F(!0),!y&&n&&e(null)},onOptionSelect:(s,y)=>{if(!y.optionValue){e(null),j(""),F(!1);return}e(y.optionValue),j(""),F(!1)},placeholder:"Type to search columns…",listbox:{style:{maxHeight:360}},children:[f.length===0&&t.jsx(Ce,{value:"__none",text:"",disabled:!0,children:t.jsxs(O,{style:{color:l.colorNeutralForeground3},children:["No columns match “",S,"”"]})}),f.map(s=>t.jsx(Ce,{value:s.logicalName,text:s.displayName,children:t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{children:s.displayName}),t.jsxs(O,{style:{color:l.colorNeutralForeground3},children:[s.logicalName," ·"," ",t.jsx("span",{style:{color:l.colorBrandForeground2},children:s.attributeType})]})]})},s.logicalName))]})}),t.jsx(R,{layout:"multiline",intent:"info",style:{marginTop:14},children:t.jsxs(I,{children:["In PUT mode, the URL changes to"," ",t.jsxs("code",{style:{fontFamily:l.fontFamilyMonospace},children:["/",m?.entitySetName??"<set>","(<id>)/",n??"<col>"]})," ","and the body is"," ",t.jsx("code",{style:{fontFamily:l.fontFamilyMonospace},children:'{ "value": <scalar> }'}),". Switch to ",t.jsx("strong",{children:"Field set"})," in the sidebar to edit the value."]})})]})]})}function Re({title:o,description:n,syntax:a,selected:e,onClick:d}){return t.jsxs("button",{type:"button",onClick:d,"aria-pressed":e,style:{textAlign:"left",padding:14,cursor:"pointer",background:e?l.colorBrandBackground2:l.colorNeutralBackground1,border:`1px solid ${e?l.colorBrandStroke1:l.colorNeutralStroke2}`,borderRadius:l.borderRadiusMedium,display:"flex",flexDirection:"column",gap:8},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("strong",{style:{fontSize:13},children:o}),e&&t.jsx(or,{style:{marginLeft:"auto",color:l.colorBrandForeground1},"aria-label":"Selected"})]}),t.jsx(O,{style:{color:l.colorNeutralForeground2,lineHeight:1.4},children:n}),t.jsx("code",{style:{marginTop:"auto",fontFamily:l.fontFamilyMonospace,fontSize:10,color:l.colorBrandForeground2,background:l.colorBrandBackground2Hover,padding:"4px 6px",borderRadius:l.borderRadiusSmall,alignSelf:"flex-start"},children:a})]})}function yr({table:o,column:n,value:a,onChange:e,onSwapMethod:d,themeMode:u}){const m=_(o),g=m&&n?Jt(m,n):void 0;return g?t.jsxs("div",{children:[t.jsx(G,{icon:Ue,title:`${g.displayName} → PUT`,sub:t.jsxs("span",{children:["Setting one column via the property URL."," ",t.jsx(ae,{appearance:"transparent",size:"small",onClick:d,style:{padding:"0 2px",minWidth:0,height:"auto",verticalAlign:"baseline"},children:"Switch back to PATCH (multi-field)"})]}),group:"write"}),t.jsx("div",{style:{maxWidth:720},children:t.jsx(Le,{table:o,values:{[g.logicalName]:a??""},setValues:h=>e(h[g.logicalName]??""),group:"write",themeMode:u,purpose:"update",method:"PUT"})})]}):t.jsx(R,{layout:"multiline",intent:"warning",children:t.jsxs(I,{children:["Pick a column on the ",t.jsx("strong",{children:"Method"})," pane first."]})})}export{Fr as UpdateMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as D,j as t,M as J,m as Y,ay as we,au as U,az as Se,aA as Z,C as P,t as y,be as Re,bt as Fe,bd as Ie,I as Ne,dc as Be,av as Te,f as Ce,bh as Ue,r as o,R as Pe,u as Le,U as Ve,dd as Ae,de as De,cY as He,cZ as $e,d5 as Q,aH as Ke,aI as Ee,df as Ge,dg as qe,X as Oe,dh as ze,bl as Me,Y as A,Z as X,cM as We,_ as _e,$ as Je,a0 as Ye,aJ as Ze,aK as Qe,d6 as Xe,d7 as et,a$ as tt,b0 as st,cP as at,cQ as rt,a7 as nt,a8 as lt,aP as ee,b1 as te,a9 as it,cS as ot,b2 as dt,d8 as ct,ab as ut,ad as se,ae as yt,af as pt,ag as ht,ah as bt,ai as mt,di as ae,bR as gt,b8 as ft,b9 as kt,ax as xt,bx as vt,aj as jt,e as wt,dj as St}from"./index-NW0Z4UWR.js";import{K as le,a as Rt,F as Ft}from"./FieldSetEditor-Dg6WsDgG.js";import{d as It,s as Nt,B as Bt}from"./bypassAdvisories-BhBeq_oI.js";import{C as Tt}from"./CodeView-C65Y5vXN.js";import{w as Ct}from"./writeResultName-Dw705_0B.js";import{d as Ut}from"./writeState-DgYICTBE.js";import"./multipart-Bd_eOd8a.js";function Pt({table:x,keyMode:n,setKeyMode:p,group:e="write"}){const c=D(x),h=c?.alternateKeys??[];return c?t.jsxs("div",{children:[t.jsx(we,{icon:le,title:"Upsert key",sub:"Identify the row to upsert — by GUID or by an alternate (business) key configured on the table.",group:e}),t.jsxs("div",{style:{maxWidth:760},children:[t.jsx(U,{label:"Addressing",children:t.jsxs(Se,{value:n.kind,onChange:(l,i)=>{if(i.value==="guid")p({kind:"guid",recordId:n.kind==="guid"?n.recordId:null});else{const b=h[0];if(!b)return;const u=n.kind==="alternate"?n.keyValues:{};p({kind:"alternate",keyName:b.name,keyValues:u})}},children:[t.jsx(Z,{value:"guid",label:t.jsxs("span",{children:[t.jsx("strong",{children:"By GUID"}),t.jsx(P,{style:{display:"block",color:y.colorNeutralForeground3,marginTop:2},children:"Address the record by its primary-key (system) identifier — same as Update."})]})}),t.jsx(Z,{value:"alternate",disabled:h.length===0,label:t.jsxs("span",{children:[t.jsx("strong",{children:"By alternate key"}),h.length===0&&t.jsxs("span",{style:{color:y.colorNeutralForeground3,fontSize:11},children:[" ","· none defined on this table"]}),t.jsxs(P,{style:{display:"block",color:y.colorNeutralForeground3,marginTop:2},children:["Use a business identifier (e.g. account number, email) instead of the GUID. The URL becomes"," ",t.jsxs("code",{style:{fontFamily:y.fontFamilyMonospace},children:["/",c.entitySetName,"(col=value)"]}),"."]})]})})]})}),n.kind==="guid"&&t.jsxs("div",{style:{marginTop:14,maxWidth:480},children:[t.jsx(U,{label:"Record",children:t.jsx(Re,{table:x,selectedId:n.recordId,onPick:l=>p({kind:"guid",recordId:l?.id??null}),placeholder:`Search ${c.displayName} records…`})}),t.jsxs(P,{style:{marginTop:6,color:y.colorNeutralForeground3,display:"block"},children:["Leave empty to address by a future GUID — the URL will read ",t.jsx("code",{children:"(<id>)"})," ","as a placeholder until you pick a row."]})]}),n.kind==="alternate"&&t.jsxs("div",{style:{marginTop:14,display:"flex",flexDirection:"column",gap:14,maxWidth:560},children:[t.jsx(U,{label:"Key definition",children:t.jsx(Fe,{value:h.find(l=>l.name===n.keyName)?.displayName??n.keyName,selectedOptions:[n.keyName],onOptionSelect:(l,i)=>{i.optionValue&&p({kind:"alternate",keyName:i.optionValue,keyValues:{}})},children:h.map(l=>t.jsx(Ie,{value:l.name,text:l.displayName,children:t.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[t.jsx("span",{children:l.displayName}),t.jsxs(P,{style:{color:y.colorNeutralForeground3},children:["cols: ",l.columns.join(", ")]})]})},l.name))})}),(()=>{const l=h.find(i=>i.name===n.keyName);return l?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:l.columns.map(i=>{const b=Ne(c,i),u=Be(c,l,i);return t.jsx(U,{label:b?.displayName??i,hint:t.jsxs("span",{children:[t.jsx("code",{style:{fontFamily:y.fontFamilyMonospace},children:i})," ·"," ",u?t.jsx("span",{style:{color:y.colorBrandForeground2},children:u}):t.jsx("span",{style:{color:y.colorPaletteMarigoldForeground2},children:"type unknown, quoted as string"})]}),children:t.jsx(Te,{size:"small",value:n.keyValues[i]??"",onChange:(j,w)=>p({kind:"alternate",keyName:n.keyName,keyValues:{...n.keyValues,[i]:w.value}}),placeholder:u==="String"?"e.g. ACC-0001":"value",style:{fontFamily:y.fontFamilyMonospace}})},i)})}):null})(),t.jsx(J,{layout:"multiline",intent:"info",children:t.jsxs(Y,{children:["When the row is ",t.jsx("strong",{children:"created"})," via upsert, Dataverse auto-sets these alternate-key columns from the URL —"," ",t.jsx("strong",{children:"don't repeat them in the Field set"}),". When the row is"," ",t.jsx("strong",{children:"updated"}),", alternate-key values in the URL identify the row and are ignored in the body."]})})]})]})]}):t.jsx(J,{layout:"multiline",intent:"error",children:t.jsxs(Y,{children:["Unknown table ",t.jsx("code",{children:x}),"."]})})}const re=()=>({table:"",key:{kind:"guid",recordId:null},fieldValues:{},nullFields:[],rawBody:null,prefer:{...wt(),formattedValues:!0,returnRepresentation:!0},headers:jt(),returnSelect:[],concurrency:{kind:"none"},bypass:Ut(),dirty:new Set}),ne=gt;function Gt({themeMode:x}){const n=Ce("upsert"),p=Ue("upsert",ae,re),[e,c]=o.useState(p.state),{table:h}=Pe(e.table||null),{allEntities:l}=Le(),[i,b]=o.useState("target"),[u,j]=o.useState("builder"),[w,F]=o.useState(null),[ie,oe]=o.useState(!1),[de,H]=o.useState(!1),[ce,ue]=Ve("upsert"),[I,N]=o.useState(p.lastSavedId),[B,T]=o.useState(p.lastSavedHash),S=o.useMemo(()=>Ae(e),[e,h]),L=o.useMemo(()=>De(e),[e,h]),d=D(e.table),ye=s=>c(a=>{const r=new Set(a.dirty);return r.add(s),{...a,dirty:r}}),m=(s,a,r)=>{c(f=>({...f,[s]:a})),r&&ye(r)},$=(()=>{const s=e.key;if(s.kind==="guid")return!!s.recordId;const a=d?.alternateKeys?.find(r=>r.name===s.keyName);return a?a.columns.every(r=>(s.keyValues[r]??"").trim()!==""):!1})(),C=e.rawBody!=null?Object.keys(L).length:Object.keys(e.fieldValues).length,R=o.useMemo(()=>d?e.concurrency.kind!=="create-only"?[]:He(d,d.columns,e.rawBody,e.fieldValues,e.nullFields).map(s=>s.logicalName):[],[d,e.concurrency.kind,e.rawBody,e.fieldValues,e.nullFields]),K=$e(e.rawBody),pe=d?$?e.key.kind==="guid"&&e.key.recordId&&!ne(e.key.recordId)?"Record id is not a valid GUID.":K||(R.length>0?`${R.length} required field${R.length===1?"":"s"} unset for create-only: ${R.slice(0,3).join(", ")}${R.length>3?"…":""}`:Object.keys(L).length===0?"Body is empty — set at least one field.":e.concurrency.kind==="etag"&&Q(e.concurrency.etag)?Q(e.concurrency.etag):e.headers.some(s=>s.enabled&&!s.name)?"Fix empty header name.":null):e.key.kind==="guid"?"Pick a record (or switch to alternate key).":"Fill in every alternate-key column.":"Pick a target table first.",he=async()=>{H(!0);const s=await kt.upsert(e,se(E,null));F(s),oe(e.prefer.returnRepresentation),H(!1),j("results"),ue(xt({snapshot:v,modeId:"upsert",url:S.relativeUrl,method:"PATCH",status:s.status,ms:s.ms,rowCount:s.ok?1:0})),c(a=>({...a,dirty:new Set}))},E=o.useMemo(()=>Ke(e),[e]),G=o.useMemo(()=>{const s=[...It(e.bypass,"bypass"),...Ee({op:"upsert",concurrency:e.concurrency,bypass:e.bypass})];if(e.key.kind==="guid"&&e.key.recordId&&!ne(e.key.recordId)&&s.push({id:"ups-bad-guid",severity:"error",source:"validation",focusNode:"key",title:"Invalid record id",body:`"${e.key.recordId}" isn't a valid GUID. The upsert will fail at the wire.`}),e.key.kind==="alternate"){s.push({id:"ups-altkey-unsupported",severity:"error",source:"validation",focusNode:"key",title:"Alternate-key Upsert isn't supported by the PPTB host",body:t.jsxs(t.Fragment,{children:["DRS authors the correct request"," ",t.jsxs("code",{children:["PATCH /",d?.entitySetName??"<set>","(<keyCol>='value')"]}),", but PPTB's ",t.jsx("code",{children:"dataverseAPI.update"})," only accepts GUID addressing — there's no raw-request hook for property-keyed URLs. Copy the URL + body from the Code tab and run it from Postman / curl / the JS SDK / Power Automate. Or switch the Key pane to ",t.jsx("strong",{children:"By GUID"})," if you know the record's primary key."]})});const a=e.key,r=d?.alternateKeys?.find(k=>k.name===a.keyName),f=r?Ge(e.table,r,a.keyValues):[],_=r?qe(e.table,r):[];_.length>0&&s.push({id:"ups-altkey-unknown-type",severity:"info",source:"validation",focusNode:"key",title:"Key column type unknown — quoted as string",body:t.jsxs(t.Fragment,{children:[_.map((k,V)=>t.jsxs("span",{children:[V>0&&", ",t.jsx("code",{children:k})]},k))," ","couldn't be found in the table metadata, so its value is quoted as a string literal. If the column is numeric, a choice, a date or a GUID, remove the quotes from the key segment before running the request."]})}),f.length>0&&s.push({id:"ups-altkey-reserved-chars",severity:"warning",source:"validation",focusNode:"key",title:"Alternate-key value has characters Dataverse rejects",body:t.jsxs(t.Fragment,{children:[f.map((k,V)=>t.jsxs("span",{children:[V>0&&", ",t.jsx("code",{children:k})]},k))," ","contains one of ",t.jsx("code",{children:"/ < > * % & : \\ ? + #"}),". DRS percent-encodes the value, but Dataverse still rejects these characters inside an alternate-key URL. Look the row up with ",t.jsx("code",{children:"$filter"})," instead (for example"," ",t.jsx("code",{children:"?$filter=accountnumber eq '…'&$select=…id"}),"), then upsert by its GUID."]})})}return s},[e.bypass,e.concurrency,e.key,e.table,d]),be=Oe(G),v=o.useMemo(()=>ze(e),[e]);Me("upsert",v,I,B);const me=o.useMemo(()=>A(v),[v]),q=B===null?!0:me!==B,ge=s=>{N(s.id),T(A(s.state))},O=s=>{if(s.modeId!=="upsert")return;const a=s.state;if(l.length>0&&!l.some(r=>r.logicalName===a.table)){ft(`Can't load "${s.name}": entity \`${a.table}\` isn't available in this environment. The solution may have been removed or you may be connected to a different org.`);return}c(ae(a)),N(s.id),T(A(a)),F(null),b("target")},fe=s=>{const a=vt(s,"upsert");if(!a)return;const r=I,f=B;O(a),N(r),T(f)},z=X(ge);We("upsert",s=>{s.modeId==="upsert"&&(c(St(re(),s)),F(null),j("builder"),b("target"))});const M=X(O);_e(o.useMemo(()=>e.table?{state:v,modeId:"upsert",dirty:q,lastSavedId:I,onSaved:z,onLoadSaved:M}:null,[v,q,I,e.table,z,M]));const W=e.prefer.returnRepresentation,ke=e.key.kind==="guid"?"GUID":"alt key",xe=[{id:"target",label:"Target",meta:d?`${d.displayName} · ${d.entitySetName}`:"Pick a table",items:[{id:"target",icon:Ye,iconFilled:Je,label:d?.displayName??"Pick a table",dirty:e.dirty.has("target")}]},{id:"key",label:"Key",meta:ke,items:[{id:"key",icon:Rt,iconFilled:le,label:e.key.kind==="guid"?"By GUID":"By alternate key",badge:$?"✓":null,badgeAppearance:"ghost",dirty:e.dirty.has("key")}]},{id:"body",label:"Field set",meta:`${C} field${C===1?"":"s"}`,items:[{id:"fieldset",icon:Qe,iconFilled:Ze,label:"Field set",badge:C||null,badgeAppearance:"tint",badgeColor:C>0?"success":"subtle",dirty:e.dirty.has("fieldset")}]},{id:"precondition",label:"Precondition",meta:e.concurrency.kind==="none"?"None — server decides":e.concurrency.kind==="create-only"?"Require absent record":e.concurrency.kind==="update-only"?"Require existing record":"Match specific ETag",items:[{id:"precondition",icon:et,iconFilled:Xe,label:"Optimistic concurrency",badge:e.concurrency.kind==="none"?"none":e.concurrency.kind==="create-only"?"If-None-Match: *":e.concurrency.kind==="update-only"?"If-Match: *":"If-Match: etag",badgeAppearance:"ghost",dirty:e.dirty.has("precondition")}]},{id:"prefer",label:"Prefer",meta:W?"return=representation":"204 No Content",items:[{id:"prefer",icon:st,iconFilled:tt,label:"Prefer header",badge:te(e.prefer)?"on":null,badgeAppearance:"ghost",dirty:e.dirty.has("prefer")},...W?[{id:"returnselect",icon:rt,iconFilled:at,label:"$select (response)",code:!0,badge:e.returnSelect.length||null,dirty:e.dirty.has("returnselect")}]:[]]},{id:"headers",label:"Headers",meta:`${e.headers.filter(s=>s.enabled).length} active`,items:[{id:"headers",icon:lt,iconFilled:nt,label:"HTTP headers",badge:e.headers.filter(s=>s.enabled).length||null,dirty:e.dirty.has("headers")},{id:"bypass",icon:ee,iconFilled:ee,label:"Bypass logic",badge:Nt(e.bypass),badgeAppearance:e.bypass.businessLogic!=="none"||e.bypass.suppressFlows?"tint":"ghost",badgeColor:e.bypass.businessLogic!=="none"||e.bypass.suppressFlows?"warning":"subtle",dirty:e.dirty.has("bypass")}]}];let g;switch(i){case"target":g=t.jsx(ut,{table:e.table,onTableChange:s=>{const r=D(s)?.alternateKeys?.[0];c(f=>({...f,table:s,key:r?{kind:"alternate",keyName:r.name,keyValues:{}}:{kind:"guid",recordId:null},fieldValues:{},rawBody:null,returnSelect:[],dirty:new Set(["target","key","fieldset"])})),F(null),N(void 0),T(null)},group:"write",sub:"Pick the entity set for the upsert. Switching the target clears the key and field set."});break;case"key":g=t.jsx(Pt,{table:e.table,keyMode:e.key,setKeyMode:s=>m("key",s,"key"),group:"write"});break;case"fieldset":g=t.jsx(Ft,{table:e.table,values:e.fieldValues,setValues:s=>m("fieldValues",s,"fieldset"),nullFields:e.nullFields,setNullFields:s=>m("nullFields",s,"fieldset"),rawBody:e.rawBody??null,setRawBody:s=>m("rawBody",s,"fieldset"),group:"write",themeMode:x,purpose:"upsert"});break;case"precondition":g=t.jsx(ct,{mode:e.concurrency,setMode:s=>m("concurrency",s,"precondition"),available:["none","create-only","update-only","etag"],group:"write"});break;case"prefer":g=t.jsx(dt,{spec:e.prefer,setSpec:s=>m("prefer",s,"prefer"),group:"write"});break;case"returnselect":g=t.jsx(ot,{table:e.table,selectedIds:e.returnSelect,setSelectedIds:s=>m("returnSelect",s,"returnselect"),group:"write"});break;case"headers":g=t.jsx(it,{items:e.headers,setItems:s=>m("headers",s,"headers"),group:"write"});break;case"bypass":g=t.jsx(Bt,{value:e.bypass,onChange:s=>m("bypass",s,"bypass"),group:"write"});break}const ve=se(E,te(e.prefer)),je={method:"PATCH",built:S,headers:ve,body:L,entityLogical:S.entityLogical};return t.jsx(yt,{sidebar:t.jsx(mt,{type:n,urlPreview:S.relativeNoBase,sections:xe,activeNode:i,onSelect:s=>{b(s),j("builder")},recents:ce,onRecentClick:fe}),urlBar:t.jsx(bt,{method:"PATCH",url:S.relativeUrl,executeVerb:n.executeVerb,writeConfirm:{operation:"Upsert Record",table:e.table,scope:{kind:"records",count:1},highImpact:!1},disabledReason:pe??be,loading:de,onExecute:he,advisories:G,onAdvisoryFocus:b}),children:t.jsxs(pt,{tab:u,onTabChange:j,resultCount:w?.ok?1:null,children:[u==="builder"&&g,u==="code"&&t.jsx(Tt,{themeMode:x,inputs:je}),u==="results"&&t.jsx(ht,{result:w,mode:"single",table:e.table,writeContext:{operation:"upsert",table:e.table,recordId:e.key.kind==="guid"?e.key.recordId:null,recordName:Ct(d?.primaryName,w?.body,e.fieldValues),returnRepresentation:ie}})]})})}export{Gt as UpsertMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{bg as x,z as P,fr as T,E as F,j as o,t as l,fs as A,aP as O,ft as B,C as y,ak as L,aW as v,s as k,ao as w,ap as S,aq as q,fu as W,fv as U,bv as D,fw as z,fx as _,fy as I,fz as G,fA as J,fB as M,fC as H,fD as V,fE as Y,B as K,fF as Q,fG as X,fH as Z}from"./index-NW0Z4UWR.js";const ee={create:"create",update:"update",upsert:"upsert",delete:"delete",merge:"merge",associate:"associate",disassociate:"disassociate",action:"action call",function:"function call",workflow:"workflow run","manage-file":"file request","manage-image":"image request","manage-attachment":"attachment request"},te=new Set(["create","update","upsert","merge"]);function de({result:e,ctx:t}){const s=x(),i=P(t.table),n=i?.displayName??t.table,h=e.headers["OData-EntityId"]??e.headers["odata-entityid"],a=t.recordId??ne(h)??se(e.body,i?.primaryKey),c=e.ok?"success":e.outcome==="partial"||e.status===412||e.status===404||e.status===429||e.status===409?"warning":"danger",$=c==="success"?A:c==="warning"?O:B,r=c==="success"?l.colorPaletteGreenForeground1:c==="warning"?l.colorPaletteDarkOrangeForeground1:l.colorPaletteRedForeground1,d=oe(t,e,a,n),u=c==="success"&&!!a&&!!t.table&&te.has(t.operation)&&T(),g=a&&i?`https://${F.host}${F.apiBase}/${i.entitySetName}(${a})`:null,p=e.body,f=!!p&&typeof p=="object"&&!Array.isArray(p)&&Object.keys(p).length>0&&("@odata.etag"in p||i&&i.primaryKey in p);return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[o.jsxs("div",{className:D(s.inlineCard),style:{padding:16,background:c==="success"?l.colorPaletteGreenBackground1:c==="warning"?l.colorPaletteDarkOrangeBackground1:l.colorPaletteRedBackground1,border:c==="success"?`1px solid ${l.colorPaletteGreenBorderActive}`:c==="warning"?`1px solid ${l.colorPaletteDarkOrangeBorderActive}`:`1px solid ${l.colorPaletteRedBorderActive}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[o.jsx($,{style:{width:28,height:28,color:r,flexShrink:0}}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:15,fontWeight:600,marginBottom:2},children:d.title}),d.body&&o.jsx(y,{style:{color:l.colorNeutralForeground2},children:d.body}),c==="success"&&t.returnRepresentation&&(t.operation==="update"||t.operation==="upsert")&&!f&&o.jsxs(y,{style:{display:"block",color:l.colorNeutralForeground3},children:["You asked for return=representation, but ToolBox's update doesn't pass the row back.",u&&" Retrieve this record to see it."]})]}),o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8,flexShrink:0},children:[o.jsx(L,{status:c==="success"?"success":c==="warning"?"warning":"danger",code:e.outcome==="partial"?"Partial success":e.status||"Error",ms:e.ms}),o.jsxs(y,{style:{color:l.colorNeutralForeground3},children:[(e.bytes/1024).toFixed(1)," KB"]})]})]}),a&&o.jsxs("div",{style:{display:"flex",gap:6,marginTop:12,flexWrap:"wrap",paddingTop:12,borderTop:`1px solid ${l.colorNeutralStroke3}`},children:[o.jsxs("code",{style:{fontFamily:l.fontFamilyMonospace,fontSize:11,color:l.colorNeutralForeground3,padding:"4px 8px",background:l.colorNeutralBackground1,borderRadius:l.borderRadiusSmall,alignSelf:"center"},children:[i?.primaryKey??"id",": ",a]}),o.jsx(v,{content:"Copy record GUID",relationship:"description",children:o.jsx(k,{size:"small",appearance:"subtle",icon:o.jsx(S,{}),onClick:()=>{w(a,"the record ID")},children:"Copy ID"})}),g&&!(t.operation==="delete"&&!t.clearedColumn)&&o.jsxs(o.Fragment,{children:[o.jsx(v,{content:"Copy record URL",relationship:"description",children:o.jsx(k,{size:"small",appearance:"subtle",icon:o.jsx(S,{}),onClick:()=>{w(g,"the record URL")},children:"Copy URL"})}),o.jsx(v,{content:"Open the record's Web API URL in a new tab",relationship:"description",children:o.jsx(k,{size:"small",appearance:"subtle",icon:o.jsx(q,{}),onClick:()=>window.open(g,"_blank","noopener"),children:"Open"})})]}),u&&o.jsx(v,{content:"Open this record in Retrieve Single and run the request",relationship:"description",children:o.jsx(k,{size:"small",appearance:"subtle",icon:o.jsx(Z,{}),onClick:()=>X("retrieve-single",{table:t.table,recordId:a,autoExecute:!0}),children:"Retrieve this record"})})]}),!e.ok&&o.jsx("div",{style:{display:"flex",gap:6,marginTop:12,flexWrap:"wrap"},children:o.jsx(k,{size:"small",appearance:"subtle",icon:o.jsx(U,{}),onClick:()=>{w(W({result:e,operation:`${t.operation}${t.table?` on ${t.table}`:""}`}),"the error report")},children:"Copy error report"})})]}),E(e)&&o.jsx(ae,{targets:e.targets,operation:t.operation,names:t.targetNameById??{}}),f&&o.jsxs("div",{children:[o.jsx(y,{style:{display:"block",marginBottom:6,color:l.colorNeutralForeground3,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.04em",fontSize:10},children:"Returned representation"}),o.jsx(z,{record:p,entityLogical:t.table,level:0})]})]})}function oe(e,t,s,i){const n=e.recordName?.trim()||null,h=t.ok,a=re(e,t,n,s,i);if(a)return a;if(!h){const r=t.body?.error,d=r?.code;if(d===_)return{title:"Not sent — headers not approved",body:"Power Platform ToolBox didn't send the request because its headers weren't approved, so nothing changed in Dataverse. Execute again and approve the headers when ToolBox asks."};if(d===I)return{title:"Not sent — header rejected",body:r?.message??"Power Platform ToolBox rejected a request header."};const u=G(t);return u?{title:`Throttled: ${u.limit}`,body:`Dataverse didn't run this ${ee[e.operation]}. ${u.advice} ${J}`}:t.status===412?{title:"Operation rejected",body:e.operation==="upsert"?"precondition failed — the record's existence state didn't match your selection":e.operation==="delete"||e.operation==="update"?"precondition failed — the ETag is stale (someone else changed the record)":"precondition failed"}:t.status===404?{title:"Record not found",body:`No ${i} record matched ${s??"the supplied id"}.`}:t.status===409?{title:"Conflict",body:"A duplicate-detection rule or related conflict blocked the operation."}:t.status===401?{title:"Not authenticated",body:"Your session lost the bearer token. Reconnect and retry."}:t.status===403?{title:"Forbidden",body:"The calling user lacks the required privilege."}:t.status===501?{title:"Not executed",body:r?.message??"The PPTB host could not run this request."}:t.status>=500?{title:"Server error",body:"Dataverse returned a 5xx. Inspect the JSON body for details."}:{title:t.status?`Failed · ${t.status} ${t.statusText}`:"Failed",body:"See the JSON tab for details."}}const c=n?o.jsx(o.Fragment,{children:n}):s?`record ${s.slice(0,8)}…`:`${i} record`,$=typeof c=="string"?c:n;switch(e.operation){case"create":return{title:`Created ${i}`,body:s?`New record ${$?`"${$}"`:""} created with id ${s.slice(0,8)}…`:"Record created."};case"update":return{title:t.status===200?`Updated ${i} (return=representation)`:`Updated ${i}`,body:n?`Saved changes to "${n}".`:s?`Saved changes to ${s.slice(0,8)}…`:null};case"upsert":return t.status===201?{title:`Upsert: created new ${i}`,body:n?`New record "${n}".`:s?`id ${s.slice(0,8)}…`:null}:{title:`Upsert completed on ${i}`,body:n?`Server resolved the request against "${n}". The PPTB host doesn't surface the distinguishing 201 (created) vs 204 (updated) — copy the URL + body from the Code tab and run outside PPTB if you need to tell which path ran.`:s?`Server resolved the request against id ${s.slice(0,8)}…`:"Server resolved the request."};case"delete":return e.clearedColumn?{title:`Cleared column on ${i}`,body:`Set ${e.clearedColumn} to null on ${n?`"${n}"`:`id ${s?.slice(0,8)??"?"}…`}.`}:{title:`Deleted ${i}`,body:n?`"${n}" has been removed. Related records cascaded per CascadeConfiguration.`:"Record removed."};case"merge":return{title:`Merged ${i}`,body:e.subordinateName&&e.targetName?`"${e.subordinateName}" merged into "${e.targetName}". Subordinate deactivated; related rows re-parented.`:"Merge completed. Subordinate deactivated; related rows re-parented."};case"associate":{const r=e.targetCount??0,d=e.navProperty?`via ${e.navProperty}`:"",u=n?`"${n}"`:s?`id ${s.slice(0,8)}…`:`the ${i} record`,g=(e.targetNames??[]).slice(0,3),p=Math.max(0,r-g.length),f=g.length>0?`${g.map(m=>`"${m}"`).join(", ")}${p>0?` and ${p} more`:""}`:r>0?`${r} target${r===1?"":"s"}`:"the target";return{title:r>1?`Associated ${r} records to ${i}`:`Associated to ${i}`,body:`Linked ${f} to ${u} ${d}.`.replace(/\s+\./,".")+(t.changeSet?" Sent as one change set.":"")}}case"disassociate":{const r=e.targetCount??0,d=e.navProperty?`via ${e.navProperty}`:"",u=n?`"${n}"`:s?`id ${s.slice(0,8)}…`:`the ${i} record`;return{title:r>1?`Disassociated ${r} records from ${i}`:`Disassociated from ${i}`,body:r>0?`Removed ${r} link${r===1?"":"s"} from ${u} ${d}.`.replace(/\s+\./,".")+(t.changeSet?" Sent as one change set.":""):`Cleared the lookup on ${u} ${d}.`.replace(/\s+\./,".")}}case"action":{const r=e.operationName??"action",d=e.boundEntity?` on ${n?`${e.boundEntity} "${n}"`:`the ${e.boundEntity} record`}`:"";return{title:`Action: ${r}`,body:t.status===200||t.status===201?`Executed ${r}${d}. Server returned a result body — see the JSON tab.`:`Executed ${r}${d}. Server returned 204 No Content — no return value.`}}case"function":{const r=e.operationName??"function",d=e.boundEntity?` bound to ${n?`${e.boundEntity} "${n}"`:`a ${e.boundEntity} record`}`:"";return{title:`Function: ${r}`,body:`Invoked ${r}${d}. The result body is in the JSON tab.`}}case"workflow":{const r=e.operationName??"workflow",d=n?` on "${n}"`:s?` on record ${s.slice(0,8)}…`:"";return{title:`Workflow: ${r}`,body:`Triggered "${r}"${d}. Workflow steps run asynchronously — check the System Jobs grid for progress.`}}case"manage-file":case"manage-image":case"manage-attachment":{const r=e.operation==="manage-image"?"image":e.operation==="manage-attachment"?e.columnName==="documentbody"?"annotation":"attachment":"file",d=e.fileOperation??"upload",u=e.columnName?` · column ${e.columnName}`:"",g=n?` on ${i} "${n}"`:s?` on record ${s.slice(0,8)}…`:"",p=r.charAt(0).toUpperCase()+r.slice(1);return t.status===501?{title:`${p} ${d} — request built`,body:`PPTB's dataverseAPI doesn't expose the ${r} ${d} endpoint. Your request is ready to run externally — copy a snippet from the Code tab (fetch / curl / C# / PowerShell) and execute it from there.`}:{title:`${p} ${d}${u}`,body:t.ok?`${p} ${d} completed${g}.`:`${d} request failed${g}. See the JSON / Headers tabs for details.`}}}}function E(e){const t=e.targets;return!t||t.length===0?!1:t.length>1||t[0].state!=="done"}function re(e,t,s,i,n){if(e.operation!=="associate"&&e.operation!=="disassociate"||!E(t))return null;const h=t.targets.length,a=Q(t),{done:c,skipped:$,failed:r}=a,d=a["rolled-back"];if(r===0&&$===0&&d===0||r===h&&h===1)return null;const u=e.operation==="associate",g=b=>`${b} record${b===1?"":"s"}`,p=s?`"${s}"`:i?`id ${i.slice(0,8)}…`:`the ${n} record`,f=e.navProperty?` via ${e.navProperty}`:"",m=$>0?` ${$} ${$===1?"was":"were"} already ${u?"linked":"unlinked"}, so no request was sent for ${$===1?"it":"them"}.`:"",R=u?"Fix the failures and Execute again: targets that are already linked are skipped.":"Fix the failures, remove the targets that were unlinked, and Execute again: every listed target is sent again.";if(d>0){const b=u?"Associate":"Disassociate",N=r+d,j=`${N} request${N===1?"":"s"}`;if(r>0)return{title:`${b} failed — nothing changed`,body:(`The ${j} went as one change set. One failed, so Dataverse rolled back the other ${d}: nothing was changed on ${p}${f}.`+m+" Fix the failure and Execute again.").trim()};const C=t.body?.error?.message;return{title:`${b} failed — change set not applied`,body:(`The change set of ${j} failed${C?`: ${C.replace(/\.?$/,".")}`:"."} Dataverse applies a change set whole or not at all, so none of them should have changed ${p}${f}.`+m+" If the connection dropped, check the links before you Execute again.").trim()}}if(r===0){const b=u?"Linked":"Removed links to";return{title:c===0?u?`Already associated to ${n}`:`Already disassociated from ${n}`:u?`Associated ${g(c)} to ${n}`:`Disassociated ${g(c)} from ${n}`,body:((c>0?`${b} ${g(c)} on ${p}${f}.`:"")+m).trim()}}return c===0?{title:r===h?`${u?"Associate":"Disassociate"} failed for all ${h} targets`:`${u?"Associate":"Disassociate"} failed for ${r} of ${g(h)}`,body:(`Nothing was changed on ${p}.`+m+" Each failed target's error is listed below.").trim()}:{title:`${u?"Associated":"Disassociated"} ${c} of ${g(h)} — ${r} failed`,body:(`${u?"Linked":"Removed links to"} ${g(c)} on ${p}${f}; those changes are saved.`+m+` ${R}`).trim()}}function ae({targets:e,operation:t,names:s}){const i=x(),n=t==="associate",h=a=>a.state==="done"?n?"Linked":"Unlinked":a.state==="skipped"?"Already linked · skipped":a.state==="rolled-back"?"Not applied":a.status?`Failed · ${a.status} ${a.statusText??""}`.trim():"Failed";return o.jsxs("div",{className:i.inlineCard,style:{padding:12},children:[o.jsx(y,{style:{display:"block",marginBottom:8,color:l.colorNeutralForeground3,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.04em",fontSize:10},children:"Targets"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:e.map(a=>{const c=a.state==="done"?M:a.state==="skipped"?H:a.state==="rolled-back"?V:Y,$=a.state==="done"?l.colorPaletteGreenForeground1:a.state==="skipped"?l.colorNeutralForeground3:a.state==="rolled-back"?l.colorPaletteDarkOrangeForeground1:l.colorPaletteRedForeground1,r=s[a.targetId];return o.jsxs("div",{style:{display:"flex",gap:8,minWidth:0},children:[o.jsx(c,{style:{color:$,flexShrink:0,marginTop:2}}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"baseline"},children:[r&&o.jsx("span",{style:{fontWeight:600},children:r}),o.jsx("code",{style:{fontFamily:l.fontFamilyMonospace,fontSize:11,color:l.colorNeutralForeground3,overflowWrap:"anywhere"},children:a.targetId}),o.jsx(K,{size:"small",appearance:"tint",color:a.state==="done"?"success":a.state==="skipped"?"informative":a.state==="rolled-back"?"warning":"danger",children:h(a)})]}),a.error&&o.jsx(y,{style:{display:"block",marginTop:2,color:l.colorNeutralForeground2,overflowWrap:"anywhere"},children:a.error.code&&!a.error.message.includes(a.error.code)?`${a.error.code}: ${a.error.message}`:a.error.message})]})]},a.targetId)})})]})}function ne(e){if(!e)return null;const t=e.match(/\(([0-9a-fA-F-]{36})\)/);return t?t[1]:null}function se(e,t){if(!e||typeof e!="object"||Array.isArray(e))return null;const s=e;return(typeof s.id=="string"&&/^[0-9a-fA-F-]{36}$/.test(s.id)?s.id:null)??(t&&typeof s[t]=="string"&&/^[0-9a-fA-F-]{36}$/.test(s[t])?s[t]:null)??null}export{de as WriteResultCard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{bg as M,r as D,dy as y,dz as c,j as s,ay as E,aP as A,B as _,dA as F,C as g,t as o,az as T,aA as p,an as B,au as P,av as O,s as L,aU as q,aT as N,M as f,m as b,o as U,dB as $,dC as z,cm as l}from"./index-NW0Z4UWR.js";function V({value:e,onChange:i,group:a="write"}){const x=M(),[r,m]=D.useState(""),d=t=>i({...e,...t}),v=t=>d({businessLogic:t}),j=e.stepIds.filter(Boolean).length,k=e.businessLogic==="steps"&&j>y,w=e.businessLogic==="steps"&&j>c,S=()=>{const t=r.trim();if(t){if(e.stepIds.includes(t)){m("");return}d({stepIds:[...e.stepIds,t]}),m("")}},C=t=>d({stepIds:e.stepIds.filter((n,R)=>R!==t)});return s.jsxs("div",{children:[s.jsx(E,{icon:A,title:"Bypass logic",sub:"Skip server-side business logic or Power Automate triggers — privileged operations for bulk-data work.",group:a,children:s.jsx(_,{appearance:"ghost",children:G(e)})}),(e.businessLogic!=="none"||e.suppressFlows)&&s.jsxs(F,{header:s.jsxs(s.Fragment,{children:["the ",s.jsx("code",{children:"MSCRM.*"})," bypass headers"]}),children:["The ",s.jsx("code",{children:"MSCRM.*"})," bypass headers are dropped at execute time, so"," ",s.jsx("strong",{children:"Execute"})," is disabled while a bypass option is on. Copy the request from the Code tab to run it elsewhere."]}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18,maxWidth:720},children:[s.jsxs("section",{children:[s.jsx(I,{children:"Custom business logic"}),s.jsxs(g,{style:{color:o.colorNeutralForeground2,display:"block",marginBottom:8},children:["Emits ",s.jsx("code",{children:"MSCRM.BypassBusinessLogicExecution"})," with the chosen scope. Requires the ",s.jsx("code",{children:"prvBypassCustomBusinessLogic"})," privilege — by default only System Administrator has it."]}),s.jsxs(T,{value:e.businessLogic,onChange:(t,n)=>v(n.value),layout:"vertical",children:[s.jsx(p,{value:"none",label:s.jsx(u,{title:"None",sub:"Default — all custom logic runs."})}),s.jsx(p,{value:"sync",label:s.jsx(u,{title:"Sync only",sub:"Bypass synchronous plug-ins/workflows. Reduces per-record latency on bulk operations."})}),s.jsx(p,{value:"async",label:s.jsx(u,{title:"Async only",sub:"Bypass async logic (system jobs). Lets bulk operations complete without queueing thousands of async ops."})}),s.jsx(p,{value:"both",label:s.jsx(u,{title:"Both",sub:"Skip both sync and async logic. Most aggressive option."})}),s.jsx(p,{value:"steps",label:s.jsx(u,{title:"Specific steps",sub:"Bypass only the named plug-in step registrations (GUIDs). Useful when one plug-in causes the slowdown."})})]}),e.businessLogic==="sync"&&s.jsx("div",{style:{marginTop:10,padding:"8px 12px",borderRadius:o.borderRadiusMedium,background:o.colorNeutralBackground2},children:s.jsx(B,{checked:e.useLegacyHeader,onChange:(t,n)=>d({useLegacyHeader:!!n.checked}),label:s.jsxs("span",{style:{fontSize:12},children:["Use legacy ",s.jsx("code",{children:"MSCRM.BypassCustomPluginExecution"})," header",s.jsxs(g,{style:{display:"block",color:o.colorNeutralForeground3},children:["Off: emit modern header. On: emit legacy (requires"," ",s.jsx("code",{children:"prvBypassCustomPlugins"})," privilege)."]})]})})}),e.businessLogic==="steps"&&s.jsxs("div",{className:x.inlineCard,style:{padding:12,marginTop:10},children:[s.jsx("strong",{style:{fontSize:12,display:"block",marginBottom:6},children:"Plug-in step IDs"}),s.jsxs(g,{style:{color:o.colorNeutralForeground2,display:"block",marginBottom:8},children:["One GUID per row. Resolve them via"," ",s.jsx("code",{children:"GET /sdkmessagefilters?$select=sdkmessagefilterid&$filter=primaryobjecttypecode eq '<table>' and sdkmessageid/name eq '<Op>'&$expand=sdkmessagefilterid_sdkmessageprocessingstep($select=name)"}),"."]}),s.jsx(P,{children:s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsx(O,{size:"small",value:r,onChange:(t,n)=>m(n.value),placeholder:"00000000-0000-0000-0000-000000000000",style:{flex:1},onKeyDown:t=>{t.key==="Enter"&&S()}}),s.jsx(L,{icon:s.jsx(q,{}),size:"small",onClick:S,disabled:!r.trim(),children:"Add"})]})}),e.stepIds.length>0&&s.jsx("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:4},children:e.stepIds.map((t,n)=>s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:o.fontFamilyMonospace,fontSize:11,padding:"4px 8px",background:o.colorNeutralBackground1,borderRadius:o.borderRadiusSmall},children:[s.jsx("span",{style:{flex:1},children:t}),s.jsx(L,{icon:s.jsx(N,{}),appearance:"subtle",size:"small","aria-label":`Remove step ${t}`,title:"Remove step",onClick:()=>C(n)})]},n))}),w&&s.jsx(f,{layout:"multiline",intent:"error",style:{marginTop:8},children:s.jsxs(b,{children:[s.jsx(U,{children:"Over the maximum step cap"}),"Dataverse caps this list at ",c,". The request will be rejected."]})}),!w&&k&&s.jsx(f,{layout:"multiline",intent:"warning",style:{marginTop:8},children:s.jsxs(b,{children:["Default org cap is ",y,". Anything over this requires the",s.jsx("code",{children:" BypassBusinessLogicExecutionStepIdsLimit "})," OrgDbOrgSettings tweak (max ",c,")."]})})]})]}),s.jsxs("section",{children:[s.jsx(I,{children:"Power Automate flows"}),s.jsxs(g,{style:{color:o.colorNeutralForeground2,display:"block",marginBottom:8},children:["Emits ",s.jsx("code",{children:"MSCRM.SuppressCallbackRegistrationExpanderJob"}),". No privilege required, but flow owners are ",s.jsx("strong",{children:"not notified"})," that their logic was bypassed."]}),s.jsx(B,{checked:e.suppressFlows,onChange:(t,n)=>d({suppressFlows:!!n.checked}),label:"Suppress Power Automate flow triggers"}),e.suppressFlows&&s.jsx(f,{layout:"multiline",intent:"warning",style:{marginTop:8},children:s.jsxs(b,{children:["Use only when you've confirmed a backlog of"," ",s.jsx("code",{children:"CallbackRegistration Expander Operation"})," jobs (operationtype 79 in",s.jsx("code",{children:" asyncoperation"}),"). Communicate with flow owners before enabling for production traffic."]})})]})]})]})}function I({children:e}){return s.jsx("div",{style:{fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",color:o.colorNeutralForeground3,marginBottom:6},children:e})}function u({title:e,sub:i}){return s.jsxs("span",{style:{display:"inline-flex",flexDirection:"column"},children:[s.jsx("strong",{style:{fontSize:12},children:e}),s.jsx(g,{style:{color:o.colorNeutralForeground3},children:i})]})}function G(e){const i=[];return e.businessLogic==="sync"&&i.push(e.useLegacyHeader?"sync (legacy)":"sync"),e.businessLogic==="async"&&i.push("async"),e.businessLogic==="both"&&i.push("sync+async"),e.businessLogic==="steps"&&i.push(`${e.stepIds.filter(Boolean).length} steps`),e.suppressFlows&&i.push("flows"),i.length===0?"off":i.join(" · ")}const h="https://learn.microsoft.com/en-us/power-apps/developer/data-platform/bypass-custom-business-logic",H="https://learn.microsoft.com/en-us/power-apps/developer/data-platform/bypass-power-automate-flows";function J(e,i="bypass"){const a=[];if(e.businessLogic!=="none"){const x=e.useLegacyHeader&&e.businessLogic==="sync"?$:z;if(a.push(l.warn("bypass-active","bypass",`Bypassing ${W(e)} business logic`,s.jsxs("span",{children:["This request requires the ",s.jsx("code",{children:x.name})," privilege on the caller."," ",x.description]}),i,h)),e.businessLogic==="steps"){const r=e.stepIds.filter(Boolean).length;r===0?a.push(l.err("bypass-no-steps","validation","Step bypass enabled but no step IDs provided",s.jsx("span",{children:'Add at least one plug-in step GUID, or change the bypass mode to "None".'}),i,h)):r>c?a.push(l.err("bypass-step-cap-max","validation",`${r} step IDs — exceeds the maximum cap (${c})`,s.jsxs("span",{children:["Dataverse rejects more than ",c," step IDs."]}),i,h)):r>y&&a.push(l.warn("bypass-step-cap-default","bypass",`${r} step IDs — exceeds the default org cap (${y})`,s.jsxs("span",{children:["Default cap is ",y,". Anything above this requires raising",s.jsx("code",{children:" BypassBusinessLogicExecutionStepIdsLimit "})," via the OrgDbOrgSettings tool."]}),i,h))}e.useLegacyHeader&&e.businessLogic==="sync"&&a.push(l.info("bypass-legacy-header","bypass","Using legacy MSCRM.BypassCustomPluginExecution header",s.jsxs("span",{children:["The newer ",s.jsx("code",{children:"MSCRM.BypassBusinessLogicExecution: CustomSync"})," is the recommended replacement. Both wire effects are equivalent for sync-only bypass."]}),i,h))}return e.suppressFlows&&a.push(l.warn("bypass-flows","flow-bypass","Suppressing Power Automate flow triggers",s.jsxs("span",{children:["Flow owners are ",s.jsx("strong",{children:"not notified"})," when their logic is bypassed. Communicate with them before running this against production data — child flows may still fire via other triggers later."]}),i,H)),a}function W(e){switch(e.businessLogic){case"sync":return"synchronous";case"async":return"asynchronous";case"both":return"sync + async";case"steps":return`${e.stepIds.filter(Boolean).length} specific plug-in step(s) of`;default:return""}}export{V as B,J as d,G as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(e){try{return decodeURIComponent(e)}catch{return e}}export{o as d};
|