@mohsinonxrm/pptb-dataverse-request-studio 1.5.0-beta.1 → 1.6.0-beta.1

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.
Files changed (142) hide show
  1. package/CHANGELOG.md +380 -0
  2. package/README.md +44 -18
  3. package/dist/assets/ActionParamForm-DvTh6hUs.js +1 -0
  4. package/dist/assets/AllOrNothingOption-C7wGq_-r.js +1 -0
  5. package/dist/assets/AssociateMode-Dj-iEObO.js +1 -0
  6. package/dist/assets/BatchMode-Dsa1JVpd.js +10 -0
  7. package/dist/assets/BinaryColumnPickers-NAaoPcPt.js +1 -0
  8. package/dist/assets/BinaryPipelineCard-CSklRaME.js +1 -0
  9. package/dist/assets/BulkDeleteMode-Cqpb47QI.js +1 -0
  10. package/dist/assets/BulkWriteMode-CRkiw89Q.js +6 -0
  11. package/dist/assets/CodeView-C65Y5vXN.js +874 -0
  12. package/dist/assets/CreateMode-CwGffdDR.js +1 -0
  13. package/dist/assets/DeleteMode-CaWEZkJ1.js +1 -0
  14. package/dist/assets/DisassociateMode-Ddk9Jm3g.js +2 -0
  15. package/dist/assets/ExecuteActionMode-BbN_9350.js +1 -0
  16. package/dist/assets/ExecuteFunctionMode-G3PFBDpl.js +1 -0
  17. package/dist/assets/ExecuteWorkflowMode-D2MxIt5s.js +1 -0
  18. package/dist/assets/FieldSetEditor-Dg6WsDgG.js +3 -0
  19. package/dist/assets/ImportCurlDialog-BiURYtjH.js +7 -0
  20. package/dist/assets/ManageAttachmentMode-D14EZog8.js +1 -0
  21. package/dist/assets/ManageFileMode-DMLRV2xg.js +1 -0
  22. package/dist/assets/ManageImageMode-CoSAt9yh.js +1 -0
  23. package/dist/assets/MergeMode-PfbLAjOh.js +1 -0
  24. package/dist/assets/OptionGroup-DYAAm_pt.js +1 -0
  25. package/dist/assets/PredefinedQueryMode-CdT1I6jB.js +1 -0
  26. package/dist/assets/RetrieveNextLinkMode-BK9KD3q6.js +1 -0
  27. package/dist/assets/RetrieveSingleMode-_y2Z1G7C.js +1 -0
  28. package/dist/assets/UpdateMode-Dvd6cr4i.js +1 -0
  29. package/dist/assets/UpsertMode-BuyV7FEg.js +1 -0
  30. package/dist/assets/WriteResultCard-N_Ewu4dP.js +1 -0
  31. package/dist/assets/bypassAdvisories-BhBeq_oI.js +1 -0
  32. package/dist/assets/decodeForDisplay-D55DM53E.js +1 -0
  33. package/dist/assets/index-NW0Z4UWR.js +42 -0
  34. package/dist/assets/javascript-Dti3Ss-T.js +1 -0
  35. package/dist/assets/{jsonMode-DOHFeg2H.js → jsonMode-YuJX0ZcQ.js} +1 -1
  36. package/dist/assets/jsonWorkerInPage-CTjyykdK.js +33 -0
  37. package/dist/assets/{monacoSetup-CEhMjQNN.js → monacoSetup-Bxl8fgYX.js} +176 -176
  38. package/dist/assets/multipart-Bd_eOd8a.js +4 -0
  39. package/dist/assets/{python-DDgBOsRh.js → python-CZnGM3Qv.js} +1 -1
  40. package/dist/assets/writeResultName-Dw705_0B.js +1 -0
  41. package/dist/assets/writeState-DgYICTBE.js +1 -0
  42. package/dist/assets/{xml-BXhJpCm5.js → xml-gySD1GMR.js} +1 -1
  43. package/dist/icons/icon.svg +9 -6
  44. package/dist/index.html +7 -1
  45. package/index.html +6 -0
  46. package/package.json +2 -1
  47. package/dist/assets/AssociateMode-mu2ai0TV.js +0 -1
  48. package/dist/assets/AssociateTargetsEditor-BoH9Qxe8.js +0 -1
  49. package/dist/assets/BatchMode-BVAfFgPy.js +0 -11
  50. package/dist/assets/BinaryColumnPickers-DYpKoRIO.js +0 -1
  51. package/dist/assets/BulkDeleteMode-Df-XirlR.js +0 -1
  52. package/dist/assets/BulkWriteMode-UXREEvbe.js +0 -6
  53. package/dist/assets/DisassociateMode-CKBL5nUo.js +0 -2
  54. package/dist/assets/ExecuteWorkflowMode-4EWco-ze.js +0 -1
  55. package/dist/assets/ManageFileMode-BFNwxuEY.js +0 -1
  56. package/dist/assets/ManageImageMode-DX0AdPN1.js +0 -1
  57. package/dist/assets/MergeMode-BzyXLu1b.js +0 -1
  58. package/dist/assets/PredefinedQueryMode-BT-HdZHF.js +0 -1
  59. package/dist/assets/RetrieveNextLinkMode-QBuIwdgS.js +0 -1
  60. package/dist/assets/abap-CRCWOmpq.js +0 -1
  61. package/dist/assets/apex-DnsZk_dE.js +0 -1
  62. package/dist/assets/azcli-1IWB1ccx.js +0 -1
  63. package/dist/assets/bat-DPkNLes8.js +0 -1
  64. package/dist/assets/bicep-Corcdgou.js +0 -2
  65. package/dist/assets/cameligo-CGrWLZr3.js +0 -1
  66. package/dist/assets/clojure-D9WOWImG.js +0 -1
  67. package/dist/assets/coffee-B7EJu28W.js +0 -1
  68. package/dist/assets/cpp-SEyurbux.js +0 -1
  69. package/dist/assets/csp-C46ZqvIl.js +0 -1
  70. package/dist/assets/css-DQU6DXDx.js +0 -3
  71. package/dist/assets/css.worker-CwQehIRV.js +0 -93
  72. package/dist/assets/cssMode-DRNC4UuD.js +0 -4
  73. package/dist/assets/cypher-D84EuPTj.js +0 -1
  74. package/dist/assets/dart-D8lhlL1r.js +0 -1
  75. package/dist/assets/dockerfile-DLk6rpji.js +0 -1
  76. package/dist/assets/ecl-BO6FnfXk.js +0 -1
  77. package/dist/assets/elixir-BRjLKONM.js +0 -1
  78. package/dist/assets/flow9-Cac8vKd7.js +0 -1
  79. package/dist/assets/freemarker2-BITb8GyO.js +0 -3
  80. package/dist/assets/fsharp-fd1GTHhf.js +0 -1
  81. package/dist/assets/go-O9LJTZXk.js +0 -1
  82. package/dist/assets/graphql-LQdxqEYJ.js +0 -1
  83. package/dist/assets/handlebars-BbDVduNH.js +0 -1
  84. package/dist/assets/hcl-DxDQ3s82.js +0 -1
  85. package/dist/assets/html-Ru2Cy2VS.js +0 -1
  86. package/dist/assets/html.worker-4xVL0wjo.js +0 -470
  87. package/dist/assets/htmlMode-DeMh8vPt.js +0 -4
  88. package/dist/assets/index-XmEQbXiX.js +0 -703
  89. package/dist/assets/ini-BvajGCUy.js +0 -1
  90. package/dist/assets/java-SYsfObOQ.js +0 -1
  91. package/dist/assets/javascript-DLj2yjBO.js +0 -1
  92. package/dist/assets/julia-DQXNmw_w.js +0 -1
  93. package/dist/assets/kotlin-qQ0MG-9I.js +0 -1
  94. package/dist/assets/less-GGFNNJHn.js +0 -2
  95. package/dist/assets/lexon-Canl7DCW.js +0 -1
  96. package/dist/assets/liquid-udbJGOUP.js +0 -1
  97. package/dist/assets/lua-D28Ae8-K.js +0 -1
  98. package/dist/assets/m3-DPitgjJI.js +0 -1
  99. package/dist/assets/markdown-B811l8j2.js +0 -1
  100. package/dist/assets/mdx-B6ABiFDH.js +0 -1
  101. package/dist/assets/mips-CdjsipkG.js +0 -1
  102. package/dist/assets/msdax-CYqgjx_P.js +0 -1
  103. package/dist/assets/mysql-BHd6q0vd.js +0 -1
  104. package/dist/assets/objective-c-B1aVtJYH.js +0 -1
  105. package/dist/assets/pascal-BhNW15KB.js +0 -1
  106. package/dist/assets/pascaligo-5jv8CcQD.js +0 -1
  107. package/dist/assets/perl-DlYyT36c.js +0 -1
  108. package/dist/assets/pgsql-Dy0bjov7.js +0 -1
  109. package/dist/assets/php-120yhfDK.js +0 -1
  110. package/dist/assets/pla-CjnFlu4u.js +0 -1
  111. package/dist/assets/postiats-CQpG440k.js +0 -1
  112. package/dist/assets/powerquery-DdJtto1Z.js +0 -1
  113. package/dist/assets/protobuf-IBS6jZEB.js +0 -2
  114. package/dist/assets/pug-kFxLfcjb.js +0 -1
  115. package/dist/assets/qsharp-q7JyzKFN.js +0 -1
  116. package/dist/assets/r-BIFz-_sK.js +0 -1
  117. package/dist/assets/razor-DGf0KCTP.js +0 -1
  118. package/dist/assets/redis-CHOsPHWR.js +0 -1
  119. package/dist/assets/redshift-CBifECDb.js +0 -1
  120. package/dist/assets/restructuredtext-CghPJEOS.js +0 -1
  121. package/dist/assets/ruby-CYWGW-b1.js +0 -1
  122. package/dist/assets/rust-DMDD0SHb.js +0 -1
  123. package/dist/assets/sb-BYAiYHFx.js +0 -1
  124. package/dist/assets/scala-Bqvq8jcR.js +0 -1
  125. package/dist/assets/scheme-Dhb-2j9p.js +0 -1
  126. package/dist/assets/scss-CTwUZ5N7.js +0 -3
  127. package/dist/assets/solidity-CME5AdoB.js +0 -1
  128. package/dist/assets/sophia-RYC1BQQz.js +0 -1
  129. package/dist/assets/sparql-KEyrF7De.js +0 -1
  130. package/dist/assets/sql-BdTr02Mf.js +0 -1
  131. package/dist/assets/st-C7iG7M4S.js +0 -1
  132. package/dist/assets/swift-D7IUmUK8.js +0 -1
  133. package/dist/assets/systemverilog-DgMryOEJ.js +0 -1
  134. package/dist/assets/tcl-PloMZuKG.js +0 -1
  135. package/dist/assets/ts.worker-B8Ae6930.js +0 -51330
  136. package/dist/assets/tsMode-D4ZDTisA.js +0 -11
  137. package/dist/assets/twig-BfRIq3la.js +0 -1
  138. package/dist/assets/typescript-CJFgy1iR.js +0 -1
  139. package/dist/assets/typespec-CzxlYoT_.js +0 -1
  140. package/dist/assets/vb-BwAE3J76.js +0 -1
  141. package/dist/assets/wgsl-Dksx_ONF.js +0 -298
  142. package/dist/assets/yaml-B7iGwJkY.js +0 -1
@@ -0,0 +1 @@
1
+ import{f as ce,bh as ue,r as n,R as ge,u as he,U as be,bT as pe,bU as me,bV as ve,z as ye,bW as fe,bX as Se,bj as xe,W as Ne,bY as X,X as Pe,bZ as Te,bl as je,Y as H,Z as G,_ as we,$ as ke,a0 as Ce,b_ as Ae,b$ as Re,bN as Me,bO as Ie,c0 as L,a7 as $e,a8 as He,j as a,a9 as Fe,M as Le,m as Be,o as Oe,ab as qe,c1 as Ee,ad as Y,ae as Ue,af as We,ag as ze,c2 as F,ah as Ve,ai as De,c3 as Z,b8 as _e,b9 as Xe,ax as Ge,bx as Ye,aj as Ze,bg as Je,ay as Ke,t as w,B as Qe,C as et,bv as tt}from"./index-NW0Z4UWR.js";import{t as at,A as st,a as rt,N as ot}from"./AllOrNothingOption-C7wGq_-r.js";import{C as nt}from"./CodeView-C65Y5vXN.js";import"./multipart-Bd_eOd8a.js";const it=()=>({table:"",sourceId:null,navProperty:null,targets:[],targetNames:{},headers:Ze(),dirty:new Set});function bt({themeMode:l}){const v=ce("associate"),h=ue("associate",Z,it),[e,d]=n.useState(h.state),{table:k}=ge(e.table||null),{allEntities:B}=he(),[O,C]=n.useState("source"),[y,A]=n.useState("builder"),[q,R]=n.useState(null),[K,E]=n.useState(!1),[Q,ee]=be("associate"),[f,S]=n.useState(h.lastSavedId),[x,N]=n.useState(h.lastSavedHash),[U,M]=n.useState(""),b=n.useMemo(()=>pe(e),[e,k]),te=n.useMemo(()=>me(e),[e,k]),r=n.useMemo(()=>ve(e),[e,k]),P=ye(e.table),o=e.navProperty?P?.navigationProperties.find(t=>t.name===e.navProperty):void 0,T=o?fe(o):!1,c=T?"PATCH":"POST",p=!T&&Se(e.allOrNothing,r.length),I=t=>d(s=>{const i=new Set(s.dirty);return i.add(t),{...s,dirty:i}}),m=(t,s,i)=>{d($=>({...$,[t]:s})),i&&I(i)},j=xe([["Source record id",e.sourceId],...e.targets.map(t=>["Target record id",t])],[["Navigation property",e.navProperty]]),W=Ne([{when:!P,id:"assoc-table",title:"Pick a source table first.",focusNode:"source"},{when:!e.sourceId,id:"assoc-source",title:"Pick a source record.",focusNode:"source"},{when:!e.navProperty,id:"assoc-nav",title:"Pick a navigation property.",focusNode:"nav"},{when:e.targets.length===0,id:"assoc-targets",title:"Pick at least one target record.",focusNode:"targets"},{when:p&&r.length>X,id:"assoc-change-set-cap",title:`All or nothing sends at most ${X} requests in one change set; this has ${r.length}. Remove targets or turn it off.`,focusNode:"targets"},{when:e.headers.some(t=>t.enabled&&!t.name),id:"assoc-header-name",title:"Fix empty header name.",focusNode:"headers"},{when:j,id:"assoc-url-part",title:j??"",focusNode:j?.startsWith("Target")?"targets":j?.startsWith("Navigation")?"nav":"source"}]),ae=Pe(W),se=async()=>{E(!0);const t=await Xe.associate(e,Y(e.headers,null));R(t),E(!1),A("results"),ee(Ge({snapshot:u,modeId:"associate",url:b.relativeUrl,method:c,status:t.status,ms:t.ms,rowCount:F(t,r.length)??0,summary:`${F(t,r.length)??0} of ${r.length} linked`})),d(s=>({...s,dirty:new Set}))},u=n.useMemo(()=>Te(e),[e]);je("associate",u,f,x);const re=n.useMemo(()=>H(u),[u]),z=x===null?!0:re!==x,oe=t=>{S(t.id),N(H(t.state))},V=t=>{if(t.modeId!=="associate")return;const s=t.state;if(B.length>0&&!B.some(i=>i.logicalName===s.table)){_e(`Can't load "${t.name}": entity \`${s.table}\` isn't available in this environment. The solution may have been removed or you may be connected to a different org.`);return}d(Z(s)),S(t.id),N(H(s)),R(null),M(""),C("source")},ne=t=>{const s=Ye(t,"associate");if(!s)return;const i=f,$=x;V(s),S(i),N($)},D=G(oe),_=G(V);we(n.useMemo(()=>e.table?{state:u,modeId:"associate",dirty:z,lastSavedId:f,onSaved:D,onLoadSaved:_}:null,[u,z,f,e.table,D,_]));const ie=[{id:"source",label:"Target",meta:P?.displayName??"Pick a table",items:[{id:"source",icon:Ce,iconFilled:ke,label:e.sourceId?U||`${P?.displayName??""} (selected)`:"Pick a record",badge:o?c:null,badgeAppearance:"tint",badgeColor:"brand",dirty:e.dirty.has("source")}]},{id:"relationship",label:"Relationship",meta:o?J(o.cardinality):"pick one",items:[{id:"nav",icon:Re,iconFilled:Ae,label:o?o.name:"Navigation property",code:!!o,badge:o?J(o.cardinality):null,badgeAppearance:"ghost",dirty:e.dirty.has("nav")}]},{id:"targets",label:"Related",meta:e.targets.length?`${e.targets.length} target${e.targets.length===1?"":"s"}`:"none",items:[{id:"targets",icon:Ie,iconFilled:Me,label:at(T,e.targets.length),badge:e.targets.length||null,badgeAppearance:"tint",badgeColor:e.targets.length>0?"success":"subtle",dirty:e.dirty.has("targets")},...r.length>0?[{id:"preview",icon:L,iconFilled:L,label:`${r.length} request${r.length===1?"":"s"}${p?" · all or nothing":""}`,badge:r.length,badgeAppearance:"ghost"}]:[]]},{id:"headers",label:"Headers",meta:`${e.headers.filter(t=>t.enabled).length} active`,items:[{id:"headers",icon:He,iconFilled:$e,label:"HTTP headers",badge:e.headers.filter(t=>t.enabled).length||null,dirty:e.dirty.has("headers")}]}];let g;switch(O){case"source":g=a.jsx(qe,{table:e.table,onTableChange:t=>{d(s=>({...s,table:t,sourceId:null,navProperty:null,targets:[],targetNames:{},dirty:new Set(["source","nav","targets"])})),M(""),R(null),S(void 0),N(null)},recordId:e.sourceId,onRecordChange:(t,s)=>{m("sourceId",t,"source"),M(s??"")},group:"relate",sub:"Pick the source entity and the record that the relationship anchors on."});break;case"nav":g=a.jsx(ot,{table:e.table,value:e.navProperty,onChange:t=>{d(s=>({...s,navProperty:t,targets:[],targetNames:{}})),I("nav"),I("targets")},group:"relate",forOperation:"associate",footer:a.jsx(Le,{layout:"multiline",intent:"info",children:a.jsxs(Be,{children:[a.jsx(Oe,{children:"How cardinality drives the request"}),a.jsx("strong",{children:"Collection-valued"})," (1:N / N:N) → ",a.jsx("code",{children:"POST /…/$ref"})," with one request per target. ",a.jsx("strong",{children:"Single-valued"})," (N:1) →"," ",a.jsx("code",{children:"PATCH /source(id)"})," with body"," ",a.jsx("code",{children:'{ "<nav>@odata.bind": "<target-set>(<id>)" }'})," (one target). This is the docs-preferred shape — the URL bar verb updates automatically. The PATCH is sent with ",a.jsx("code",{children:"If-Match: *"}),", so a wrong source id fails with 404 instead of creating a record; Power Platform ToolBox asks you to approve that header once."," ",a.jsx("a",{href:"https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/associate-disassociate-entities-using-web-api",target:"_blank",rel:"noopener noreferrer",style:{color:"inherit"},children:"MS Learn ↗"})]})})});break;case"targets":g=a.jsx(st,{table:e.table,navProperty:e.navProperty,targets:e.targets,setTargets:t=>m("targets",t,"targets"),targetNames:e.targetNames,setTargetNames:t=>m("targetNames",t),group:"relate",resolvedMethod:o?c:null,changeSet:p,footer:o&&!T?a.jsx(rt,{checked:!!e.allOrNothing,onChange:t=>m("allOrNothing",t||void 0,"targets"),targets:e.targets.length,verb:"POST"}):void 0});break;case"preview":g=a.jsx(lt,{requests:r,changeSet:p});break;case"headers":g=a.jsx(Fe,{policy:"relate",items:e.headers,setItems:t=>m("headers",t,"headers"),group:"relate"});break}const le=Ee(c,Y(e.headers,null)),de={method:c,built:b,headers:le,body:te,entityLogical:b.entityLogical,multiRequests:r.length>1?r.map(t=>({method:t.method,relativeUrl:t.relativeUrl,body:t.body,description:`target ${t.targetId}`})):void 0,changeSet:p};return a.jsx(Ue,{sidebar:a.jsx(De,{type:v,urlPreview:b.relativeNoBase,sections:ie,activeNode:O,onSelect:t=>{C(t),A("builder")},recents:Q,onRecentClick:ne}),urlBar:a.jsx(Ve,{method:c,url:b.relativeUrl,executeVerb:v.executeVerb,writeConfirm:{operation:o?`Associate (${o.name})`:"Associate",table:e.table,scope:{kind:"records",count:Math.max(1,e.targets.length)},highImpact:e.targets.length>1},disabledReason:ae,loading:K,onExecute:se,advisories:W,onAdvisoryFocus:C}),children:a.jsxs(We,{tab:y,onTabChange:A,resultCount:F(q,r.length),children:[y==="builder"&&g,y==="code"&&a.jsx(nt,{themeMode:l,inputs:de}),y==="results"&&a.jsx(ze,{result:q,mode:"single",table:e.table,writeContext:{operation:"associate",table:e.table,recordId:e.sourceId,recordName:U||null,navProperty:e.navProperty??void 0,targetCount:e.targets.length,targetNames:e.targets.map(t=>e.targetNames[t]).filter(t=>!!t),targetNameById:e.targetNames}})]})})}function lt({requests:l,changeSet:v}){const h=Je();return a.jsxs("div",{children:[a.jsx(Ke,{icon:L,title:`Generated requests (${l.length})`,sub:v?"All or nothing: these requests go together as one $batch change set, so all succeed or none do.":"Each target queues a separate HTTP request. For large counts, prefer a $batch request.",group:"relate"}),a.jsxs("div",{className:tt(h.inlineCard),style:{padding:12,maxWidth:980,fontFamily:w.fontFamilyMonospace,fontSize:11},children:[l.map((e,d)=>a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"60px 1fr",gap:8,padding:"8px 0",borderBottom:d<l.length-1?`1px solid ${w.colorNeutralStroke3}`:"none"},children:[a.jsx(Qe,{appearance:"filled",color:e.method==="POST"?"success":"warning",style:{fontWeight:700,justifySelf:"start"},children:e.method}),a.jsxs("div",{style:{minWidth:0},children:[a.jsx("div",{style:{wordBreak:"break-all"},children:e.relativeUrl}),a.jsx("div",{style:{marginTop:4,color:w.colorNeutralForeground3},children:JSON.stringify(e.body)})]})]},e.targetId)),l.length===0&&a.jsx(et,{style:{color:w.colorNeutralForeground3,fontStyle:"italic",padding:"12px 4px",textAlign:"center",display:"block"},children:"No requests queued — pick at least one target on the Related pane."})]})]})}function J(l){switch(l){case"OneToMany":return"1:N";case"ManyToOne":return"N:1";case"ManyToMany":return"N:N"}}export{bt as AssociateMode};
@@ -0,0 +1,10 @@
1
+ import{aG as Mt,cb as Pt,K as ze,x as Ue,z as rt,ci as Nt,cc as At,cd as Dt,dO as Ft,dJ as _t,dH as Lt,dD as zt,dE as Ut,c8 as Wt,c5 as Ht,c1 as We,c3 as Gt,bV as Vt,bQ as Jt,bK as Kt,bL as Qt,dp as Xt,dm as Zt,di as Yt,dd as es,de as ts,d9 as ss,d1 as ns,d2 as os,c$ as rs,cX as as,aD as is,bw as ls,bi as cs,cT as ds,cK as us,eJ as hs,eK as ps,eL as ms,n as at,eM as fs,eN as gs,eO as ee,u as it,aZ as He,r as w,R as bs,bb as xs,eP as ys,c6 as vs,j as e,ay as he,cq as lt,aW as Se,s as C,eQ as ct,eR as dt,aT as ke,M as H,m as G,au as _,bc as be,bd as xe,av as U,t as j,T as ut,C as B,an as Ee,aU as ue,eS as ie,eT as Ce,eU as qe,br as js,bs as Ge,eI as Oe,aO as $s,o as re,eV as ws,eW as Ss,eX as ks,eY as Es,eZ as Rs,e_ as Ts,ak as Re,b3 as Is,cr as Cs,ao as qs,ap as Os,e$ as Bs,f0 as Ms,f1 as Ps,f2 as Ns,D as As,g as Ds,h as Fs,k as _s,l as Ls,bC as zs,at as Us,f as Te,q as Ws,bh as Hs,U as Gs,E as Ve,f3 as Vs,f4 as Js,f5 as Ks,cm as de,X as Qs,f6 as Xs,bl as Zs,Y as ye,Z as Je,cM as Ys,_ as en,f7 as tn,f8 as sn,f9 as nn,fa as on,cp as rn,b as Ke,ae as an,af as ln,ah as cn,ai as dn,fb as un,fc as Qe,fd as Xe,ax as hn,fe as pn}from"./index-NW0Z4UWR.js";import{e as ht,C as ve,a as mn,b as fn,m as Ze}from"./multipart-Bd_eOd8a.js";const je=t=>t.status>=400;function gn(t,n){const r=new Map,s=[];for(const p of n)p.contentId&&!r.has(p.contentId)?r.set(p.contentId,p):s.push(p);r.size===0&&s.length===t.items.length&&(t.items.forEach((p,x)=>r.set(p.contentId,s[x])),s.length=0);const u=n.some(je),i=t.transaction&&u,o=t.items.map(p=>{const x=r.get(p.contentId);return x?{itemId:p.item.id,contentId:p.contentId,outcome:i&&!je(x)?"rolled-back":"done",status:x.status,statusText:x.statusText,headers:x.headers,body:x.body}:{itemId:p.item.id,contentId:p.contentId,outcome:i?"rolled-back":"not-run"}}),b=s.find(je);return{items:o,segment:{transaction:t.transaction,contentIds:t.items.map(p=>p.contentId),ms:0,ok:!u&&o.every(p=>p.outcome==="done"),changesetError:b}}}function bn(t){const n=t.segments.some(x=>!x.skipped&&(!x.error||x.requestFailed)),r=t.items.length;let s=0,u=0,i=0,o=0,b=0;for(const x of t.items)x.outcome==="done"?(x.status??0)>=400?u++:s++:x.outcome==="rolled-back"?i++:x.outcome==="not-run"?o++:b++;const p=[`${r} request${r===1?"":"s"}`];return u&&p.push(`${u} failed`),i&&p.push(`${i} rolled back`),o&&p.push(`${o} not run`),b&&p.push(`${b} no result`),r>0&&s===r&&p.push("all succeeded"),{status:n?200:0,summary:p.join(" · "),succeeded:s}}const xn=/additional headers were rejected|header consent/i,pt=/invalid content id correlation|missing operation results/i,yn=/invalid content id correlation/i;function vn(t){return t.replace(/^\s*Error invoking remote method '[^']*':\s*/i,"").replace(/^(?:\w*Error:\s*)+/,"").trim()}function jn(t,n){const r=vn(t);return xn.test(r)?`Power Platform ToolBox didn’t send this batch because its request headers weren’t approved, so nothing reached Dataverse. Send again and allow the headers when ToolBox asks, or remove them. Host message: ${r}`:!n.transaction&&n.continueOnError&&yn.test(r)?`A request in this batch failed, and Power Platform ToolBox couldn’t read the continue-on-error response because more requests followed the failed one (a known ToolBox batch-parser bug). Dataverse still ran every request: the ones that succeeded were applied. To see each result, put requests that might fail last in the batch, or send them on their own. Host message: ${r}`:!n.transaction&&!n.continueOnError&&pt.test(r)?`A request failed and Dataverse stopped the batch there. Requests before it were applied; the rest didn’t run. This version of Power Platform ToolBox can’t return partial results without continue-on-error — turn on Continue on error to see each request’s result. Host message: ${r}`:r}async function $n(t,n){const r=performance.now(),s=[],u=[];let i=!1;for(const o of t){const b=o.items.map(h=>h.contentId);if(i){u.push({transaction:o.transaction,contentIds:b,ms:0,ok:!1,skipped:!0});for(const h of o.items)s.push({itemId:h.item.id,contentId:h.contentId,outcome:"not-run"});continue}const p=o.items.map(mt),x=!o.transaction&&n.continueOnError?{Prefer:"odata.continue-on-error"}:void 0,m=performance.now();try{const h=o.transaction?await ze.executeTransaction(p,x):await ze.executeBatch(p,x),l=gn(o,h);l.segment.ms=Math.round(performance.now()-m),u.push(l.segment),s.push(...l.items),!l.segment.ok&&!n.continueOnError&&(i=!0)}catch(h){const l=h instanceof Error?h.message:String(h);x||p.some(g=>g.headers&&Object.keys(g.headers).length),u.push({transaction:o.transaction,contentIds:b,ms:Math.round(performance.now()-m),ok:!1,requestFailed:pt.test(l),error:jn(l,{transaction:o.transaction,continueOnError:n.continueOnError})});for(const g of o.items)s.push({itemId:g.item.id,contentId:g.contentId,outcome:o.transaction?"rolled-back":"unknown"});n.continueOnError||(i=!0)}}return{ms:Math.round(performance.now()-r),ok:u.every(o=>o.ok),items:s,segments:u}}function mt(t){const n=t.wire,r={method:n.method,url:n.path,contentId:t.contentId};return Object.keys(n.headers).length>0&&(r.headers={...n.headers}),n.body!==void 0&&(r.body=n.body),r}function wn(){return Mt()?Pt()?null:"Sending a $batch requires Power Platform ToolBox 1.2.7 or later.":"Run Dataverse Request Studio inside Power Platform ToolBox to send a batch."}const Sn=new Set(["retrieve-multiple","retrieve-single","predefined-query","create","update","upsert","delete","merge","associate","disassociate","exec-action","exec-function","exec-workflow"]),kn=new Set(["authorization","accept","content-type","content-length","odata-version","odata-maxversion"]);function D(t){return Object.fromEntries(Object.entries(ms(t)).filter(([n])=>!kn.has(n.toLowerCase())))}function $e(t,n,r,s,u,i){return at("custom",{label:t,source:n,method:r,url:gs(s),body:i&&Object.keys(i).length>0?fs(i):i?"{}":"",headers:Object.entries(u).map(([o,b])=>({name:o,value:b,enabled:!0}))})}function En(t){const{name:n}=t,r=(s,u,i,o)=>u?{ok:!0,items:[$e(n,n,s,u,i,o)]}:{ok:!1,reason:"its table isn’t available on this connection"};try{switch(t.modeId){case"retrieve-multiple":{const s=hs(t.state);return r("GET",ps(s).relativeUrl,D(s))}case"retrieve-single":{const s=ds(t.state);return r("GET",us(s).relativeUrl,D(s))}case"predefined-query":{const s=ls(t.state);return r("GET",cs(s).relativeUrl,D(s))}case"create":{const s=rs(t.state);return r("POST",as(s).relativeUrl,D(s),is(s))}case"update":{const s=ss(t.state);return r(s.method,ns(s).relativeUrl,D(s),os(s))}case"upsert":{const s=Yt(t.state);return r("PATCH",es(s).relativeUrl,D(s),ts(s))}case"delete":{const s=Xt(t.state);return r("DELETE",Zt(s).relativeUrl,D(s))}case"merge":{const s=Jt(t.state);return r("POST",Kt(s).relativeUrl,D(s),Qt(s))}case"associate":{const s=Gt(t.state),u=D(s),i=Vt(s);return i.length===0?{ok:!1,reason:"the request is incomplete"}:{ok:!0,items:i.map(o=>$e(`${n} → ${o.targetId}`,n,o.method,o.relativeUrl,We(o.method,u),o.body))}}case"disassociate":{const s=Wt(t.state),u=D(s),i=Ht(s);return i.length===0?{ok:!1,reason:"the request is incomplete"}:{ok:!0,items:i.map(o=>$e(o.targetId?`${n} × ${o.targetId}`:n,n,o.method,o.relativeUrl,We(o.method,u),o.body))}}case"exec-action":{const s=Lt(t.state);return r("POST",zt(s).relativeUrl,D(s),Ut(s))}case"exec-function":{const s=Ft(t.state);return r("GET",_t(s).relativeUrl,D(s))}case"exec-workflow":{const s=Nt(t.state);return r("POST",At(s).relativeUrl,D(s),Dt(s))}default:return{ok:!1,reason:"file, image and attachment requests can’t be sent in a batch"}}}catch(s){return{ok:!1,reason:s instanceof Error?s.message:String(s)}}}function Rn(t){if(t&&typeof t=="object"&&"table"in t){const n=t.table;if(typeof n=="string")return n}return""}async function Tn(t){const n=Rn(t.state);n&&await Ue.getTable(n).catch(()=>{});const r=t.state?.navProperty;if(n&&typeof r=="string"&&r){const s=rt(n)?.navigationProperties.find(u=>u.name===r)?.targetEntity;s&&await Ue.getTable(s).catch(()=>{})}return En(t)}const ft={http:"HTTP ($batch)",fetch:"fetch (JavaScript)",python:"Python (requests)",pptb:"PPTB dataverseAPI"};function gt(t){const n=[];let r=null;for(const s of t)s.wire&&(s.group!==r&&n.push({atomic:s.group.atomic,parts:[]}),n[n.length-1].parts.push({contentId:s.contentId,wire:s.wire}),r=s.group);return n}function we(t,n){return["OData-MaxVersion: 4.0","OData-Version: 4.0","If-None-Match: null","Accept: application/json",`Content-Type: ${t}`,...n?["Prefer: odata.continue-on-error"]:[]]}const In=t=>t.replace(/\r\n/g,`
2
+ `);function Cn(t,n){const r=n.orgUrl||"[Organization URI]",s=ht(gt(n.items),n.boundaries);switch(t){case"http":return In([`POST ${r}${ee}/$batch HTTP/1.1`,...we(s.contentType,n.continueOnError),"",s.body].join(ve));case"fetch":{const u=s.body.split(ve);u[u.length-1]===""&&u.pop();const i=we(s.contentType,n.continueOnError).filter(o=>!o.startsWith("If-None-Match")).map(o=>{const b=o.indexOf(":");return` ${JSON.stringify(o.slice(0,b))}: ${JSON.stringify(o.slice(b+1).trim())},`});return["// Dataverse $batch — every line of the body must end in CRLF.","const body = [",...u.map(o=>` ${JSON.stringify(o)},`),"].join('\\r\\n') + '\\r\\n';","",`const res = await fetch(${JSON.stringify(`${r}${ee}/$batch`)}, {`," method: 'POST',"," headers: {"," Authorization: `Bearer ${accessToken}`,",...i," },"," body,","});","","// The response is multipart/mixed too: one part per request, change sets nested.","console.log(res.status, res.headers.get('Content-Type'));","console.log(await res.text());"].join(`
3
+ `)}case"python":{const u=s.body.split(ve);u[u.length-1]===""&&u.pop();const i=we(s.contentType,n.continueOnError).filter(o=>!o.startsWith("If-None-Match")).map(o=>{const b=o.indexOf(":");return` ${JSON.stringify(o.slice(0,b))}: ${JSON.stringify(o.slice(b+1).trim())},`});return["# Dataverse $batch — Python (requests). Every line of the body must end in CRLF.","# pip install requests and replace <access-token> with a bearer token.","","import requests","",'ACCESS_TOKEN = "<access-token>"',"",'body = "\\r\\n".join([',...u.map(o=>` ${JSON.stringify(o)},`),']) + "\\r\\n"',"","res = requests.post(",` ${JSON.stringify(`${r}${ee}/$batch`)},`," headers={",' "Authorization": "Bearer " + ACCESS_TOKEN,',...i.map(o=>` ${o}`)," },",' data=body.encode("utf-8"),'," timeout=120,",")","","# The response is multipart/mixed too: one part per request, change sets nested.",'print(res.status_code, res.headers.get("Content-Type"))',"print(res.text)"].join(`
4
+ `)}case"pptb":{if(n.plan.length===0)return"// Add a request to see the host calls.";const u=["// What Dataverse Request Studio sends through Power Platform ToolBox (1.2.7+).","// The host writes the multipart body; each change set is its own call."];return n.plan.length>1&&u.push(`// ${n.plan.length} calls, in order.${n.continueOnError?"":" A failed call stops the rest."}`),n.plan.forEach((i,o)=>{const b=i.items.filter(m=>m.wire).map(mt),p=i.transaction?"executeTransaction":"executeBatch",x=!i.transaction&&n.continueOnError?", undefined, { Prefer: 'odata.continue-on-error' }":"";u.push("",`const results${o+1} = await dataverseAPI.${p}(${JSON.stringify(b,null,2)}${x});`)}),u.push("","// Each result: { contentId, status, statusText, headers, body }"),u.join(`
5
+ `).replace(/\\r\\n/g,"\\n")}}}const qn=/^\{?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}?$/i,O=t=>JSON.stringify(t),X=t=>`new Guid(${O(t.replace(/[{}]/g,""))})`;function Y(t,n){return n.logicalOf(t)??t.replace(/s$/,"")}function On(t){const n=/^([A-Za-z_][\w]*)\(([^)]+)\)$/.exec(t.trim());return n?{set:n[1],id:n[2]}:null}function Bn(t,n,r,s,u){if(r===null)return"null";const i=s.attrType(t,n);switch(i){case"Picklist":case"State":case"Status":return`new OptionSetValue(${Number(r)})`;case"MultiSelectPicklist":return`new OptionSetValueCollection { ${String(r).split(",").filter(Boolean).map(o=>`new OptionSetValue(${Number(o)})`).join(", ")} }`;case"Money":return`new Money(${Number(r)}m)`;case"Decimal":return`${Number(r)}m`;case"BigInt":return`${Number(r)}L`;case"DateTime":return`DateTime.Parse(${O(String(r))})`;case"Uniqueidentifier":return X(String(r))}return typeof r=="string"?O(r):typeof r=="boolean"?String(r):typeof r=="number"?(i||u.push(`${n}: confirm the type (int / OptionSetValue / Money / decimal)`),String(r)):(u.push(`${n}: nested value not converted`),null)}function Mn(t,n,r,s){const u=[];for(const[i,o]of Object.entries(n)){if(i.endsWith("@odata.bind")){let p=i.slice(0,-11);if(!r.attrType(t,p)&&p.includes("_")){const m=p.slice(0,p.lastIndexOf("_"));r.attrType(t,m)&&(p=m)}const x=typeof o=="string"?On(o.replace(/^.*\/api\/data\/v[\d.]+\//,"")):null;typeof o=="string"&&/^\$\d+$/.test(o)?s.push(`${p}: ${o} referenced an earlier request — ExecuteMultiple has no Content-ID references; set the id returned by that request`):x?u.push(`[${O(p)}] = new EntityReference(${O(Y(x.set,r))}, ${X(x.id)}),`):s.push(`${p}: couldn't convert the @odata.bind value`);continue}if(i.includes("@"))continue;const b=Bn(t,i,o,r,s);b!==null&&u.push(`[${O(i)}] = ${b},`)}return u}function Ye(t){if(!t)return{};try{const n=JSON.parse(t);return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}catch{return{}}}const Pn=(t,n)=>t.map(r=>" ".repeat(n)+r);function et(t){return t?`new ColumnSet(${t.split(",").map(n=>O(n.trim().replace(/^_(.+)_value$/,"$1"))).join(", ")})`:"new ColumnSet(true)"}function Nn(t,n){const r=t.wire;if(!r)return[`// $${t.contentId}: has errors — fix it in the Builder.`];const s=[],u=[],i=t.item,o=`// $${t.contentId} ${r.method} ${r.path}`,b=m=>(u.push(o,...s.map(h=>`// TODO ${h}`),...m),u),p=qn.test(i.recordId.trim());if(i.op==="create"||i.op==="update"){const m=Y(i.entitySet,n);i.op==="update"&&!p&&s.push(`record id ${i.recordId} isn't a GUID — use new Entity(logicalName, keyAttributes) for an alternate key`);const h=i.op==="update"&&p?`new Entity(${O(m)}, ${X(i.recordId.trim())})`:`new Entity(${O(m)})`,l=Mn(m,Ye(r.body),n,s);return b([`requests.Add(new ${i.op==="create"?"CreateRequest":"UpdateRequest"}`,"{",` Target = ${h}`," {",...Pn(l,8)," },","});"])}if(i.op==="delete"){const m=Y(i.entitySet,n);return p||s.push(`record id ${i.recordId} isn't a GUID`),b([`requests.Add(new DeleteRequest { Target = new EntityReference(${O(m)}, ${X(i.recordId.trim())}) });`])}if(i.op==="retrieve"){const m=Y(i.entitySet,n),h=new URLSearchParams(i.query.trim().replace(/^\?/,"")),l=h.get("$select");if(i.recordId.trim())return b(["requests.Add(new RetrieveRequest","{",` Target = new EntityReference(${O(m)}, ${X(i.recordId.trim())}),`,` ColumnSet = ${et(l)},`,"});"]);const g=h.get("$top");for(const k of["$filter","$orderby","$expand","$apply","fetchXml"])h.get(k)&&s.push(`translate ${k} into the QueryExpression (or use FetchExpression)`);return b(["requests.Add(new RetrieveMultipleRequest","{",` Query = new QueryExpression(${O(m)})`," {",` ColumnSet = ${et(l)},`,...g?[` TopCount = ${Number(g)},`]:[]," },","});"])}if(i.op==="associate"){const m=Y(i.entitySet,n),h=Y(i.targetSet,n);return s.push("Relationship takes the relationship schema name — usually the navigation property name"),b(["requests.Add(new AssociateRequest","{",` Target = new EntityReference(${O(m)}, ${X(i.recordId.trim())}),`,` Relationship = new Relationship(${O(i.navProperty.trim())}),`,` RelatedEntities = new EntityReferenceCollection { new EntityReference(${O(h)}, ${X(i.targetId.trim())}) },`,"});"])}const x=/^(?:Microsoft\.Dynamics\.CRM\.)?([A-Za-z_][\w]*)$/.exec(r.path);if(r.method==="POST"&&x&&!n.logicalOf(x[1])){const m=Object.entries(Ye(r.body)).filter(([h])=>!h.includes("@"));return b([`requests.Add(new OrganizationRequest(${O(x[1])})`,"{"," Parameters ="," {",...m.map(([h,l])=>typeof l=="object"&&l!==null?` // TODO ${h}: convert ${JSON.stringify(l)}`:` [${O(h)}] = ${typeof l=="string"?O(l):String(l)},`)," },","});"])}return[o,"// No SDK request generated for this Web API call — add the matching OrganizationRequest."]}function An(t,n,r){return["// ExecuteMultiple (SDK for .NET). Microsoft.Xrm.Sdk + Microsoft.Xrm.Sdk.Messages + Microsoft.Xrm.Sdk.Query.","// Max 1000 requests per call; ExecuteMultiple is not transactional — use ExecuteTransactionRequest for all-or-nothing.","var requests = new OrganizationRequestCollection();","",...t.flatMap(u=>[...Nn(u,r),""]),"var executeMultiple = new ExecuteMultipleRequest","{"," Settings = new ExecuteMultipleSettings"," {",` ContinueOnError = ${n.continueOnError},`,` ReturnResponses = ${n.returnResponses},`," },"," Requests = requests,","};","","var response = (ExecuteMultipleResponse)service.Execute(executeMultiple);","","// With ReturnResponses = false only faults come back. RequestIndex is 0-based.","foreach (var item in response.Responses)","{"," if (item.Fault != null)",' Console.WriteLine($"Request {item.RequestIndex} failed: {item.Fault.Message}");'," else if (item.Response != null)",' Console.WriteLine($"Request {item.RequestIndex}: {item.Response.ResponseName}");',"}",'Console.WriteLine($"IsFaulted: {response.IsFaulted}");'].join(`
6
+ `)}const tt=[{id:"create",label:"Create (POST)"},{id:"update",label:"Update (PATCH)"},{id:"delete",label:"Delete (DELETE)"},{id:"retrieve",label:"Retrieve (GET)"},{id:"associate",label:"Associate (POST $ref)"},{id:"custom",label:"Custom request"}],Dn=["GET","POST","PATCH","PUT","DELETE"],Fn=[{name:"Prefer",value:"return=representation"},{name:"If-Match",value:"*"},{name:"MSCRM.SuppressDuplicateDetection",value:"false"}],z={fontFamily:j.fontFamilyMonospace,fontSize:12};function _n({item:t,contentId:n,group:r,groups:s,wire:u,issues:i,onChange:o,onRemove:b,onMove:p,onMoveToGroup:x}){const{entities:m,allEntities:h}=it(),l=He({value:t.url,onChange:f=>o({url:f}),mode:"url"}),g=He({value:t.query,onChange:f=>o({query:f}),mode:"query",entitySet:t.entitySet}),k=w.useMemo(()=>h.find(f=>f.entitySetName===t.entitySet.trim())?.logicalName??null,[h,t.entitySet]),{table:q}=bs(t.op==="associate"?k:null),W=xs(),P=w.useMemo(()=>ys(q?.navigationProperties??[],W).filter(vs),[q,W]),J=`drs-batch-sets-${t.id}`,M=`drs-batch-navs-${t.id}`,F=t.op!=="custom",L=t.op==="update"||t.op==="delete"||t.op==="associate",Z=t.op==="create"||t.op==="update"||t.op==="custom",K=s.indexOf(r),Q=(f,$)=>o({headers:t.headers.map((N,I)=>I===f?{...N,...$}:N)});return e.jsxs("div",{style:{maxWidth:860},children:[e.jsxs(he,{icon:lt,title:`Request $${n}`,sub:r.atomic?`In change set ${K+1} — rolls back with the rest of the change set if any request fails.`:`In group ${K+1} — independent; runs on its own.`,group:"batch",children:[e.jsx(Se,{content:"Move up",relationship:"label",children:e.jsx(C,{icon:e.jsx(ct,{}),appearance:"subtle",onClick:()=>p(-1)})}),e.jsx(Se,{content:"Move down",relationship:"label",children:e.jsx(C,{icon:e.jsx(dt,{}),appearance:"subtle",onClick:()=>p(1)})}),e.jsx(C,{icon:e.jsx(ke,{}),appearance:"subtle",onClick:b,children:"Remove"})]}),i.length>0&&e.jsx(H,{intent:i.some(f=>f.severity==="error")?"error":"warning",layout:"multiline",style:{marginBottom:12},children:e.jsx(G,{children:i.map((f,$)=>e.jsx("div",{children:f.message},$))})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:12},children:[e.jsx(_,{label:"Operation",children:e.jsx(be,{value:tt.find(f=>f.id===t.op)?.label??"",selectedOptions:[t.op],onOptionSelect:(f,$)=>{const N=$.optionValue,I={op:N};(N==="create"||N==="update")&&!t.body.trim()&&(I.body=`{
7
+
8
+ }`),o(I)},children:tt.map(f=>e.jsx(xe,{value:f.id,children:f.label},f.id))})}),s.length>1&&e.jsx(_,{label:"Group",children:e.jsx(be,{value:`${r.atomic?"Change set":"Independent"} ${K+1}`,selectedOptions:[r.id],onOptionSelect:(f,$)=>$.optionValue&&x($.optionValue),children:s.map((f,$)=>e.jsx(xe,{value:f.id,children:`${f.atomic?"Change set":"Independent"} ${$+1}`},f.id))})}),e.jsx(_,{label:"Label (optional)",children:e.jsx(U,{value:t.label,onChange:(f,$)=>o({label:$.value})})})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:12,marginTop:12},children:[t.op==="custom"&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Method",children:e.jsx(be,{value:t.method,selectedOptions:[t.method],onOptionSelect:(f,$)=>o({method:$.optionValue}),children:Dn.map(f=>e.jsx(xe,{value:f,children:f},f))})}),e.jsx(_,{label:`URL (relative to ${ee}/)`,hint:"e.g. WhoAmI, accounts?$top=5, $1/primarycontactid/$ref",style:{gridColumn:"span 2"},children:e.jsx(U,{value:t.url,...l.fieldProps,input:{style:z}})}),l.list]}),F&&e.jsx(_,{label:t.op==="associate"?"Source table (entity set)":"Table (entity set)",children:e.jsx(U,{value:t.entitySet,onChange:(f,$)=>o({entitySet:$.value}),placeholder:"accounts",input:{list:J,style:z}})}),(L||t.op==="retrieve")&&e.jsx(_,{label:t.op==="retrieve"?"Record id (optional)":"Record id",hint:t.op==="retrieve"?void 0:"GUID, alternate key, or $n for a record created earlier in this change set",children:e.jsx(U,{value:t.recordId,onChange:(f,$)=>o({recordId:$.value}),placeholder:"00000000-0000-0000-0000-000000000000",input:{style:z}})}),t.op==="retrieve"&&e.jsx(_,{label:"Query options",hint:"Without the leading ?",children:e.jsx(U,{value:t.query,...g.fieldProps,placeholder:"$select=name&$top=10",input:{style:z}})}),t.op==="retrieve"&&g.list,t.op==="associate"&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Navigation property (collection-valued)",children:e.jsx(U,{value:t.navProperty,onChange:(f,$)=>o({navProperty:$.value}),placeholder:"contact_customer_accounts",input:{list:M,style:z}})}),e.jsx(_,{label:"Target table (entity set)",children:e.jsx(U,{value:t.targetSet,onChange:(f,$)=>o({targetSet:$.value}),placeholder:"contacts",input:{list:J,style:z}})}),e.jsx(_,{label:"Target record id",hint:"GUID or $n",children:e.jsx(U,{value:t.targetId,onChange:(f,$)=>o({targetId:$.value}),input:{style:z}})})]})]}),e.jsx("datalist",{id:J,children:m.map(f=>e.jsx("option",{value:f.entitySetName,children:f.displayName},f.logicalName))}),e.jsx("datalist",{id:M,children:P.map(f=>e.jsx("option",{value:f.name,children:f.targetEntity},f.name))}),Z&&e.jsx(_,{label:"Body (JSON)",hint:r.atomic?'Reference a record created earlier in this change set with "$n", e.g. "primarycontactid@odata.bind": "$1".':void 0,style:{marginTop:12},children:e.jsx(ut,{value:t.body,onChange:(f,$)=>o({body:$.value}),resize:"vertical",rows:8,textarea:{style:z,spellCheck:!1}})}),e.jsxs("div",{style:{marginTop:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6,flexWrap:"wrap"},children:[e.jsx("strong",{style:{fontSize:13},children:"Request headers"}),e.jsx(B,{style:{color:j.colorNeutralForeground3},children:"Sent inside this part. Power Platform ToolBox asks you to approve them the first time."})]}),t.headers.map((f,$)=>e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:6,alignItems:"center"},children:[e.jsx(Ee,{checked:f.enabled,onChange:(N,I)=>Q($,{enabled:I.checked}),"aria-label":`Send ${f.name||"header"}`}),e.jsx(U,{value:f.name,onChange:(N,I)=>Q($,{name:I.value}),placeholder:"Name","aria-label":"Header name",input:{style:z},style:{flex:"1 1 0",minWidth:0}}),e.jsx(U,{value:f.value,onChange:(N,I)=>Q($,{value:I.value}),placeholder:"Value","aria-label":"Header value",input:{style:z},style:{flex:"2 1 0",minWidth:0}}),e.jsx(C,{icon:e.jsx(ke,{}),appearance:"subtle","aria-label":"Remove header",onClick:()=>o({headers:t.headers.filter((N,I)=>I!==$)})})]},$)),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx(C,{size:"small",icon:e.jsx(ue,{}),onClick:()=>o({headers:[...t.headers,{name:"",value:"",enabled:!0}]}),children:"Header"}),Fn.filter(f=>!t.headers.some($=>$.name.toLowerCase()===f.name.toLowerCase())).map(f=>e.jsxs(C,{size:"small",appearance:"subtle",onClick:()=>o({headers:[...t.headers,{...f,enabled:!0}]}),children:["+ ",f.name,": ",f.value]},f.name))]})]}),u&&e.jsxs("div",{style:{marginTop:16},children:[e.jsx("strong",{style:{fontSize:13},children:"Part preview"}),e.jsx("pre",{style:{...z,background:j.colorNeutralBackground1,border:`1px solid ${j.colorNeutralStroke2}`,borderRadius:4,padding:10,marginTop:6,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:mn({contentId:n,wire:u}).replace(/\r\n/g,`
9
+ `)})]}),t.source&&e.jsxs(B,{style:{color:j.colorNeutralForeground3},children:["From: ",t.source]})]})}const Ln=[{id:"create",label:"Create"},{id:"update",label:"Update"},{id:"delete",label:"Delete"},{id:"retrieve",label:"Retrieve"},{id:"associate",label:"Associate"},{id:"custom",label:"Custom request"}];function zn({onAdd:t,label:n="Add request",disabledGet:r}){return e.jsxs(Ss,{children:[e.jsx(ks,{disableButtonEnhancement:!0,children:e.jsx(C,{icon:e.jsx(ue,{}),children:n})}),e.jsx(Es,{children:e.jsx(Rs,{children:Ln.filter(s=>!(r&&s.id==="retrieve")).map(s=>e.jsx(Ts,{onClick:()=>t(s.id),children:s.label},s.id))})})]})}function Un({groups:t,continueOnError:n,setContinueOnError:r,plan:s,unavailable:u,needsConsent:i,orgUrl:o,onAddGroup:b,onOpenSaved:p,onAddLast:x,lastLabel:m,onSelect:h,notice:l,variant:g="batch",returnResponses:k=!0,setReturnResponses:q}){const W=t.reduce((M,F)=>M+F.items.length,0),P=g==="execute-multiple";let J=0;return e.jsxs("div",{style:{maxWidth:860},children:[e.jsx(he,{icon:$s,title:P?"ExecuteMultiple":"$batch request",sub:P?"Up to 1,000 independent requests in one call, with the SDK’s ContinueOnError and ReturnResponses settings.":"Up to 1,000 requests in one POST to /$batch. Requests in a change set succeed or roll back together.",group:"batch"}),P&&e.jsx(H,{intent:"info",layout:"multiline",style:{marginBottom:12},children:e.jsxs(G,{children:[e.jsx(re,{children:"Sent as a Web API $batch"}),"ExecuteMultiple is an SDK for .NET (Organization service) message; the Web API has no ExecuteMultiple action. Its Web API equivalent is a ",e.jsx("code",{children:"$batch"})," of independent requests, which is what DRS sends. ContinueOnError maps to"," ",e.jsx("code",{children:"Prefer: odata.continue-on-error"}),"; ReturnResponses = false shows only the faults, as ExecuteMultipleResponse does. The Code tab has the ExecuteMultipleRequest (C#). For all-or-nothing, use the $batch Request mode’s change sets (ExecuteTransaction)."]})}),u&&e.jsx(H,{intent:"warning",layout:"multiline",style:{marginBottom:12},children:e.jsxs(G,{children:[e.jsx(re,{children:"Can’t send from here"}),u," You can still compose the batch and copy it from the Code tab."]})}),l&&e.jsx(H,{intent:"info",layout:"multiline",style:{marginBottom:12},children:e.jsx(G,{children:l})}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:16},children:[P?t[0]&&e.jsx(C,{icon:e.jsx(ue,{}),onClick:()=>h(`group:${t[0].id}`),children:"Add request"}):e.jsxs(e.Fragment,{children:[e.jsx(C,{icon:e.jsx(Ce,{}),onClick:()=>b(!0),children:"Add change set"}),e.jsx(C,{icon:e.jsx(qe,{}),onClick:()=>b(!1),children:"Add independent group"})]}),e.jsx(C,{icon:e.jsx(ue,{}),onClick:p,children:"Add from Saved…"}),e.jsx(C,{icon:e.jsx(ws,{}),onClick:x,disabled:!m,children:m?`Add last request (${m})`:"Add last request"})]}),e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"flex-start",padding:12,border:`1px solid ${j.colorNeutralStroke2}`,borderRadius:6,background:j.colorNeutralBackground1,marginBottom:16},children:[e.jsx(Ee,{checked:n,onChange:(M,F)=>r(F.checked),"aria-label":"Continue on error"}),e.jsxs("div",{children:[e.jsx("strong",{children:P?"ContinueOnError":"Continue on error"})," ",e.jsx("code",{style:{fontSize:12},children:"Prefer: odata.continue-on-error"}),e.jsx(B,{block:!0,style:{color:j.colorNeutralForeground3},children:P?"False: processing stops at the first fault; the rest don’t run. True: every request runs and each fault is reported. Requests that already ran aren’t undone either way.":"Off: Dataverse stops at the first failed request or change set. On: it runs the rest and returns every result. A change set is all-or-nothing either way."})]})]}),P&&q&&e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"flex-start",padding:12,border:`1px solid ${j.colorNeutralStroke2}`,borderRadius:6,background:j.colorNeutralBackground1,marginBottom:16},children:[e.jsx(Ee,{checked:k,onChange:(M,F)=>q(F.checked),"aria-label":"ReturnResponses"}),e.jsxs("div",{children:[e.jsx("strong",{children:"ReturnResponses"}),e.jsx(B,{block:!0,style:{color:j.colorNeutralForeground3},children:"True: a response for every request. False: only the faults, which is what you want for bulk loads. A $batch always returns every response; DRS filters the Results the same way and sets it in the C#."})]})]}),i&&e.jsx(H,{intent:"info",layout:"multiline",style:{marginBottom:12},children:e.jsxs(G,{children:[e.jsx(re,{children:"Headers need your approval in Power Platform ToolBox"}),"This batch sends request headers (per-request headers or continue-on-error). If you haven’t approved additional request headers for this tool yet, ToolBox asks first; if you reject, nothing is sent."]})}),s.length>1&&e.jsx(H,{intent:"info",layout:"multiline",style:{marginBottom:12},children:e.jsxs(G,{children:[e.jsxs(re,{children:["Sent as ",s.length," host calls"]}),"Power Platform ToolBox sends one change set or one run of independent requests per call, so this batch goes out as ",s.length," $batch requests in order (",s.map(M=>M.transaction?"change set":"independent").join(" → "),"). Each change set is still atomic.",n?"":" A failed call stops the ones after it."," The Code tab shows the single-envelope form for other clients."]})}),e.jsxs("div",{style:{fontSize:13,marginBottom:8},children:[e.jsxs("strong",{children:[W," request",W===1?"":"s"]})," ","in ",t.length," group",t.length===1?"":"s"]}),t.map((M,F)=>e.jsxs("div",{style:{border:`1px solid ${j.colorNeutralStroke2}`,borderLeft:`3px solid ${M.atomic?"var(--color-request-batch)":j.colorNeutralStroke1}`,borderRadius:6,padding:"8px 12px",marginBottom:8,background:j.colorNeutralBackground1},children:[e.jsx(C,{appearance:"transparent",onClick:()=>h(`group:${M.id}`),style:{padding:0},children:e.jsx("strong",{children:P?"Requests":M.atomic?`Change set ${F+1}`:`Independent group ${F+1}`})}),M.items.length===0&&e.jsx(B,{block:!0,style:{color:j.colorNeutralForeground3},children:"Empty — skipped when sent."}),M.items.map(L=>{J+=1;const Z=ie(L,o);return e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>h(`item:${L.id}`),onKeyDown:K=>(K.key==="Enter"||K.key===" ")&&h(`item:${L.id}`),style:{display:"flex",gap:8,alignItems:"center",padding:"3px 0",cursor:"pointer"},children:[e.jsxs("code",{style:{width:36,color:j.colorNeutralForeground3},children:["$",J]}),e.jsx(Oe,{method:Z.method,size:"sm"}),e.jsx("code",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Z.path||"—"}),L.label&&e.jsx(B,{style:{color:j.colorNeutralForeground3},children:L.label})]},L.id)})]},M.id))]})}function Wn({group:t,index:n,count:r,contentIdOf:s,orgUrl:u,onSetAtomic:i,onAdd:o,onRemoveGroup:b,onMoveGroup:p,onSelect:x,variant:m="batch"}){const h=t.items.some(g=>ie(g,u).method==="GET"),l=m==="execute-multiple";return e.jsxs("div",{style:{maxWidth:860},children:[e.jsx(he,{icon:t.atomic?Ce:qe,title:l?"Requests":t.atomic?`Change set ${n+1}`:`Independent group ${n+1}`,sub:l?"ExecuteMultiple runs each request on its own, in order. It isn’t transactional.":t.atomic?"Atomic: if any request fails, Dataverse rolls back the whole change set. GET isn’t allowed here.":"Each request runs on its own; a failure doesn’t undo the others.",group:"batch",children:!l&&e.jsxs(e.Fragment,{children:[e.jsx(C,{icon:e.jsx(ct,{}),appearance:"subtle","aria-label":"Move group up",disabled:n===0,onClick:()=>p(-1)}),e.jsx(C,{icon:e.jsx(dt,{}),appearance:"subtle","aria-label":"Move group down",disabled:n===r-1,onClick:()=>p(1)}),e.jsx(C,{icon:e.jsx(ke,{}),appearance:"subtle",onClick:b,children:"Remove group"})]})}),e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:16,flexWrap:"wrap"},children:[!l&&e.jsxs(js,{ariaLabel:"Group kind",children:[e.jsx(Ge,{checked:t.atomic,onClick:()=>i(!0),children:"Change set (atomic)"}),e.jsx(Ge,{checked:!t.atomic,onClick:()=>i(!1),children:"Independent"})]}),e.jsx(zn,{onAdd:o,disabledGet:t.atomic})]}),t.atomic&&h&&e.jsx(H,{intent:"error",style:{marginBottom:12},children:e.jsx(G,{children:"This change set holds a GET request. Move it to an independent group."})}),t.items.length===0&&e.jsx(B,{style:{color:j.colorNeutralForeground3},children:"No requests yet."}),t.items.map(g=>{const k=ie(g,u);return e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>x(`item:${g.id}`),onKeyDown:q=>(q.key==="Enter"||q.key===" ")&&x(`item:${g.id}`),style:{display:"flex",gap:8,alignItems:"center",padding:"6px 8px",borderBottom:`1px solid ${j.colorNeutralStroke3}`,cursor:"pointer"},children:[e.jsxs("code",{style:{width:36,color:j.colorNeutralForeground3},children:["$",s(g.id)]}),e.jsx(Oe,{method:k.method,size:"sm"}),e.jsx("code",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.path||"—"}),g.label&&e.jsx(B,{style:{color:j.colorNeutralForeground3},children:g.label})]},g.id)})]})}const ae={fontFamily:j.fontFamilyMonospace,fontSize:12};function st(t){return t.outcome!=="done"?t.outcome==="rolled-back"?"warning":"info":t.status===void 0?"info":t.status>=400?"danger":"success"}function Ie(t){if(t&&typeof t=="object"&&"error"in t){const n=t.error;if(n?.message)return n.code?`${n.code}: ${n.message}`:n.message}return null}function nt({r:t}){const n=Ie(t.body),r=t.headers?.["odata-entityid"]??t.headers?.["OData-EntityId"],s=t.outcome==="rolled-back"?"Rolled back":t.outcome==="not-run"?"Not run":t.outcome==="unknown"?"No result":null;return e.jsxs("details",{style:{borderBottom:`1px solid ${j.colorNeutralStroke3}`,padding:"6px 4px"},children:[e.jsxs("summary",{style:{display:"flex",gap:8,alignItems:"center",cursor:"pointer",listStyle:"none"},children:[e.jsxs("code",{style:{width:40,color:j.colorNeutralForeground3},children:["$",t.contentId]}),t.method&&e.jsx(Oe,{method:t.method,size:"sm"}),e.jsxs("code",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[t.label?`${t.label} — `:"",t.path??""]}),s&&t.status===void 0?e.jsx(Re,{status:st(t),code:s}):e.jsx(Re,{status:st(t),code:t.status!==void 0&&t.status<300?t.status:`${t.status??"—"}${t.statusText&&(t.status??0)>=300?` ${t.statusText}`:""}`}),s&&t.status!==void 0&&e.jsx(B,{children:s})]}),e.jsxs("div",{style:{padding:"8px 0 4px 48px"},children:[n&&e.jsx(H,{intent:"error",layout:"multiline",style:{marginBottom:8},children:e.jsx(G,{children:n})}),r&&e.jsxs("div",{style:{...ae,marginBottom:6},children:["OData-EntityId: ",e.jsx("code",{children:r})]}),t.headers&&Object.keys(t.headers).length>0&&e.jsx("pre",{style:{...ae,margin:"0 0 8px",whiteSpace:"pre-wrap"},children:Object.entries(t.headers).map(([u,i])=>`${u}: ${i}`).join(`
10
+ `)}),t.body!==void 0&&e.jsx("pre",{style:{...ae,margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all",background:j.colorNeutralBackground1,border:`1px solid ${j.colorNeutralStroke2}`,borderRadius:4,padding:8,maxHeight:360,overflow:"auto"},children:typeof t.body=="string"?t.body:JSON.stringify(t.body,null,2)}),t.body===void 0&&t.outcome==="done"&&e.jsx(B,{style:{color:j.colorNeutralForeground3},children:"No response body."}),t.outcome==="rolled-back"&&e.jsx(B,{block:!0,style:{color:j.colorNeutralForeground3},children:"The change set failed, so Dataverse undid this request with the rest of it."}),t.outcome==="unknown"&&e.jsx(B,{block:!0,style:{color:j.colorNeutralForeground3},children:"The host call failed as a whole (see the message above), so there’s no result for this request."}),t.outcome==="not-run"&&e.jsx(B,{block:!0,style:{color:j.colorNeutralForeground3},children:"An earlier failure stopped the batch before this request ran."})]})]})}function Hn({run:t,rows:n,extraTitle:r}){const[s,u]=w.useState(""),[i,o]=w.useState(null),[b,p]=w.useState(null),x=()=>{try{o(fn(s)),p(null)}catch(l){o(null),p(l instanceof Error?l.message:String(l))}},m=(t?.items??[]).reduce((l,g)=>(g.outcome==="done"&&g.status!==void 0&&g.status<400?l.ok+=1:g.outcome==="done"?l.failed+=1:g.outcome==="unknown"?l.noResult+=1:l.other+=1,l),{ok:0,failed:0,other:0,noResult:0}),h=l=>!!l.requestFailed&&l.contentIds.every(g=>n.find(k=>k.contentId===g)?.outcome==="unknown");if(t){const l=new Map(n.map(g=>[g.contentId,g]));for(const g of t.segments){if(!g.changesetError&&!g.requestFailed)continue;!g.contentIds.some(q=>{const W=l.get(q);return W?.outcome==="done"&&(W.status??0)>=400})&&m.other>0&&(m.failed+=1,m.other-=1)}}return e.jsxs("div",{style:{maxWidth:1e3},children:[t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginBottom:12,flexWrap:"wrap"},children:[e.jsx(Re,{status:t.ok?"success":"danger",code:t.ok?200:"Failed",ms:t.ms}),e.jsxs("span",{style:{fontSize:13},children:[m.ok," succeeded · ",m.failed," failed",m.other?` · ${m.other} rolled back or not run`:"",m.noResult?` · ${m.noResult} no result`:"",t.segments.length>1?` · ${t.segments.length} host calls`:""]}),r&&e.jsx(B,{children:r})]}),t.segments.map((l,g)=>l.error||l.changesetError?e.jsx(H,{intent:"error",layout:"multiline",style:{marginBottom:8},children:e.jsxs(G,{children:[e.jsxs(re,{children:[h(l)?"No results for ":"",l.transaction?"Change set":"Requests"," $",l.contentIds[0],l.contentIds.length>1?`–$${l.contentIds[l.contentIds.length-1]}`:"",h(l)?"":" failed"]}),l.error??`${l.changesetError.status} ${l.changesetError.statusText??""} — ${Ie(l.changesetError.body)??"see the response body below"}`,l.changesetError?.body!==void 0&&!Ie(l.changesetError.body)&&e.jsx("pre",{style:{...ae,whiteSpace:"pre-wrap"},children:JSON.stringify(l.changesetError.body,null,2)})]})},g):null),e.jsx("div",{style:{background:j.colorNeutralBackground1,border:`1px solid ${j.colorNeutralStroke2}`,borderRadius:6,padding:"0 8px"},children:n.map(l=>e.jsx(nt,{r:l},l.key))})]}):e.jsx(B,{block:!0,style:{color:j.colorNeutralForeground3,marginBottom:16},children:"Send the batch to see each request’s status, headers and body here."}),e.jsxs("details",{style:{marginTop:24},children:[e.jsxs("summary",{style:{cursor:"pointer",fontSize:13},children:[e.jsx(Is,{style:{verticalAlign:"middle",marginRight:6}}),"Inspect a raw $batch response from another client"]}),e.jsxs("div",{style:{marginTop:8},children:[e.jsx(ut,{value:s,onChange:(l,g)=>u(g.value),placeholder:"--batchresponse_…",rows:8,resize:"vertical",textarea:{style:ae,spellCheck:!1},style:{width:"100%"},"aria-label":"Raw $batch response"}),e.jsx(C,{style:{marginTop:8},onClick:x,disabled:!s.trim(),children:"Parse response"}),b&&e.jsx(H,{intent:"error",style:{marginTop:8},children:e.jsx(G,{children:b})}),i&&e.jsx("div",{style:{marginTop:8},children:i.map((l,g)=>e.jsx(nt,{r:{key:String(g),contentId:l.contentId??String(g+1),label:l.changeset!==void 0?`change set ${l.changeset+1}`:void 0,outcome:"done",status:l.status,statusText:l.statusText,headers:l.headers,body:l.body}},g))})]})]})]})}function ot({formats:t,labels:n,generate:r,note:s,crlfFormats:u=["http"]}){const[i,o]=w.useState(t[0]),[b,p]=w.useState(!1),x=r(i);return e.jsxs("div",{children:[e.jsx(he,{icon:Cs,title:"Code",sub:s,group:"batch",children:e.jsx(Se,{content:"Copy",relationship:"label",children:e.jsx(C,{icon:e.jsx(Os,{}),appearance:"subtle",onClick:()=>{qs(x,"the code",{toastOnSuccess:!1}).then(m=>{m&&(p(!0),setTimeout(()=>p(!1),1500))})},children:b?"Copied":"Copy"})})}),e.jsx(Bs,{selectedValue:i,onTabSelect:(m,h)=>o(h.value),size:"small",children:t.map(m=>e.jsx(Ms,{value:m,children:n[m]},m))}),e.jsx("pre",{style:{fontFamily:j.fontFamilyMonospace,fontSize:12,lineHeight:1.5,background:j.colorNeutralBackground1,border:`1px solid ${j.colorNeutralStroke2}`,borderRadius:6,padding:12,marginTop:8,whiteSpace:"pre",overflow:"auto",maxHeight:"calc(100vh - 260px)"},children:x}),u.includes(i)&&e.jsx(B,{style:{color:j.colorNeutralForeground3},children:"Line breaks in a $batch body are CRLF on the wire."})]})}function Gn({open:t,onClose:n,onAdd:r}){const{saved:s}=Ps(),[u,i]=w.useState(new Set),[o,b]=w.useState(""),p=Ns(),x=w.useMemo(()=>s.filter(h=>Sn.has(h.modeId)&&(!h.orgScope||h.orgScope===p)).filter(h=>!o.trim()||h.name.toLowerCase().includes(o.trim().toLowerCase())).sort((h,l)=>l.savedAt-h.savedAt),[s,p,o]),m=()=>{i(new Set),b(""),n()};return e.jsx(As,{open:t,onOpenChange:(h,l)=>!l.open&&m(),children:e.jsx(Ds,{style:{maxWidth:640},children:e.jsxs(Fs,{children:[e.jsx(_s,{children:"Add saved requests to the batch"}),e.jsxs(Ls,{children:[e.jsx(U,{value:o,onChange:(h,l)=>b(l.value),placeholder:"Filter by name",contentBefore:e.jsx(zs,{}),style:{width:"100%",marginBottom:8},"aria-label":"Filter saved requests"}),x.length===0&&e.jsx(B,{block:!0,style:{color:j.colorNeutralForeground3,padding:"12px 0"},children:"No saved requests on this connection that can go in a batch. Save a request from a Read, Write, Relate or Execute mode first."}),e.jsx("div",{style:{maxHeight:360,overflowY:"auto"},children:x.map(h=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:4},children:e.jsx(Us,{checked:u.has(h.id),onChange:(l,g)=>i(k=>{const q=new Set(k);return g.checked?q.add(h.id):q.delete(h.id),q}),label:e.jsxs("span",{children:[h.name," ",e.jsx(B,{style:{color:j.colorNeutralForeground3},children:Te(h.modeId).name})]})})},h.id))})]}),e.jsxs(Ws,{children:[e.jsx(C,{appearance:"secondary",onClick:m,children:"Cancel"}),e.jsxs(C,{appearance:"primary",disabled:u.size===0,onClick:()=>{r(x.filter(h=>u.has(h.id))),m()},children:["Add ",u.size||""]})]})]})})})}const Vn=["http","fetch","python","pptb"],Jn=["csharp","http","python","pptb"],Kn={...ft,csharp:"ExecuteMultipleRequest (C#)",http:"Web API equivalent ($batch)",python:"Web API equivalent (Python)"},Qn=new Set(["bulk-delete","bulk-write","batch","execute-multiple"]);function Yn({themeMode:t,variant:n="batch"}){const r=n==="execute-multiple",s=r?"execute-multiple":"batch",u=Te(s),i=Hs(s,Xe,r?un:Qe),[o,b]=w.useState(i.state),p=o.returnResponses??!0,{allEntities:x}=it(),[m,h]=w.useState("overview"),[l,g]=w.useState("builder"),[k,q]=w.useState(null),[W,P]=w.useState(!1),[J,M]=Gs(s),[F,L]=w.useState(!1),[Z,K]=w.useState(null),[Q,f]=w.useState(i.lastSavedId),[$,N]=w.useState(i.lastSavedHash),I=Ve.host?`https://${Ve.host}`:"",R=w.useMemo(()=>Vs(o.groups,I),[o.groups,I]),le=w.useMemo(()=>Js(R.items),[R]),te=wn(),bt=w.useMemo(()=>{const a=R.items.length,c=R.items.filter(d=>d.wire&&d.wire.method!=="GET").length;return c===0?null:{operation:u.name,scope:{kind:"text",text:`${a} request${a===1?"":"s"}, ${c} of them change${c===1?"s":""} data`,count:c},highImpact:!0,confirmWord:u.id==="execute-multiple"?"ExecuteMultiple":"batch"}},[R,u.id,u.name]),pe=(a,c)=>{const d=new Set(a.dirty);return d.add(c),{...a,dirty:d}},V=w.useCallback((a,c="batch")=>b(d=>pe({...d,groups:a(d.groups)},c)),[]),xt=(a,c)=>V(d=>d.map(y=>({...y,items:y.items.map(v=>v.id===a?{...v,...c}:v)})),`item:${a}`),Be=(a,c,d=!0)=>{c.length!==0&&(V(y=>{let v=y.find(T=>T.id===a);const S=c.some(T=>ie(T,I).method==="GET");if((!v||v.atomic&&S)&&(v=[...y].reverse().find(T=>S?!T.atomic:!0)),!v){const T=Ke(!S,c);return[...y,T]}const E=v.id;return y.map(T=>T.id===E?{...T,items:[...T.items,...c]}:T)}),d&&(h(`item:${c[0].id}`),g("builder")))},yt=a=>{for(const c of o.groups){const d=c.items.find(y=>y.id===a);if(d)return{group:c,item:d}}return null},vt=(a,c)=>V(d=>{const y=d.findIndex(A=>A.items.some(Bt=>Bt.id===a));if(y<0)return d;const v=d[y].items,S=v.findIndex(A=>A.id===a),E=d.map(A=>({...A,items:[...A.items]})),T=S+c;if(T>=0&&T<v.length)[E[y].items[S],E[y].items[T]]=[E[y].items[T],E[y].items[S]];else if(d[y+c]){const[A]=E[y].items.splice(S,1);c<0?E[y-1].items.push(A):E[y+1].items.unshift(A)}return E}),jt=(a,c)=>V(d=>{const y=d.flatMap(v=>v.items).find(v=>v.id===a);return y?d.map(v=>{const S=v.items.filter(E=>E.id!==a);return v.id===c?{...v,items:[...S,y]}:{...v,items:S}}):d}),me=Ks(),se=me&&!Qn.has(me.modeId)?me:null,Me=se?Te(se.modeId).name:null,Pe=async a=>{const c=[],d=[];for(const v of a){const S=await Tn(v);S.ok?c.push(...S.items):d.push(`“${v.name}” (${S.reason})`)}const y=m.startsWith("group:")?m.slice(6):null;Be(y,c,!1),K([c.length?`Added ${c.length} request${c.length===1?"":"s"}.`:"",d.length?`Skipped ${d.join(", ")}.`:""].filter(Boolean).join(" ")||null)},Ne=w.useMemo(()=>{const a=R.issues.map((d,y)=>{const v=d.target?d.target.startsWith("g")?`group:${d.target}`:`item:${d.target}`:"overview",S=R.items.find(T=>T.item.id===d.target),E=S?`$${S.contentId}: ${d.message}`:d.message;return d.severity==="error"?de.err(`batch-${y}`,"validation",E,void 0,v):de.warn(`batch-${y}`,"validation",E,void 0,v)}),c=R.items.filter(d=>d.wire?.method==="DELETE").length;return c>0&&a.push(de.warn("batch-deletes","validation",`This batch deletes ${c} record${c===1?"":"s"}`,"The batch’s confirmation counts writes, not the records each delete removes, and there’s no typed record name as in the Delete mode. Check the ids first.","overview")),te&&a.unshift(de.err("batch-unavailable","validation",te,void 0,"overview")),a},[R,te]),$t=te??Qs(Ne),wt=R.items.some(a=>a.wire&&Object.keys(a.wire.headers).length>0)||o.continueOnError&&le.some(a=>!a.transaction),St=async()=>{P(!0);try{const a=await $n(le,{continueOnError:o.continueOnError});q(a);const{status:c,summary:d,succeeded:y}=bn(a);M(hn({modeId:s,url:`${ee}/$batch`,method:"BATCH",status:c,ms:a.ms,rowCount:y,summary:d})),b(v=>({...v,dirty:new Set}))}finally{P(!1),g("results")}},kt=w.useMemo(()=>k?(r&&!p?k.items.filter(c=>c.outcome!=="done"||(c.status??0)>=400):k.items).map(c=>{const d=R.items.find(y=>y.item.id===c.itemId);return{key:c.itemId,contentId:c.contentId,method:d?.wire?.method,path:d?.wire?.path,label:d?.item.label,outcome:c.outcome,status:c.status,statusText:c.statusText,headers:c.headers,body:c.body}}):[],[k,R,r,p]),Ae=w.useRef({batch:Ze("batch"),cs:[]}),fe=w.useMemo(()=>({batch:Ae.current.batch,changeset:a=>{var c;return(c=Ae.current.cs)[a]??(c[a]=Ze("changeset"))}}),[]),Et=w.useMemo(()=>new TextEncoder().encode(ht(gt(R.items),fe).body).length,[R,fe]),De=a=>Cn(a,{items:R.items,plan:le,continueOnError:o.continueOnError,orgUrl:I,boundaries:fe}),Rt=a=>a==="csharp"?An(R.items,{continueOnError:o.continueOnError,returnResponses:p},{logicalOf:c=>x.find(d=>d.entitySetName===c)?.logicalName??null,attrType:(c,d)=>rt(c)?.columns.find(y=>y.logicalName===d)?.attributeType??null}):De(a),ne=w.useMemo(()=>Xs(o),[o]);Zs(s,ne,Q,$);const Tt=w.useMemo(()=>ye(ne),[ne]),Fe=$===null?!0:Tt!==$,ce=R.items.length,It=a=>{f(a.id),N(ye(a.state))},Ct=a=>{if(a.modeId!==s)return;const c=a.state;b(Xe(c)),f(a.id),N(ye(c)),q(null),h("overview")},_e=Je(It);Ys(s,a=>{a.modeId===s&&(b(pn(Qe(),a)),q(null),g("builder"),h("overview"))});const Le=Je(Ct);en(w.useMemo(()=>({state:ne,modeId:s,dirty:Fe,lastSavedId:Q,onSaved:_e,onLoadSaved:Le}),[ne,s,Fe,Q,_e,Le]));const ge=a=>R.issues.filter(c=>c.target===a),qt=a=>k?.items.find(c=>c.itemId===a),Ot=[{id:"batch",label:r?"ExecuteMultiple":"Batch",meta:`${ce} request${ce===1?"":"s"}`,items:[{id:"overview",icon:sn,iconFilled:tn,label:r?"Settings & add":"Options & add",badge:o.continueOnError?"continue":null,badgeAppearance:"tint",dirty:o.dirty.has("overview")}]},...o.groups.map((a,c)=>({id:a.id,label:r?"Requests":a.atomic?`Change set ${c+1}`:`Independent ${c+1}`,meta:`${a.items.length}`,items:[{id:`group:${a.id}`,icon:a.atomic?Ce:qe,iconFilled:a.atomic?nn:on,label:r?"Add request":a.atomic?"Atomic group":"Independent requests",badge:ge(a.id).length||null,badgeColor:"danger"},...a.items.map(d=>{const y=R.items.find(A=>A.item.id===d.id),v=ie(d,I),S=ge(d.id).filter(A=>A.severity==="error").length,E=qt(d.id),T=S?`${S} issue${S===1?"":"s"}`:E?E.status!==void 0?E.status:E.outcome==="rolled-back"?"rolled back":E.outcome==="unknown"?"no result":"not run":null;return{id:`item:${d.id}`,icon:lt,iconFilled:rn,label:`$${y?.contentId??"?"} ${v.method} ${d.label||v.path||"…"}`,code:!0,badge:T,badgeAppearance:"tint",badgeColor:S||E&&(E.outcome!=="done"||(E.status??0)>=400)?"danger":"success",dirty:o.dirty.has(`item:${d.id}`)}})]}))];let oe=null;if(m.startsWith("item:")){const a=yt(m.slice(5)),c=a&&R.items.find(d=>d.item.id===a.item.id);a&&c&&(oe=e.jsx(_n,{item:a.item,contentId:c.contentId,group:a.group,groups:o.groups,wire:c.wire,issues:ge(a.item.id),onChange:d=>xt(a.item.id,d),onRemove:()=>{V(d=>d.map(y=>({...y,items:y.items.filter(v=>v.id!==a.item.id)}))),h(`group:${a.group.id}`)},onMove:d=>vt(a.item.id,d),onMoveToGroup:d=>jt(a.item.id,d)},a.item.id))}else if(m.startsWith("group:")){const a=o.groups.findIndex(d=>d.id===m.slice(6)),c=o.groups[a];c&&(oe=e.jsx(Wn,{group:c,index:a,count:o.groups.length,variant:n,orgUrl:I,contentIdOf:d=>R.items.find(y=>y.item.id===d)?.contentId??"?",onSetAtomic:d=>V(y=>y.map(v=>v.id===c.id?{...v,atomic:d}:v)),onAdd:d=>Be(c.id,[at(d)]),onRemoveGroup:()=>{V(d=>d.filter(y=>y.id!==c.id)),h("overview")},onMoveGroup:d=>V(y=>{const v=[...y],S=a+d;return S<0||S>=v.length?y:([v[a],v[S]]=[v[S],v[a]],v)}),onSelect:h}))}return oe||(oe=e.jsx(Un,{variant:n,returnResponses:p,setReturnResponses:a=>b(c=>pe({...c,returnResponses:a},"overview")),groups:o.groups,continueOnError:o.continueOnError,setContinueOnError:a=>b(c=>pe({...c,continueOnError:a},"overview")),plan:le,unavailable:te,needsConsent:wt,orgUrl:I,onAddGroup:a=>{const c=Ke(a);V(d=>[...d,c]),h(`group:${c.id}`)},onOpenSaved:()=>L(!0),onAddLast:()=>{se&&Pe([{...se,name:Me??se.modeId}])},lastLabel:Me,onSelect:h,notice:Z})),e.jsxs(an,{sidebar:e.jsx(dn,{type:u,urlPreview:`/$batch · ${ce} request${ce===1?"":"s"}${r?" · ExecuteMultiple":""}`,sections:Ot,activeNode:m,onSelect:a=>{h(a),g("builder")},recents:J}),urlBar:e.jsx(cn,{method:"BATCH",url:`${ee}/$batch`,bytes:Et,executeVerb:u.executeVerb,writeConfirm:bt,disabledReason:$t,loading:W,onExecute:St,advisories:Ne,onAdvisoryFocus:a=>{h(a),g("builder")}}),children:[e.jsxs(ln,{tab:l,onTabChange:g,resultCount:k?k.items.length:null,children:[l==="builder"&&oe,l==="code"&&r&&e.jsx(ot,{formats:Jn,labels:Kn,generate:Rt,note:"DRS sends these requests as a Web API $batch; the C# is the SDK form."}),l==="code"&&!r&&e.jsx(ot,{formats:Vn,labels:ft,generate:De,note:R.issues.some(a=>a.severity==="error")?"Requests with errors are left out until they’re fixed.":void 0}),l==="results"&&e.jsx(Hn,{run:k,rows:kt,extraTitle:r&&!p&&k?"ReturnResponses = false: only faults are listed.":void 0})]}),e.jsx(Gn,{open:F,onClose:()=>L(!1),onAdd:a=>{Pe(a.map(c=>({modeId:c.modeId,state:c.state,name:c.name})))}})]})}export{Yn as BatchMode};
@@ -0,0 +1 @@
1
+ import{z as f,r as F,j as e,M as u,m as p,ay as x,cE as h,au as N,bt as b,bd as I,cp as j,t as n,B as r,cs as g,C as m,cH as z,cI as S}from"./index-NW0Z4UWR.js";function P({table:l,value:i,onChange:t,group:d="binary"}){const o=f(l),c=F.useMemo(()=>(o?.columns??[]).filter(a=>a.attributeType==="File"),[o]),s=c.find(a=>a.logicalName===i);return o?c.length===0?e.jsxs("div",{children:[e.jsx(x,{icon:j,title:"File column",group:d}),e.jsx(u,{layout:"multiline",intent:"warning",style:{maxWidth:720},children:e.jsxs(p,{children:[e.jsx("strong",{children:o.displayName})," has no File-typed columns. Add one via the maker portal or pick a different table."]})})]}):e.jsxs("div",{children:[e.jsx(x,{icon:j,title:"File column",sub:"Pick the File-typed column to operate on. Max size + target are sourced from the column metadata.",group:d}),e.jsxs("div",{style:{maxWidth:720},children:[e.jsx(N,{label:"Column",children:e.jsx(b,{value:s?.displayName??s?.logicalName??"",selectedOptions:i?[i]:[],onOptionSelect:(a,y)=>t(y.optionValue??null),placeholder:"Pick a file column…",children:c.map(a=>e.jsx(I,{value:a.logicalName,text:a.displayName,children:e.jsx(v,{col:a})},a.logicalName))})}),s&&e.jsx("div",{style:{marginTop:16},children:e.jsx(B,{col:s})})]})]}):e.jsx(u,{layout:"multiline",intent:"error",children:e.jsxs(p,{children:["Unknown table ",e.jsx("code",{children:l}),"."]})})}function v({col:l}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontFamily:n.fontFamilyMonospace,fontWeight:600},children:l.logicalName}),e.jsx(r,{appearance:"ghost",size:"small",children:"File"}),e.jsxs(r,{appearance:"ghost",size:"small",style:{marginLeft:"auto"},children:["max ",g((l.maxSizeInKB??32768)*1024)]})]}),e.jsxs(m,{style:{color:n.colorNeutralForeground3},children:[l.displayName,l.binaryTarget&&l.binaryTarget!=="file"&&e.jsxs(e.Fragment,{children:[" · ",l.binaryTarget," body"]})]})]})}function B({col:l}){const i=(l.maxSizeInKB??32768)*1024;return e.jsxs("div",{style:{border:`1px solid ${n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium,padding:12,background:n.colorNeutralBackground1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx(j,{style:{color:n.colorBrandForeground1}}),e.jsx("strong",{style:{fontFamily:n.fontFamilyMonospace,fontSize:13},children:l.logicalName}),e.jsx(r,{appearance:"tint",color:"brand",children:"File"}),e.jsx("span",{style:{flexGrow:1}}),e.jsx(m,{style:{color:n.colorNeutralForeground3,fontFamily:n.fontFamilyMonospace},children:l.displayName})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"160px 1fr",rowGap:4,fontSize:11},children:[e.jsx("span",{style:{color:n.colorNeutralForeground3},children:"Max file size"}),e.jsxs("span",{children:[g(i)," ",e.jsxs(m,{style:{color:n.colorNeutralForeground3,marginLeft:4},children:["· ",(l.maxSizeInKB??32768).toLocaleString()," KB"]})]}),e.jsx("span",{style:{color:n.colorNeutralForeground3},children:"Companion column"}),e.jsxs("span",{style:{fontFamily:n.fontFamilyMonospace},children:[S(l.logicalName)," ",e.jsx(m,{style:{color:n.colorNeutralForeground3,marginLeft:4,fontFamily:n.fontFamilyBase},children:"· read-only string — $select to get the filename without downloading bytes"})]}),e.jsx("span",{style:{color:n.colorNeutralForeground3},children:"Retrieve returns"}),e.jsx("span",{children:"file id (Guid). Pass to DeleteFile or compose download URL."}),e.jsx("span",{style:{color:n.colorNeutralForeground3},children:"Binary target"}),e.jsx("span",{children:e.jsx(r,{appearance:"ghost",children:l.binaryTarget??"file"})})]})]})}function T({table:l,value:i,onChange:t,group:d="binary"}){const o=f(l),c=F.useMemo(()=>(o?.columns??[]).filter(a=>a.attributeType==="Image"),[o]),s=c.find(a=>a.logicalName===i);return o?c.length===0?e.jsxs("div",{children:[e.jsx(x,{icon:h,title:"Image column",group:d}),e.jsx(u,{layout:"multiline",intent:"warning",style:{maxWidth:720},children:e.jsxs(p,{children:[e.jsx("strong",{children:o.displayName})," has no Image-typed columns. Tables get one when their primary image is configured; custom image columns are created via solution explorer."]})})]}):e.jsxs("div",{children:[e.jsx(x,{icon:h,title:"Image column",sub:"Pick the Image-typed column. Primary image (entityimage) is thumbnail-only; custom image columns can store full size when configured.",group:d}),e.jsxs("div",{style:{maxWidth:720},children:[e.jsx(N,{label:"Column",children:e.jsx(b,{value:s?.displayName??s?.logicalName??"",selectedOptions:i?[i]:[],onOptionSelect:(a,y)=>t(y.optionValue??null),placeholder:"Pick an image column…",children:c.map(a=>e.jsx(I,{value:a.logicalName,text:a.displayName,children:e.jsx(C,{col:a})},a.logicalName))})}),s&&e.jsx("div",{style:{marginTop:16},children:e.jsx(k,{col:s})})]})]}):e.jsx(u,{layout:"multiline",intent:"error",children:e.jsxs(p,{children:["Unknown table ",e.jsx("code",{children:l}),"."]})})}function C({col:l}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontFamily:n.fontFamilyMonospace,fontWeight:600},children:l.logicalName}),e.jsx(r,{appearance:"ghost",size:"small",children:"Image"}),l.isPrimaryImage&&e.jsx(r,{appearance:"tint",color:"brand",size:"small",children:"primary"}),l.canStoreFullImage&&e.jsx(r,{appearance:"tint",color:"success",size:"small",children:"full-size"}),e.jsx(r,{appearance:"ghost",size:"small",style:{marginLeft:"auto"},children:l.isPrimaryImage?"144×144":`max ${g((l.maxSizeInKB??10240)*1024)}`})]}),e.jsx(m,{style:{color:n.colorNeutralForeground3},children:l.displayName})]})}function k({col:l}){const i=(l.maxSizeInKB??10240)*1024;return e.jsxs("div",{style:{border:`1px solid ${n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium,padding:12,background:n.colorNeutralBackground1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx(h,{style:{color:n.colorBrandForeground1}}),e.jsx("strong",{style:{fontFamily:n.fontFamilyMonospace,fontSize:13},children:l.logicalName}),e.jsx(r,{appearance:"tint",color:"brand",children:"Image"}),l.isPrimaryImage&&e.jsx(r,{appearance:"tint",color:"brand",children:"primary"}),l.canStoreFullImage?e.jsx(r,{appearance:"tint",color:"success",children:"full-size enabled"}):e.jsx(r,{appearance:"tint",color:"subtle",children:"thumbnail only"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"180px 1fr",rowGap:4,fontSize:11},children:[e.jsx("span",{style:{color:n.colorNeutralForeground3},children:"Display name"}),e.jsx("span",{children:l.displayName}),e.jsx("span",{style:{color:n.colorNeutralForeground3},children:"Thumbnail size"}),e.jsx("span",{children:"144 × 144 (auto-cropped center)"}),e.jsx("span",{style:{color:n.colorNeutralForeground3},children:"Full-size"}),e.jsx("span",{children:l.canStoreFullImage?`Up to ${g(i)}`:e.jsx("em",{style:{color:n.colorNeutralForeground3},children:"not stored — thumbnail only"})}),e.jsx("span",{style:{color:n.colorNeutralForeground3},children:"Companion columns"}),e.jsx("span",{style:{fontFamily:n.fontFamilyMonospace,fontSize:10},children:(()=>{const t=z(l.logicalName);return`${t.id} · ${t.timestamp} · ${t.url}`})()}),e.jsx("span",{style:{color:n.colorNeutralForeground3},children:"Set on Create?"}),e.jsx("span",{children:l.isPrimaryImage?"Yes — primary image only":"No — Update or PATCH only"}),e.jsx("span",{style:{color:n.colorNeutralForeground3},children:"File types"}),e.jsx("span",{children:"image/gif · image/jpeg · image/png · image/bmp · image/tiff"})]})]})}export{P as F,T as I};
@@ -0,0 +1 @@
1
+ import{bg as b,r as y,j as e,ay as k,eG as B,t as a,eH as N,b$ as C,cr as v,au as s,cp as R,C as h,cs as u,aW as p,s as g,av as c,T as M,B as F,bv as S,M as T,m as w,o as U,eI as z,E,ao as W,ap as D}from"./index-NW0Z4UWR.js";const m=10*1024*1024;function I(l){const n=b(),r=y.useRef(null),[o,d]=y.useState(null);return y.useEffect(()=>d(null),[l.source.kind]),e.jsxs("div",{className:S(n.inlineCard),style:{padding:12,maxWidth:880},children:[e.jsx(k,{icon:B,title:"Payload source",sub:"Where the bytes come from. Switch source to change how the body gets composed.",group:l.group??"binary"}),e.jsxs("div",{style:{display:"inline-flex",border:`1px solid ${a.colorNeutralStroke2}`,borderRadius:a.borderRadiusSmall,overflow:"hidden",marginBottom:14},children:[e.jsx(f,{active:l.source.kind==="file",onClick:()=>l.setSource({kind:"file"}),icon:e.jsx(N,{}),label:"Upload file"}),e.jsx(f,{active:l.source.kind==="url",onClick:()=>l.setSource({kind:"url"}),icon:e.jsx(C,{}),label:"From URL"}),e.jsx(f,{active:l.source.kind==="base64",onClick:()=>l.setSource({kind:"base64"}),icon:e.jsx(v,{}),label:"Paste base64"})]}),l.source.kind==="file"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,maxWidth:560},children:[e.jsx(s,{label:"File",children:e.jsx("input",{ref:r,type:"file",accept:l.accept,style:{fontSize:12},onChange:t=>{const i=t.currentTarget.files?.[0];i&&(l.setFileName(i.name),l.setFileSize(i.size),i.type&&l.setMimeType(i.type),l.setBodyBase64(""),l.onFile?.(i))}})}),l.fileName&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",background:a.colorNeutralBackground2,borderRadius:a.borderRadiusSmall,fontSize:11},children:[e.jsx(R,{style:{color:a.colorBrandForeground1,width:18,height:18}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontWeight:600},children:l.fileName}),e.jsxs(h,{style:{color:a.colorNeutralForeground3},children:[u(l.fileSize)," · ",l.mimeType||"application/octet-stream"]})]}),e.jsx(p,{content:"Pick a different file",relationship:"description",children:e.jsx(g,{size:"small",appearance:"subtle",onClick:()=>r.current?.click(),children:"Change"})})]})]}),l.source.kind==="url"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,maxWidth:720},children:[e.jsx(s,{label:"URL",hint:e.jsx("span",{style:{color:a.colorNeutralForeground3},children:"Informational — the studio doesn't fetch external URLs at execute time. Use this when the file lives on a CDN and you'll fetch it client-side before calling Dataverse."}),children:e.jsx(c,{value:l.bodyUrl,onChange:(t,i)=>l.setBodyUrl(i.value),placeholder:"https://cdn.example.com/file.pdf",style:{fontFamily:a.fontFamilyMonospace}})}),e.jsx(s,{label:"File name",children:e.jsx(c,{value:l.fileName,onChange:(t,i)=>l.setFileName(i.value),placeholder:"file.pdf"})}),e.jsx(s,{label:"MIME type",children:e.jsx(c,{value:l.mimeType,onChange:(t,i)=>l.setMimeType(i.value),placeholder:"application/pdf",style:{fontFamily:a.fontFamilyMonospace}})})]}),l.source.kind==="base64"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx(s,{label:"File name",children:e.jsx(c,{value:l.fileName,onChange:(t,i)=>l.setFileName(i.value),placeholder:"file.bin"})}),e.jsx(s,{label:"MIME type",children:e.jsx(c,{value:l.mimeType,onChange:(t,i)=>l.setMimeType(i.value),placeholder:"application/octet-stream",style:{fontFamily:a.fontFamilyMonospace}})}),e.jsx(s,{label:"Base64 body",validationState:o?"error":"none",validationMessage:o??void 0,hint:e.jsxs("span",{children:["Raw base64-encoded bytes."," ",e.jsx(F,{appearance:"ghost",children:u(j(l.bodyBase64))})," ","after decode."]}),children:e.jsx(M,{rows:6,value:l.bodyBase64,onChange:(t,i)=>{const x=j(i.value);if(x>m){d(`That's ${u(x)} decoded; up to ${u(m)} can be pasted. Use Upload file for larger files.`);return}d(null),l.setBodyBase64(i.value),l.setFileSize(x)},style:{fontFamily:a.fontFamilyMonospace,fontSize:11},placeholder:"JVBERi0xLjQK…"})})]})]})}function f({active:l,onClick:n,icon:r,label:o}){return e.jsx(g,{size:"small",appearance:l?"primary":"subtle",icon:r,onClick:n,style:{borderRadius:0,border:"none"},children:o})}function j(l){const n=l.replace(/^data:[^,]*,/,"").replace(/\s+/g,"");if(!n)return 0;const r=(n.match(/=+$/)??[""])[0].length;return Math.max(0,Math.floor(n.length*3/4)-r)}function _({steps:l,title:n="Pipeline",sub:r,sizeAdvisory:o}){const d=b();return e.jsxs("div",{className:S(d.inlineCard),style:{padding:12,maxWidth:1040},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[e.jsx(v,{style:{width:16,height:16,color:a.colorBrandForeground1}}),e.jsx("strong",{style:{fontSize:12},children:n}),e.jsxs(F,{appearance:"ghost",children:[l.length," request",l.length===1?"":"s"]}),r&&e.jsx(h,{style:{color:a.colorNeutralForeground3,marginLeft:6},children:r})]}),o&&e.jsx("div",{style:{marginBottom:10},children:e.jsx(T,{intent:o.level==="error"?"error":o.level==="warn"?"warning":"success",layout:"multiline",children:e.jsxs(w,{children:[e.jsx(U,{children:o.headline}),o.detail]})})}),l.length===0?e.jsx(h,{style:{color:a.colorNeutralForeground3,fontStyle:"italic",display:"block",padding:"8px 4px"},children:"No pipeline — pick a target / column / operation."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:l.map(t=>e.jsx(L,{step:t},t.n))})]})}function L({step:l}){return e.jsxs("div",{style:{padding:10,border:`1px solid ${a.colorNeutralStroke2}`,borderLeft:`3px solid ${a.colorBrandStroke1}`,borderRadius:a.borderRadiusMedium,background:a.colorNeutralBackground1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{width:24,height:24,borderRadius:12,background:a.colorBrandBackground,color:a.colorNeutralForegroundOnBrand,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:11,flexShrink:0},children:l.n}),e.jsx(z,{method:l.method,size:"sm"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600},children:l.title}),e.jsx("div",{style:{fontFamily:a.fontFamilyMonospace,fontSize:10,color:a.colorNeutralForeground3,wordBreak:"break-all",marginTop:2},children:l.relativeUrl.startsWith("http")||l.relativeUrl.startsWith("<")?l.relativeUrl:`https://${E.host}${l.relativeUrl}`})]}),e.jsx(p,{content:"Copy URL",relationship:"label",children:e.jsx(g,{size:"small",appearance:"subtle",icon:e.jsx(D,{}),onClick:()=>{W(l.relativeUrl,"the URL")}})})]}),(Object.keys(l.headers).length>0||l.body||l.detail)&&e.jsxs("div",{style:{paddingLeft:34,marginTop:8,display:"flex",flexDirection:"column",gap:4,fontSize:11,color:a.colorNeutralForeground3},children:[Object.keys(l.headers).length>0&&e.jsxs("div",{children:[e.jsx("strong",{style:{color:a.colorNeutralForeground2},children:"Headers"}),e.jsx("div",{style:{marginTop:2,fontFamily:a.fontFamilyMonospace,fontSize:10,lineHeight:1.55},children:Object.entries(l.headers).map(([n,r])=>e.jsxs("div",{children:[e.jsx("span",{style:{color:a.colorBrandForeground2},children:n}),e.jsx("span",{style:{color:a.colorNeutralForeground3},children:": "}),e.jsx("span",{children:r})]},n))})]}),l.body&&e.jsxs("div",{children:[e.jsx("strong",{style:{color:a.colorNeutralForeground2},children:"Body"}),e.jsx("div",{style:{marginTop:2,fontFamily:a.fontFamilyMonospace,fontSize:10,padding:8,background:a.colorNeutralBackground3,borderRadius:a.borderRadiusSmall,whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:200,overflow:"auto"},children:typeof l.body=="string"?l.body:JSON.stringify(l.body,null,2)})]}),l.detail&&e.jsx(h,{style:{color:a.colorNeutralForeground3},children:l.detail})]})]})}export{_ as B,I as a};
@@ -0,0 +1 @@
1
+ import{z as U,E as V,A as Xe,F as Ye,G as Ve,H as ue,I as de,J as Je,K as P,L as me,N as ze,O as Qe,P as Ge,Q as Ke,f as Ze,r as u,R as et,u as tt,U as at,V as st,W as nt,X as rt,Y as X,Z as pe,_ as ot,$ as lt,a0 as it,a1 as ct,a2 as ut,a3 as De,a4 as dt,a5 as Te,a6 as mt,a7 as pt,a8 as ht,j as t,a9 as yt,aa as ft,ab as bt,ac as Ce,ad as he,ae as gt,af as xt,M as L,m as O,ag as jt,ah as St,ai as vt,aj as kt,o as J,ak as ye,al as z,s as F,am as wt,an as G,ao as Nt,ap as Dt,aq as Tt,t as D,C as T,ar as Ct,D as Et,g as Rt,h as $t,k as Lt,l as Ot,as as Ft,S as At,at as It,au as C,av as Q,q as Pt,aw as Mt,ax as Bt,ay as Ee,az as qt,aA as fe,aB as Ut,T as be,aC as _t}from"./index-NW0Z4UWR.js";import{C as Ht}from"./CodeView-C65Y5vXN.js";import"./multipart-Bd_eOd8a.js";const ge={eq:"Equal",ne:"NotEqual",gt:"GreaterThan",ge:"GreaterEqual",lt:"LessThan",le:"LessEqual"},Wt=new Set(["On","OnOrAfter","OnOrBefore","Today","Tomorrow","Yesterday","Last7Days","Next7Days","LastWeek","ThisWeek","NextWeek","LastMonth","ThisMonth","NextMonth","LastYear","ThisYear","NextYear","LastXHours","LastXDays","LastXWeeks","LastXMonths","LastXYears","NextXHours","NextXDays","NextXWeeks","NextXMonths","NextXYears","OlderThanXMinutes","OlderThanXHours","OlderThanXDays","OlderThanXWeeks","OlderThanXMonths","OlderThanXYears","ThisFiscalPeriod","ThisFiscalYear","LastFiscalPeriod","LastFiscalYear","NextFiscalPeriod","NextFiscalYear","LastXFiscalPeriods","LastXFiscalYears","NextXFiscalPeriods","NextXFiscalYears","InFiscalPeriod","InFiscalYear","InFiscalPeriodAndYear","InOrAfterFiscalPeriodAndYear","InOrBeforeFiscalPeriodAndYear","Between","NotBetween","In","NotIn","ContainValues","DoesNotContainValues","Above","AboveOrEqual","Under","UnderOrEqual","NotUnder","EqualUserId","NotEqualUserId","EqualBusinessId","NotEqualBusinessId","EqualRoleBusinessId","EqualUserLanguage","EqualUserTeams","EqualUserOrUserTeams","EqualUserOrUserHierarchy","EqualUserOrUserHierarchyAndTeams"]);function xe(e){switch(e?.attributeType){case"Integer":case"Picklist":case"State":case"Status":case"MultiSelectPicklist":case"EntityName":return"System.Int32";case"BigInt":return"System.Int64";case"Decimal":case"Money":return"System.Decimal";case"Double":return"System.Double";case"Boolean":return"System.Boolean";case"DateTime":return"System.DateTime";case"Uniqueidentifier":case"Lookup":case"Customer":case"Owner":return"System.Guid";default:return"System.String"}}const Xt=e=>e.replace(/[[%_]/g,s=>`[${s}]`);function Yt(e,s){const a=[],o=n=>{if(n.type==="rule"){if(n.col.includes("/"))return a.push(`"${n.col}" filters on a related table — not supported in a bulk delete query.`),null;if(n.valKind==="column")return a.push(`"${n.col}" compares two columns — not supported in a bulk delete query.`),null;const c=ue(n.op),m=de(e,n.col),y=n.val??"";if(c?.kind==="null-check")return{AttributeName:n.col,Operator:n.op==="is-null"?"Null":"NotNull",Values:[]};if(c?.kind==="comparison"&&ge[n.op])return{AttributeName:n.col,Operator:ge[n.op],Values:[{Type:xe(m),Value:y}]};if(c?.kind==="odata-fn"){const{value:f}=Je(y),p=Xt(f),d=n.op==="contains"?`%${p}%`:n.op==="startswith"?`${p}%`:`%${p}`;return{AttributeName:n.col,Operator:n.negated?"NotLike":"Like",Values:[{Type:"System.String",Value:d}]}}return a.push(`Operator "${n.op}" on "${n.col}" has no QueryExpression mapping.`),null}if(n.type==="function"){const c=ue(n.op);if(!c||!Wt.has(n.op))return a.push(`Query function "${n.op}" has no QueryExpression mapping.`),null;if(n.negated)return a.push(`"not ${n.op}" can't be expressed in a bulk delete query.`),null;if(n.col.includes("/"))return a.push(`"${n.col}" filters on a related table — not supported in a bulk delete query.`),null;const m=c.category==="hierarchy"?e.primaryKey:n.col,y=de(e,n.col),f=c.kind==="dv-fn-array"?n.values??[]:c.kind==="dv-fn-2"?n.vals??["",""]:c.kind==="dv-fn-0"?[]:[n.val??""],p=c.kind==="dv-fn-1-int"||c.kind==="dv-fn-2"?"System.Int32":c.kind==="dv-fn-guid"?"System.Guid":xe(y);return{AttributeName:m,Operator:n.op,Values:f.map(d=>({Type:p,Value:d}))}}return null},r=n=>{n.negated&&a.push('Negated groups ("not (…)") can’t be expressed in a bulk delete query.');const c={FilterOperator:n.combinator==="or"?"Or":"And",Conditions:[],Filters:[]};for(const m of n.rules)if(m.type==="group")c.Filters.push(r(m));else if(m.type==="lambda")a.push(`"${m.nav}/${m.lambda}(…)" filters on related records — not supported in a bulk delete query.`);else{const y=o(m);y&&c.Conditions.push(y)}return c},i=r(s);for(const n of Xe(s,e))a.push(`"${n.col}" needs ${n.expected}, not ${JSON.stringify(n.value)}.`);return a.push(...Ye(s)),{query:a.length?null:{EntityName:e.logicalName,Criteria:i},problems:a}}const Vt=/^\{?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}?$/i;function je(e){const s=e.split(/[\s,;]+/).map(r=>r.trim()).filter(Boolean),a=[],o=[];for(const r of s)Vt.test(r)?a.push(r.replace(/^\{|\}$/g,"").toLowerCase()):o.push(r);return{ids:[...new Set(a)],invalid:o}}const Se=e=>({"@odata.type":"Microsoft.Dynamics.CRM.activityparty",activitypartyid:e});function Re(e){return e&&e>0?`FREQ=DAILY;INTERVAL=${Math.floor(e)}`:""}function Jt(e,s){if(e.startMode==="at"&&e.startAt){const a=new Date(e.startAt);if(!Number.isNaN(a.getTime()))return a.toISOString()}return s.toISOString()}function zt(e){const s=a=>String(a).padStart(2,"0");return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())} ${s(e.getHours())}:${s(e.getMinutes())}`}function $e(e,s){return`DRS bulk delete · ${e||"table"} · ${zt(s)}`}function Le(e,s){const a=U(e.table);if(!a)return{body:null,problems:["Pick a target table first."],deletesAll:!1};const{query:o,problems:r}=Yt(a,e.filter),i=je(e.toRecipients),n=je(e.ccRecipients),c=[...r];e.jobName.trim()||c.push("Give the job a name."),(i.invalid.length||n.invalid.length)&&c.push(`Not a systemuser id: ${[...i.invalid,...n.invalid].join(", ")}`),e.sendEmail&&i.ids.length===0&&c.push("Email notification needs at least one To recipient (systemuser id)."),e.startMode==="at"&&Number.isNaN(new Date(e.startAt).getTime())&&c.push("Pick a valid start date and time."),e.recurrenceDays!==null&&!(e.recurrenceDays>=1)&&c.push("Recurrence must be every 1 day or more.");const m=!!o&&Oe(o.Criteria);return{body:o?{QuerySet:[o],JobName:e.jobName.trim(),SendEmailNotification:e.sendEmail,ToRecipients:e.sendEmail?i.ids.map(Se):[],CCRecipients:e.sendEmail?n.ids.map(Se):[],RecurrencePattern:Re(e.recurrenceDays),StartDateTime:Jt(e,s)}:null,problems:c,deletesAll:m}}function Oe(e){return e.Conditions.length===0&&e.Filters.every(Oe)}function Qt(e){const s=U(e.table),a="/BulkDelete",o=`${V.apiBase}${a}`;return{relativeUrl:o,relativeNoBase:a,bytes:o.length,queryParts:[],entitySet:s?.entitySetName??"",entityLogical:s?.logicalName??""}}function Gt(e){const s=U(e.table);if(!s)return null;const a=Ve(e.filter,s),o=r=>encodeURIComponent(r).replace(/%2F/g,"/").replace(/%2C/g,",").replace(/%3D/g,"=").replace(/%24/g,"$").replace(/%28/g,"(").replace(/%29/g,")").replace(/%20/g," ").replace(/%27/g,"'").replace(/%3A/g,":");return`${s.entitySetName}?$select=${s.primaryKey}&$count=true&$top=1`+(a?`&$filter=${o(a)}`:"")}const Fe=5e3,Kt={0:"Ready",1:"Suspended",2:"Locked",3:"Completed"},ve={0:"Waiting for resources",10:"Waiting",20:"In progress",21:"Pausing",22:"Canceling",30:"Succeeded",31:"Failed",32:"Canceled"};function Zt(e){return`asyncoperations(${e})?$select=name,statecode,statuscode,message,friendlymessage,createdon,startedon,completedon,postponeuntil,recurrencepattern`}function ea(e){return`bulkdeleteoperations?$select=successcount,failurecount,statecode,statuscode,isrecurring&$filter=_asyncoperationid_value eq ${e}`}function ta(e){const{dirty:s,...a}=e;return a}function aa(e,s){return{...s,...e,dirty:new Set}}const Ae=e=>{const s=typeof e=="object"&&e!==null?e:{};return s.message??s.innererror?.message??String(e)};async function sa(e){const s=Gt(e);if(!s)return{ok:!1,error:"Table metadata not loaded."};try{const o=(await P.queryData(s))["@odata.count"];return typeof o!="number"?{ok:!1,error:"The response had no @odata.count."}:{ok:!0,count:o,capped:o>=Fe}}catch(a){return{ok:!1,error:Ae(a)}}}async function na(e,s){const{body:a,problems:o}=Le(e,new Date);if(!a||o.length)return me({statusCode:400,message:o[0]??"Request incomplete."},0);const r=ze(s);if(r)return r;const i=Qe(Ge("impersonation",s)),n=performance.now();try{const c=await P.execute({operationName:"BulkDelete",operationType:"action",parameters:a},i);return{status:200,statusText:"OK",ms:Math.round(performance.now()-n),bytes:Ke(c??{}),ok:!0,outcome:"ok",body:c??{},headers:{"OData-Version":"4.0"}}}catch(c){return me(c,Math.round(performance.now()-n),i)}}function ra(e){if(!e||typeof e!="object")return null;const s=e.JobId;return typeof s=="string"?s:null}async function oa(){const s=(await P.execute({operationName:"WhoAmI",operationType:"function"})).UserId;if(typeof s!="string")throw new Error("WhoAmI returned no UserId.");return s.toLowerCase()}async function la(e){try{const s=await P.queryData(Zt(e)),a=Array.isArray(s?.value)?s.value[0]??null:s??null;let o=null;try{o=(await P.queryData(ea(e)))?.value?.[0]??null}catch{}return{job:a,operation:o}}catch(s){return{job:null,operation:null,error:Ae(s)}}}const I="bulk-delete",$="bulk",ke=5e3,Y=120,we=()=>({table:"",filter:Ce(),jobName:"",sendEmail:!1,toRecipients:"",ccRecipients:"",startMode:"now",startAt:"",recurrenceDays:null,headers:kt()});function fa({themeMode:e}){const s=Ze(I),[a,o]=u.useState(()=>({...we(),dirty:new Set})),{table:r}=et(a.table||null),{allEntities:i}=tt(),[n,c]=u.useState("target"),[m,y]=u.useState("builder"),[f,p]=u.useState(null),[d,S]=u.useState(null),[v,N]=u.useState(!1),[E,g]=u.useState(!1),[x,j]=at(I),[k,K]=u.useState(null),[Z,ee]=u.useState(void 0),[te,ae]=u.useState(null),[_,Ie]=u.useState(()=>new Date);u.useEffect(()=>{const l=window.setInterval(()=>Ie(new Date),6e4);return()=>window.clearInterval(l)},[]);const w=U(a.table),A=u.useMemo(()=>Qt(a),[a,r]),{body:Pe,problems:H,deletesAll:M}=u.useMemo(()=>Le(a,_),[a,r,_]),B=u.useMemo(()=>st(a.filter),[a.filter]),se=(l,h,W)=>o(ie=>{const ce=new Set(ie.dirty);return ce.add(W),{...ie,[l]:h,dirty:ce}}),ne=nt([{when:!a.table,id:"bd-table",title:"Pick a target table first.",focusNode:"target"},{when:!w,id:"bd-metadata",title:"Loading table metadata…",focusNode:"target"},{when:H.length>0,id:"bd-query",title:H[0]??"",focusNode:"filter"},{when:a.headers.some(l=>l.enabled&&!l.name),id:"bd-header-name",title:"Fix empty header name.",focusNode:"headers"}]),Me=rt(ne),Be=async()=>{g(!1),N(!0);const l=await na(a,he(a.headers,null));p(l),S(l.ok?ra(l.body):null),N(!1),y("results"),j(Bt({modeId:I,url:A.relativeUrl,method:"POST",status:l.status,ms:l.ms})),o(h=>({...h,dirty:new Set}))},q=u.useMemo(()=>ta(a),[a]),qe=u.useMemo(()=>X(q),[q]),re=te===null?!0:qe!==te,Ue=l=>{ee(l.id),ae(X(l.state))},_e=l=>{if(l.modeId!==I)return;const h=l.state;if(i.length>0&&!i.some(W=>W.logicalName===h.table)){K(`Can't load "${l.name}": table '${h.table}' isn't available in this environment.`);return}K(null),o(aa(h,we())),ee(l.id),ae(X(h)),p(null),S(null),c("filter")},oe=pe(Ue),le=pe(_e);ot(u.useMemo(()=>a.table?{state:q,modeId:I,dirty:re,lastSavedId:Z,onSaved:oe,onLoadSaved:le}:null,[q,re,Z,a.table,oe,le]));const He=[{id:"target",label:"Target",meta:w?`${w.displayName} · ${w.entitySetName}`:"Pick a table",items:[{id:"target",icon:it,iconFilled:lt,label:w?.displayName??"Pick a table",dirty:a.dirty.has("target")}]},{id:"query",label:"Query",meta:B?`${B} condition${B===1?"":"s"}`:"all rows",items:[{id:"filter",icon:ut,iconFilled:ct,label:"Criteria",code:!0,badge:M?"ALL":B||null,badgeAppearance:"tint",badgeColor:M?"danger":"brand",dirty:a.dirty.has("filter")}]},{id:"job",label:"Job",meta:a.recurrenceDays?`every ${a.recurrenceDays} d`:"run once",items:[{id:"job",icon:dt,iconFilled:De,label:"Name & schedule",badge:a.startMode==="at"?"scheduled":null,dirty:a.dirty.has("job")},{id:"notify",icon:mt,iconFilled:Te,label:"Email notification",badge:a.sendEmail?"on":null,dirty:a.dirty.has("notify")}]},{id:"headers",label:"Headers",meta:`${a.headers.filter(l=>l.enabled).length} active`,items:[{id:"headers",icon:ht,iconFilled:pt,label:"HTTP headers",badge:a.headers.filter(l=>l.enabled).length||null,dirty:a.dirty.has("headers")}]}];let R=null;switch(n){case"target":R=t.jsx(bt,{table:a.table,onTableChange:l=>{o(h=>({...h,table:l,filter:Ce(),jobName:h.jobName&&!h.jobName.startsWith("DRS bulk delete")?h.jobName:l?$e(l,new Date):"",dirty:new Set(["target","filter"])})),p(null),S(null)},group:$,sub:"Rows of this table that match the query are deleted by an asynchronous system job. Switching the target clears the query."});break;case"filter":R=t.jsxs("div",{children:[t.jsx(ia,{deletesAll:M,problems:H,tbl:w}),t.jsx(ft,{table:a.table,tree:a.filter,setTree:l=>se("filter",l,"filter"),group:$})]});break;case"job":R=t.jsx(ca,{state:a,now:_,onChange:l=>o(h=>({...h,...l,dirty:new Set([...h.dirty,"job"])}))});break;case"notify":R=t.jsx(ua,{state:a,onChange:l=>o(h=>({...h,...l,dirty:new Set([...h.dirty,"notify"])}))});break;case"headers":R=t.jsx(yt,{policy:"impersonation",items:a.headers,setItems:l=>se("headers",l,"headers"),group:$});break}const We={method:"POST",built:A,headers:he(a.headers,null),body:Pe??{},entityLogical:A.entityLogical};return t.jsxs(gt,{sidebar:t.jsx(vt,{type:s,urlPreview:A.relativeNoBase,sections:He,activeNode:n,onSelect:l=>{c(l),y("builder")},recents:x}),urlBar:t.jsx(St,{method:"POST",url:A.relativeUrl,executeVerb:s.executeVerb,disabledReason:Me,loading:v,onExecute:async()=>g(!0),advisories:ne,onAdvisoryFocus:c}),children:[t.jsxs(xt,{tab:m,onTabChange:y,resultCount:null,children:[m==="builder"&&t.jsxs(t.Fragment,{children:[k&&t.jsx(L,{intent:"error",style:{marginBottom:12},children:t.jsx(O,{children:k})}),R]}),m==="code"&&t.jsx(Ht,{themeMode:e,inputs:We,group:$}),m==="results"&&(f?.ok&&d?t.jsx(ma,{jobId:d,result:f}):t.jsx(jt,{result:f,mode:"single",table:a.table}))]}),E&&w&&t.jsx(da,{state:a,tbl:w,deletesAll:M,onCancel:()=>g(!1),onConfirm:Be})]})}function ia({deletesAll:e,problems:s,tbl:a}){if(!a)return null;const o=s.filter(r=>/bulk delete query|mapping/.test(r));return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:12},children:[e&&t.jsx(L,{intent:"error",layout:"multiline",children:t.jsxs(O,{children:[t.jsxs(J,{children:["No conditions — every ",a.displayName," row matches"]}),"Add at least one condition unless you really mean to empty the table."]})}),o.length>0&&t.jsx(L,{intent:"error",layout:"multiline",children:t.jsxs(O,{children:[t.jsx(J,{children:"Can't convert to a QueryExpression"}),t.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18},children:o.map(r=>t.jsx("li",{children:r},r))})]})}),t.jsx(L,{intent:"info",layout:"multiline",children:t.jsxs(O,{children:["BulkDelete takes a ",t.jsx("code",{children:"QueryExpression"}),", so this $filter is converted: comparisons, null checks, contains / starts / ends with (as ",t.jsx("code",{children:"Like"}),"), and the Dataverse query functions map 1:1. Related-table paths, any/all, column-to-column comparisons and negated groups or functions aren't supported. The confirmation counts matches with the same $filter before anything is submitted."]})})]})}function ca({state:e,now:s,onChange:a}){return t.jsxs("div",{style:{maxWidth:640,display:"flex",flexDirection:"column",gap:14},children:[t.jsx(Ee,{icon:De,title:"Job",sub:"The bulk delete runs as a system job; it only deletes rows created before it starts.",group:$}),t.jsx(C,{label:"Job name",required:!0,children:t.jsx(Q,{value:e.jobName,placeholder:$e(e.table,s),onChange:(o,r)=>a({jobName:r.value})})}),t.jsx(C,{label:"Start",children:t.jsxs(qt,{value:e.startMode,onChange:(o,r)=>a({startMode:r.value}),children:[t.jsx(fe,{value:"now",label:"Immediately (StartDateTime = when you send)"}),t.jsx(fe,{value:"at",label:"At a specific time"})]})}),e.startMode==="at"&&t.jsx(C,{label:"Start date and time (your local time)",children:t.jsx(Q,{type:"datetime-local",value:e.startAt,onChange:(o,r)=>a({startAt:r.value})})}),t.jsx(G,{checked:e.recurrenceDays!==null,onChange:(o,r)=>a({recurrenceDays:r.checked?7:null}),label:"Repeat the job"}),e.recurrenceDays!==null&&t.jsx(C,{label:"Every N days",hint:t.jsxs(t.Fragment,{children:["RecurrencePattern ",t.jsx("code",{children:Re(e.recurrenceDays)||"—"}),". A recurring job keeps deleting new matching rows until you cancel it in System Jobs."]}),children:t.jsx(Ut,{min:1,max:365,value:e.recurrenceDays,onChange:(o,r)=>{const i=r.value??Number(r.displayValue);Number.isFinite(i)&&a({recurrenceDays:Math.max(1,Math.floor(i))})}})})]})}function ua({state:e,onChange:s}){const[a,o]=u.useState(null),r=async()=>{try{const i=await oa();e.toRecipients.toLowerCase().includes(i)||s({toRecipients:[e.toRecipients.trim(),i].filter(Boolean).join(", ")}),o(null)}catch(i){o(i instanceof Error?i.message:String(i))}};return t.jsxs("div",{style:{maxWidth:640,display:"flex",flexDirection:"column",gap:14},children:[t.jsx(Ee,{icon:Te,title:"Email notification",sub:"Email users when the job finishes. Recipients are systemuser ids with a valid email address.",group:$}),t.jsx(G,{checked:e.sendEmail,onChange:(i,n)=>s({sendEmail:n.checked}),label:"Send an email when the job completes"}),e.sendEmail&&t.jsxs(t.Fragment,{children:[t.jsx(C,{label:"To (systemuser ids)",required:!0,hint:"Comma, space or new-line separated.",children:t.jsx(be,{value:e.toRecipients,onChange:(i,n)=>s({toRecipients:n.value}),rows:2})}),t.jsxs("div",{children:[t.jsx(F,{icon:t.jsx(_t,{}),onClick:()=>{r()},children:"Add me"}),a&&t.jsx(T,{style:{color:D.colorPaletteRedForeground1,marginLeft:8},children:a})]}),t.jsx(C,{label:"Cc (systemuser ids)",children:t.jsx(be,{value:e.ccRecipients,onChange:(i,n)=>s({ccRecipients:n.value}),rows:2})})]})]})}function da({state:e,tbl:s,deletesAll:a,onCancel:o,onConfirm:r}){const[i,n]=u.useState(null),[c,m]=u.useState(""),[y,f]=u.useState(!1),p=Ct(),d=p.environmentUrl.replace(/^https?:\/\//,"").replace(/\/.*$/,"");u.useEffect(()=>{let g=!1;return sa(e).then(x=>{g||n(x)}),()=>{g=!0}},[]);const S=c.trim()===s.logicalName,v=i?.ok&&i.count===0,N=S&&i!==null&&(!a||y)&&!(v&&!e.recurrenceDays),E=e.startMode==="at"&&e.startAt?new Date(e.startAt).toLocaleString():"as soon as the system job runs";return t.jsx(Et,{open:!0,modalType:"alert",onOpenChange:(g,x)=>!x.open&&o(),children:t.jsx(Rt,{style:{maxWidth:560},children:t.jsxs($t,{children:[t.jsxs(Lt,{children:["Delete ",s.displayName," rows in bulk?"]}),t.jsxs(Ot,{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(L,{intent:"error",layout:"multiline",children:t.jsxs(O,{children:[t.jsx(J,{children:"This permanently deletes data"}),"Deleted rows can't be restored, related rows follow the table's cascade rules, plug-ins and flows on Delete run for every row, and a failed job doesn't roll back what it already deleted."]})}),p.connected&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8},children:[t.jsx(T,{style:{color:D.colorNeutralForeground3},children:"Environment"}),t.jsx(z,{weight:"semibold",children:p.connectionName||d||"(no connection)"}),t.jsx(Ft,{environment:p.environment}),p.connectionName&&d&&t.jsx(T,{style:{color:D.colorNeutralForeground3,wordBreak:"break-all"},children:d})]}),t.jsx("div",{children:i===null?t.jsx(At,{size:"tiny",label:"Counting matching rows…",labelPosition:"after"}):i.ok?t.jsxs(z,{weight:"semibold",size:400,children:[i.capped?`${Fe.toLocaleString()} or more`:i.count.toLocaleString()," ",s.displayName," row",i.count===1?"":"s"," match right now."]}):t.jsxs(T,{style:{color:D.colorPaletteRedForeground1},children:["Couldn't count matching rows: ",i.error]})}),v&&!e.recurrenceDays&&t.jsx(T,{children:"Nothing matches, so there's nothing to delete."}),t.jsxs(T,{children:["Job ",t.jsx("strong",{children:e.jobName||"(unnamed)"})," starts ",E,e.recurrenceDays?` and repeats every ${e.recurrenceDays} day${e.recurrenceDays===1?"":"s"}, deleting rows that match at each run`:"","."]}),a&&t.jsx(It,{checked:y,onChange:(g,x)=>f(!!x.checked),label:`The query has no conditions — delete every ${s.displayName} row.`}),t.jsx(C,{label:t.jsxs(t.Fragment,{children:["Type the table name ",t.jsx("code",{children:s.logicalName})," to confirm"]}),children:t.jsx(Q,{value:c,onChange:(g,x)=>m(x.value),autoComplete:"off","aria-label":"Table logical name"})})]}),t.jsxs(Pt,{children:[t.jsx(F,{appearance:"secondary",onClick:o,children:"Cancel"}),t.jsx(F,{appearance:"primary",icon:t.jsx(Mt,{}),disabled:!N,onClick:r,style:N?{backgroundColor:D.colorPaletteRedBackground3,color:D.colorNeutralForegroundOnBrand}:void 0,children:"Submit bulk delete job"})]})]})})})}function Ne(e){return typeof e=="number"?e:void 0}function b(e,s,a){if(!e)return"—";const o=e[`${s}@OData.Community.Display.V1.FormattedValue`];if(typeof o=="string")return o;const r=e[s];return a&&typeof r=="number"?a[r]??String(r):r==null||r===""?"—":String(r)}function ma({jobId:e,result:s}){const[a,o]=u.useState(null),[r,i]=u.useState(0),[n,c]=u.useState(!0),[m,y]=u.useState(!1),f=Ne(a?.job?.statecode)===3,p=async()=>{const j=await la(e);o(j),i(k=>k+1)};u.useEffect(()=>{p()},[e]),u.useEffect(()=>{if(!n||f||r>=Y)return;const j=window.setTimeout(()=>{p()},ke);return()=>window.clearTimeout(j)},[n,f,r]);const d=a?.job??null,S=a?.operation??null,v=Ne(d?.statuscode),N=v===30?"success":v===31||v===32?"danger":"info",E=V.host?`https://${V.host}/main.aspx?pagetype=entityrecord&etn=asyncoperation&id=${e}`:"",g={padding:"4px 12px 4px 0",verticalAlign:"top"},x=[["Job id",t.jsx("code",{children:e},"id")],["Name",b(d,"name")],["State",b(d,"statecode",Kt)],["Status",b(d,"statuscode",ve)],["Deleted",S?b(S,"successcount"):"—"],["Failed",S?b(S,"failurecount"):"—"],["Created",b(d,"createdon")],["Started",b(d,"startedon")],["Completed",b(d,"completedon")],["Recurrence",b(d,"recurrencepattern")],["Message",b(d,"friendlymessage")!=="—"?b(d,"friendlymessage"):b(d,"message")]];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,maxWidth:760},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx(ye,{status:"success",code:s.status,ms:s.ms}),t.jsx(z,{weight:"semibold",children:"Bulk delete job submitted"}),a&&t.jsx(ye,{status:N,code:b(d,"statuscode",ve)})]}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[t.jsx(F,{icon:t.jsx(wt,{}),onClick:()=>{p()},children:"Refresh"}),t.jsx(G,{checked:n&&!f&&r<Y,disabled:f||r>=Y,onChange:(j,k)=>c(k.checked),label:f?"Job completed":`Auto-refresh every ${ke/1e3} s`}),t.jsx(F,{icon:t.jsx(Dt,{}),onClick:()=>{Nt(e,"the job ID",{toastOnSuccess:!1}).then(j=>j&&y(!0))},children:m?"Copied":"Copy job id"}),E&&t.jsx(F,{as:"a",href:E,target:"_blank",rel:"noreferrer",icon:t.jsx(Tt,{}),appearance:"subtle",children:"Open system job"})]}),a?.error&&t.jsx(L,{intent:"warning",children:t.jsxs(O,{children:["Couldn't read the job: ",a.error]})}),t.jsx("table",{style:{borderCollapse:"collapse",fontSize:13},children:t.jsx("tbody",{children:x.map(([j,k])=>t.jsxs("tr",{children:[t.jsx("td",{style:{...g,color:D.colorNeutralForeground3},children:j}),t.jsx("td",{style:g,children:k})]},j))})}),t.jsxs(T,{children:["Status comes from ",t.jsxs("code",{children:["asyncoperations(",e,")"]}),"; deleted / failed counts from the matching ",t.jsx("code",{children:"bulkdeleteoperations"})," row once the job has run."]})]})}export{fa as BulkDeleteMode};
@@ -0,0 +1,6 @@
1
+ import{z as V,E as et,aD as tt,aE as st,aF as Ce,I as at,K as $e,N as rt,L as xe,O as nt,Q as ot,f as it,r as f,R as lt,u as dt,U as ct,aG as ut,aH as pt,aI as ht,W as mt,X as ft,Y as ee,Z as ke,_ as gt,aJ as Re,aK as yt,$ as bt,a0 as wt,aL as Me,aM as xt,aN as Ie,aO as kt,a7 as jt,a8 as vt,aP as je,j as t,C as M,a9 as St,ab as Ct,ad as ve,ae as $t,af as Rt,M as $,m as R,ag as Mt,ah as It,ai as Nt,ay as re,s as j,aQ as Ft,aR as Ne,aS as Fe,ap as ne,aT as se,au as Dt,av as De,aU as Bt,aV as Lt,o as Be,t as P,aW as te,aX as At,az as Ut,aA as Ot,S as Tt,ak as Et,al as Pt,ao as Vt,D as qt,g as _t,h as Kt,k as zt,l as Wt,T as Gt,at as Ht,q as Jt,ax as Zt,aj as Qt}from"./index-NW0Z4UWR.js";import{F as Xt,s as Yt}from"./FieldSetEditor-Dg6WsDgG.js";import{d as es,s as ts,B as ss}from"./bypassAdvisories-BhBeq_oI.js";import{C as as}from"./CodeView-C65Y5vXN.js";import{d as rs}from"./writeState-DgYICTBE.js";import"./multipart-Bd_eOd8a.js";const Le=["CreateMultiple","UpdateMultiple","UpsertMultiple","DeleteMultiple"],ns=1e3,os=100,is=/^\{?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}?$/i,Ae=s=>is.test(s.trim()),Ue=s=>s.trim().replace(/^\{|\}$/g,"").toLowerCase();let ls=1;function G(s){return{id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`row_${crypto.randomUUID()}`:`row_${Date.now().toString(36)}_${(ls++).toString(36)}`,key:s?.key??"",fieldValues:s?.fieldValues??{},nullFields:s?.nullFields??[]}}function ds(s){return G({key:"",fieldValues:cs(s.fieldValues),nullFields:[...s.nullFields]})}function cs(s){return JSON.parse(JSON.stringify(s))}const q={CreateMultiple:{label:"Create multiple",description:"Creates every row in one request and returns the new ids.",keyRequired:!1,allowsAlternateKey:!1,usesFields:!0,fieldPurpose:"create",successStatus:200},UpdateMultiple:{label:"Update multiple",description:"Updates rows addressed by their primary key (GUID). Send only changed columns.",keyRequired:!0,allowsAlternateKey:!1,usesFields:!0,fieldPurpose:"update",successStatus:204},UpsertMultiple:{label:"Upsert multiple",description:"Creates or updates each row, addressed by primary key or an alternate key. Needs a table that supports both CreateMultiple and UpdateMultiple.",keyRequired:!0,allowsAlternateKey:!0,usesFields:!0,fieldPurpose:"upsert",successStatus:204},DeleteMultiple:{label:"Delete multiple",description:"Deletes rows by primary key. Elastic tables only — for standard tables use Bulk Delete.",keyRequired:!0,allowsAlternateKey:!1,usesFields:!0,fieldPurpose:"update",successStatus:204}};function us(s,a){return tt({table:s,fieldValues:a.fieldValues,nullFields:a.nullFields})}function ps(s,a,e){const r=q[s.operation],o={"@odata.type":`Microsoft.Dynamics.CRM.${a.logicalName}`},i=r.usesFields?us(s.table,e):{};Object.assign(o,i);const u=e.key.trim();let l;if(u?Ae(u)?o[a.primaryKey]=Ue(u):r.allowsAlternateKey?o["@odata.id"]=`${a.entitySetName}(${u})`:l=s.operation==="UpdateMultiple"?"Key must be a GUID — UpdateMultiple in the Web API does not accept alternate keys.":"Key must be a GUID.":r.keyRequired&&(l=s.operation==="UpsertMultiple"?"Missing key — a GUID or an alternate key such as name='value'.":"Missing primary key (GUID)."),!l&&s.operation!=="DeleteMultiple"&&Object.keys(i).length===0&&(l="No column values set."),!l&&s.operation==="CreateMultiple"){const d=hs(a,e);d.length>0&&(l=`Required column${d.length===1?"":"s"} unset: ${d.slice(0,3).join(", ")}${d.length>3?"…":""}`)}return{target:o,issue:l}}function hs(s,a){return s.columns.filter(e=>st(e)).filter(e=>{const r=a.fieldValues[e.logicalName];return r==null||r===""?!0:Array.isArray(r)?r.length===0:Ce(e)?!r?.id:!1}).map(e=>e.logicalName)}function Oe(s){const a=V(s.table);if(!a)return{body:{Targets:[]},issues:[]};const e=[],r=new Map;return{body:{Targets:s.rows.map((i,u)=>{const{target:l,issue:d}=ps(s,a,i);d&&e.push({rowIndex:u,rowId:i.id,message:d});const p=i.key.trim().toLowerCase();if(p){const m=r.get(p);m!==void 0?e.push({rowIndex:u,rowId:i.id,message:s.operation==="UpdateMultiple"?`Same key as row ${m+1} — UpdateMultiple applies only the first of them.`:`Same key as row ${m+1} — duplicate keys fail the request.`}):r.set(p,u)}return l})},issues:e}}function ms(s){const a=V(s.table);if(!a)return{relativeUrl:"",relativeNoBase:"",bytes:0,queryParts:[],entitySet:"",entityLogical:""};const e=`/${a.entitySetName}/Microsoft.Dynamics.CRM.${s.operation}`,r=`${et.apiBase}${e}`;return{relativeUrl:r,relativeNoBase:e,bytes:r.length,queryParts:[],entitySet:a.entitySetName,entityLogical:a.logicalName}}function fs(s){return s==="UpsertMultiple"?["CreateMultiple","UpdateMultiple"]:[s]}function gs(s,a){const e=r=>`'${r.replace(/'/g,"''")}'`;return`sdkmessagefilters?$select=sdkmessagefilterid&$filter=sdkmessageid/name eq ${e(s)} and primaryobjecttypecode eq ${e(a)}`}function ys(s,a,e){const r=V(s.table);if(!s.table)return{id:"bulk-table",reason:"Pick a target table first.",focusNode:"target"};if(!r)return{id:"bulk-metadata",reason:"Loading table metadata…",focusNode:"target"};if(e.state==="unsupported")return{id:"bulk-unsupported",reason:e.message,focusNode:"operation"};if(s.rows.length===0)return{id:"bulk-no-rows",reason:"Add at least one row.",focusNode:"rows"};if(a.length>0){const o=a[0];return{id:"bulk-row",reason:`Row ${o.rowIndex+1}: ${o.message}${a.length>1?` (+${a.length-1} more)`:""}`,focusNode:`row:${o.rowId}`}}return s.headers.some(o=>o.enabled&&!o.name)?{id:"bulk-header-name",reason:"Fix empty header name.",focusNode:"headers"}:null}function bs(s,a,e){return s==="DeleteMultiple"?`DeleteMultiple isn't available for '${a}'. It's supported on elastic tables only — use the Bulk Delete mode (an asynchronous job) for standard tables.`:s==="UpsertMultiple"?`UpsertMultiple needs both CreateMultiple and UpdateMultiple, and '${a}' doesn't support ${e.join(" or ")}.`:`'${a}' doesn't support ${s} (no sdkmessagefilter for this table).`}const ws=new Set(["@key","key","id","@odata.id"]);function xs(s,a){const e=s.trim();if(!e)return{rows:[],skippedColumns:[],errors:[]};let r;if(e.startsWith("[")||e.startsWith("{")){let l;try{l=JSON.parse(e)}catch(p){return{rows:[],skippedColumns:[],errors:[`Invalid JSON: ${p instanceof Error?p.message:String(p)}`]}}const d=Array.isArray(l)?l:l&&typeof l=="object"?l.Targets??l.value:void 0;if(!Array.isArray(d))return{rows:[],skippedColumns:[],errors:['JSON must be an array of objects (or { "Targets": [ … ] }).']};r=d.filter(p=>!!p&&typeof p=="object")}else{const l=$s(e);if(l.length<2)return{rows:[],skippedColumns:[],errors:["CSV needs a header row and at least one data row."]};const[d,...p]=l;r=p.filter(m=>m.some(g=>g.trim()!=="")).map(m=>{const g={};return d.forEach((k,S)=>{const y=m[S];y!==void 0&&y!==""&&(g[k.trim()]=y)}),g})}const o=new Set,i=[];return{rows:r.map((l,d)=>{const p=G();for(const[m,g]of Object.entries(l)){const k=m.trim();if(k==="@odata.type"||k==="@odata.etag"||g===void 0)continue;if(ws.has(k.toLowerCase())||k.toLowerCase()===a.primaryKey){p.key=ks(String(g??""),a);continue}const S=/^(.+)@odata\.bind$/i.exec(k),y=js(a,S?S[1]:k);if(!y){o.add(k);continue}if(g===null){p.nullFields.push(y.logicalName);continue}const b=vs(y,g);"error"in b?i.push(`Row ${d+1}, ${k}: ${b.error}`):p.fieldValues[y.logicalName]=b.value}return p}),skippedColumns:[...o],errors:i}}function ks(s,a){const e=/^\/?([A-Za-z0-9_]+)\((.*)\)$/.exec(s.trim());return e&&e[1]===a.entitySetName?e[2]:s.trim()}function js(s,a){const e=a.toLowerCase(),r=at(s,e);if(r)return r;const o=s.columns.find(i=>Ce(i)&&e.startsWith(`${i.logicalName}_`));return o||s.columns.find(i=>i.displayName.toLowerCase()===e)}function Se(s,a){if(typeof a=="number")return a;const e=String(a).trim();return/^-?\d+$/.test(e)?Number(e):s.find(r=>r.label.toLowerCase()===e.toLowerCase())?.value}function vs(s,a){const e=typeof a=="string"?a.trim():a;switch(s.attributeType){case"Integer":case"BigInt":case"Decimal":case"Double":case"Money":{const r=typeof e=="number"?e:Number(String(e).replace(/,/g,""));return Number.isFinite(r)?(s.attributeType==="Integer"||s.attributeType==="BigInt")&&!Number.isInteger(r)?{error:`"${String(a)}" is not a whole number`}:{value:r}:{error:`"${String(a)}" is not a number`}}case"Boolean":{if(typeof e=="boolean")return{value:e};const r=String(e).toLowerCase();return["true","1","yes","y"].includes(r)?{value:!0}:["false","0","no","n"].includes(r)?{value:!1}:r===s.trueOption.label.toLowerCase()?{value:!0}:r===s.falseOption.label.toLowerCase()?{value:!1}:{error:`"${String(a)}" is not a yes/no value`}}case"Picklist":case"State":case"Status":case"EntityName":{const r=Se(s.options,e);return r===void 0?{error:`unknown choice "${String(a)}"`}:{value:r}}case"MultiSelectPicklist":{const r=Array.isArray(e)?e:String(e).split(/[,;]/).map(i=>i.trim()).filter(Boolean),o=[];for(const i of r){const u=Se(s.options,i);if(u===void 0)return{error:`unknown choice "${String(i)}"`};o.push(u)}return{value:o}}case"Lookup":case"Customer":case"Owner":{const r=String(e),o=/^\/?([A-Za-z0-9_]+)\(\{?([0-9a-fA-F-]{36})\}?\)$/.exec(r);if(o){const d=s.targets.find(p=>V(p)?.entitySetName===o[1]);return d?{value:{id:o[2].toLowerCase(),targetEntity:d}}:{error:`"${o[1]}" is not a target of ${s.logicalName}`}}const i=/^([A-Za-z0-9_]+):\s*(.+)$/.exec(r),u=i?i[1].toLowerCase():s.targets[0],l=i?i[2]:r;return Ae(l)?s.targets.includes(u)?{value:{id:Ue(l),targetEntity:u}}:{error:`"${u}" is not a target of ${s.logicalName}`}:{error:`"${r}" is not a GUID`}}case"File":case"Image":return{error:"file and image columns can’t be set in a bulk write"};default:return{value:typeof e=="string"?e:String(e)}}}function Ss(s){const{dirty:a,...e}=s;return e}function Cs(s,a){return{...a,...s,operation:Le.includes(s.operation)?s.operation:"CreateMultiple",rows:(s.rows??[]).map(e=>({id:e.id||G().id,key:e.key??"",fieldValues:e.fieldValues??{},nullFields:e.nullFields??[]})),dirty:new Set}}function $s(s){const a=s.split(/\r?\n/,1)[0],e=a.includes(" ")&&!a.includes(",")?" ":",",r=[];let o=[],i="",u=!1;for(let l=0;l<s.length;l++){const d=s[l];if(u){d==='"'?s[l+1]==='"'?(i+='"',l++):u=!1:i+=d;continue}d==='"'&&i===""?u=!0:d===e?(o.push(i),i=""):d===`
2
+ `||d==="\r"?(d==="\r"&&s[l+1]===`
3
+ `&&l++,o.push(i),r.push(o),o=[],i=""):i+=d}return o.push(i),r.push(o),r}async function Rs(s,a){try{const e=[];for(const r of fs(a))(await $e.queryData(gs(r,s)))?.value?.length||e.push(r);return e.length===0?{state:"supported"}:{state:"unsupported",message:bs(a,s,e)}}catch(e){return{state:"unknown",message:`Couldn't check ${a} availability: ${e instanceof Error?e.message:String(e)}`}}}async function Ms(s,a){const e=rt(a);if(e)return e;const{body:r,issues:o}=Oe(s);if(o.length>0)return xe({statusCode:400,message:`Row ${o[0].rowIndex+1}: ${o[0].message}`},0);const i=nt(a),u=performance.now();try{const l=await $e.execute({operationName:s.operation,operationType:"action",entityName:s.table,parameters:r},i),d=Math.round(performance.now()-u),p=l&&Object.keys(l).length>0?l:null;return{status:p?200:204,statusText:p?"OK":"No Content",ms:d,bytes:ot(p),ok:!0,outcome:"ok",body:p,headers:{"OData-Version":"4.0"}}}catch(l){return xe(l,Math.round(performance.now()-u),i)}}function ae(s){if(!s||typeof s!="object")return[];const a=s.Ids;return Array.isArray(a)?a.filter(e=>typeof e=="string"):[]}const T="bulk-write",N="bulk",L=100,Is=25,Te=()=>({table:"",operation:"CreateMultiple",rows:[],headers:Qt(),bypass:rs()}),Ns=()=>({...Te(),dirty:new Set}),E=s=>`row:${s}`;function _s({themeMode:s}){const a=it(T),[e,r]=f.useState(Ns),{table:o}=lt(e.table||null),{allEntities:i}=dt(),[u,l]=f.useState("target"),[d,p]=f.useState("builder"),[m,g]=f.useState(null),[k,S]=f.useState("CreateMultiple"),[y,b]=f.useState(!1),[H,J]=ct(T),[w,v]=f.useState({state:"idle"}),[Z,F]=f.useState(!1),[I,A]=f.useState(null),[Q,_]=f.useState(void 0),[oe,ie]=f.useState(null),C=V(e.table),U=f.useMemo(()=>ms(e),[e,o]),{body:Ee,issues:O}=f.useMemo(()=>Oe(e),[e,o]),Pe=q[e.operation];f.useEffect(()=>{if(!e.table){v({state:"idle"});return}if(!ut()){v({state:"unknown",message:"Not connected to Power Platform ToolBox — availability not checked."});return}let n=!1;return v({state:"checking"}),Rs(e.table,e.operation).then(c=>{n||v(c)}),()=>{n=!0}},[e.table,e.operation]);const le=(n,c)=>{const h=new Set(n.dirty);return h.add(c),h},X=(n,c,h)=>r(x=>({...x,[n]:c,dirty:le(x,h)})),B=n=>r(c=>({...c,rows:n(c.rows),dirty:le(c,"rows")})),de=(n,c)=>B(h=>h.map(x=>x.id===n?{...x,...c}:x)),Ve=()=>G({fieldValues:C&&e.operation==="CreateMultiple"?Yt(C):{}}),qe=n=>{const c=Ve();B(h=>[...h,c])},ce=n=>{const c=e.rows.find(x=>x.id===n);if(!c)return;const h=ds(c);B(x=>{const Xe=x.findIndex(Ye=>Ye.id===n),we=[...x];return we.splice(Xe+1,0,h),we})},ue=n=>{B(c=>c.filter(h=>h.id!==n)),u===E(n)&&l("rows")},K=f.useMemo(()=>pt(e),[e]),pe=f.useMemo(()=>[...es(e.bypass,"bypass"),...ht({op:"create",bypass:e.bypass})],[e.bypass]),z=ys(e,O,w),he=mt([{when:z,id:z?.id??"",title:z?.reason??"",focusNode:z?.focusNode},{when:w.state==="checking",id:"bulk-checking",title:`Checking ${e.operation} availability…`,focusNode:"operation"}]),_e=[...he,...pe],Ke=he[0]?.title??ft(pe),ze=async()=>{b(!0);const n=e.operation,c=await Ms(e,ve(K,null));g(c),S(n),b(!1),p("results");const h=ae(c.body);J(Zt({modeId:T,url:U.relativeUrl,method:"POST",status:c.status,ms:c.ms,rowCount:c.ok?h.length||e.rows.length:0,summary:c.ok?`${h.length||e.rows.length} ${(h.length||e.rows.length)===1?"row":"rows"} written`:void 0})),r(x=>({...x,dirty:new Set}))},W=f.useMemo(()=>Ss(e),[e]),We=f.useMemo(()=>ee(W),[W]),me=oe===null?!0:We!==oe,Ge=n=>{_(n.id),ie(ee(n.state))},He=n=>{if(n.modeId!==T)return;const c=n.state;if(i.length>0&&!i.some(h=>h.logicalName===c.table)){A(`Can't load "${n.name}": table '${c.table}' isn't available in this environment.`);return}A(null),r(Cs(c,Te())),_(n.id),ie(ee(c)),g(null),l("rows")},fe=ke(Ge),ge=ke(He);gt(f.useMemo(()=>e.table?{state:W,modeId:T,dirty:me,lastSavedId:Q,onSaved:fe,onLoadSaved:ge}:null,[W,me,Q,e.table,fe,ge]));const Y=f.useMemo(()=>{const n=new Map;for(const c of O)n.has(c.rowId)||n.set(c.rowId,c.message);return n},[O]),ye=(n,c)=>{const h=C?n.fieldValues[C.primaryName]:void 0,x=n.key||typeof h=="string"&&h||"";return x?`#${c+1} · ${x}`:`#${c+1}`},Je=e.rows.slice(0,Is).map((n,c)=>{const h=Y.get(n.id),x=Object.keys(n.fieldValues).length+n.nullFields.length;return{id:E(n.id),icon:yt,iconFilled:Re,label:ye(n,c),badge:h?"!":x||null,badgeAppearance:"tint",badgeColor:h?"danger":"success"}}),be=w.state==="supported"?{badge:"supported",color:"success"}:w.state==="unsupported"?{badge:"unsupported",color:"danger"}:w.state==="checking"?{badge:"…",color:"subtle"}:w.state==="unknown"?{badge:"?",color:"warning"}:{badge:null,color:"subtle"},Ze=[{id:"target",label:"Target",meta:C?`${C.displayName} · ${C.entitySetName}`:"Pick a table",items:[{id:"target",icon:wt,iconFilled:bt,label:C?.displayName??"Pick a table",dirty:e.dirty.has("target")}]},{id:"operation",label:"Operation",meta:e.operation,items:[{id:"operation",icon:xt,iconFilled:Me,label:Pe.label,badge:be.badge,badgeAppearance:"tint",badgeColor:be.color,dirty:e.dirty.has("operation")}]},{id:"rows",label:"Rows",meta:`${e.rows.length} row${e.rows.length===1?"":"s"}`,items:[{id:"rows",icon:kt,iconFilled:Ie,label:"All rows",badge:O.length||null,badgeAppearance:"tint",badgeColor:"danger",dirty:e.dirty.has("rows"),children:Je}]},{id:"headers",label:"Headers",meta:`${K.filter(n=>n.enabled).length} active`,items:[{id:"headers",icon:vt,iconFilled:jt,label:"HTTP headers",badge:K.filter(n=>n.enabled).length||null,dirty:e.dirty.has("headers")},{id:"bypass",icon:je,iconFilled:je,label:"Bypass logic",badge:ts(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 D=null;if(u.startsWith("row:")){const n=e.rows.findIndex(h=>E(h.id)===u),c=e.rows[n];D=c?t.jsx(Ls,{row:c,index:n,count:e.rows.length,table:e.table,tbl:C,operation:e.operation,issue:Y.get(c.id),themeMode:s,onPatch:h=>de(c.id,h),onNavigate:h=>l(E(e.rows[h].id)),onBack:()=>l("rows"),onDuplicate:()=>ce(c.id),onRemove:()=>ue(c.id)},c.id):t.jsx(M,{children:"That row was removed."})}else switch(u){case"target":D=t.jsx(Ct,{table:e.table,onTableChange:n=>{r(c=>({...c,table:n,rows:[],dirty:new Set(["target","rows"])})),g(null)},group:N,sub:"Every row in a bulk request targets the same table. Switching the target clears the rows."});break;case"operation":D=t.jsx(Fs,{operation:e.operation,setOperation:n=>X("operation",n,"operation"),support:w,table:e.table});break;case"rows":D=t.jsx(Bs,{state:e,tbl:C,issueByRow:Y,issueCount:O.length,rowLabel:ye,onAdd:()=>qe(),onImport:()=>F(!0),onClear:()=>B(()=>[]),onEdit:n=>l(E(n)),onDuplicate:ce,onRemove:ue,onKeyChange:(n,c)=>de(n,{key:c})});break;case"headers":D=t.jsx(St,{items:e.headers,setItems:n=>X("headers",n,"headers"),group:N,sendsHeaders:!0});break;case"bypass":D=t.jsx(ss,{value:e.bypass,onChange:n=>X("bypass",n,"bypass"),group:N});break}const Qe={method:"POST",built:U,headers:ve(K,null),body:Ee,entityLogical:U.entityLogical};return t.jsxs($t,{sidebar:t.jsx(Nt,{type:a,urlPreview:U.relativeNoBase,sections:Ze,activeNode:u,onSelect:n=>{l(n),p("builder")},recents:H}),urlBar:t.jsx(It,{method:"POST",url:U.relativeUrl,executeVerb:a.executeVerb,writeConfirm:{operation:`Bulk Write · ${e.operation}`,table:e.table,scope:{kind:"records",count:e.rows.length},highImpact:!0},disabledReason:Ke,loading:y,onExecute:ze,advisories:_e,onAdvisoryFocus:l}),children:[t.jsxs(Rt,{tab:d,onTabChange:p,resultCount:m?.ok&&ae(m.body).length||null,children:[d==="builder"&&t.jsxs(t.Fragment,{children:[I&&t.jsx($,{intent:"error",style:{marginBottom:12},children:t.jsx(R,{children:I})}),D]}),d==="code"&&t.jsx(as,{themeMode:s,inputs:Qe,group:N}),d==="results"&&(m&&m.ok?t.jsx(Us,{result:m,operation:k}):t.jsx(Mt,{result:m,mode:"single",table:e.table}))]}),t.jsx(As,{open:Z,tbl:C,onClose:()=>F(!1),onImport:(n,c)=>{B(h=>c?n:[...h,...n]),F(!1),l("rows")}})]})}function Fs({operation:s,setOperation:a,support:e,table:r}){return t.jsxs("div",{style:{maxWidth:760},children:[t.jsx(re,{icon:Me,title:"Operation",sub:"One request, many rows of the same table. On standard tables the whole request rolls back if any row fails.",group:N}),t.jsx(Ut,{value:s,onChange:(o,i)=>a(i.value),"aria-label":"Bulk operation",children:Le.map(o=>t.jsx(Ot,{value:o,label:t.jsxs("span",{children:[t.jsx("code",{children:o}),t.jsx("br",{}),t.jsx(M,{children:q[o].description})]})},o))}),t.jsxs("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:[r?e.state==="checking"?t.jsx(Tt,{size:"tiny",label:`Checking ${s} availability for ${r}…`}):e.state==="supported"?t.jsx($,{intent:"success",children:t.jsxs(R,{children:[t.jsx("code",{children:r})," supports ",s,"."]})}):e.state==="unsupported"?t.jsx($,{intent:"error",layout:"multiline",children:t.jsxs(R,{children:[t.jsx(Be,{children:"Not available"}),e.message]})}):e.state==="unknown"?t.jsx($,{intent:"warning",layout:"multiline",children:t.jsx(R,{children:e.message})}):null:t.jsx($,{intent:"info",children:t.jsxs(R,{children:["Pick a table to check whether it supports ",s,"."]})}),t.jsx($,{intent:"info",layout:"multiline",children:t.jsxs(R,{children:["Availability comes from the table's ",t.jsx("code",{children:"sdkmessagefilters"}),"."," ",t.jsx("code",{children:"UpsertMultiple"})," has no filter of its own — it's available where both"," ",t.jsx("code",{children:"CreateMultiple"})," and ",t.jsx("code",{children:"UpdateMultiple"})," are. Send 100–1,000 rows per request on standard tables (",os," on elastic tables); there's no fixed cap, but large payloads hit size and time limits."," ",t.jsx("a",{href:"https://learn.microsoft.com/en-us/power-apps/developer/data-platform/bulk-operations",target:"_blank",rel:"noreferrer",children:"Use bulk operation messages"})]})})]})]})}function Ds(s,a){const e=a?.primaryKey??"primary key";switch(s){case"CreateMultiple":return`optional ${e} GUID`;case"UpsertMultiple":return`${e} GUID or key='value'`;default:return`${e} GUID`}}function Bs({state:s,tbl:a,issueByRow:e,issueCount:r,rowLabel:o,onAdd:i,onImport:u,onClear:l,onEdit:d,onDuplicate:p,onRemove:m,onKeyChange:g}){const[k,S]=f.useState(0),y=Math.max(1,Math.ceil(s.rows.length/L)),b=Math.min(k,y-1),H=s.rows.slice(b*L,(b+1)*L),J=q[s.operation],w={padding:"4px 8px",borderBottom:`1px solid ${P.colorNeutralStroke2}`};return t.jsxs("div",{children:[t.jsxs(re,{icon:Ie,title:"Rows",sub:`Each row becomes one item in Targets. ${J.keyRequired?"Every row needs a key.":"A key is optional."}`,group:N,children:[t.jsx(j,{icon:t.jsx(Bt,{}),onClick:i,disabled:!a,children:"Add row"}),t.jsx(j,{icon:t.jsx(Lt,{}),onClick:u,disabled:!a,children:"Import CSV / JSON…"}),t.jsx(j,{icon:t.jsx(se,{}),appearance:"subtle",onClick:l,disabled:s.rows.length===0,children:"Clear"})]}),!a&&t.jsx($,{intent:"info",children:t.jsx(R,{children:"Pick a target table first."})}),s.rows.length>ns&&t.jsx($,{intent:"warning",layout:"multiline",style:{marginBottom:8},children:t.jsxs(R,{children:[t.jsxs(Be,{children:[s.rows.length.toLocaleString()," rows"]}),"Microsoft recommends 100–1,000 rows per request. Larger requests are more likely to hit message-size or time limits, and on standard tables a failure rolls back every row. Consider splitting the rows into several requests."]})}),r>0&&t.jsx($,{intent:"error",style:{marginBottom:8},children:t.jsxs(R,{children:[r," row issue",r===1?"":"s"," — fix them before sending."]})}),a&&s.rows.length===0&&t.jsx(M,{children:"No rows yet. Add rows one by one, or import them from CSV (header row of column names — Excel copy-paste works) or a JSON array of objects."}),s.rows.length>0&&t.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",fontSize:13},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{textAlign:"left"},children:[t.jsx("th",{style:w,children:"#"}),t.jsx("th",{style:w,children:"Key"}),t.jsx("th",{style:w,children:"Columns"}),t.jsx("th",{style:w,children:"Status"}),t.jsx("th",{style:w,"aria-label":"Actions"})]})}),t.jsx("tbody",{children:H.map((v,Z)=>{const F=b*L+Z,I=[...Object.keys(v.fieldValues),...v.nullFields],A=e.get(v.id);return t.jsxs("tr",{children:[t.jsx("td",{style:w,children:F+1}),t.jsx("td",{style:{...w,minWidth:220},children:t.jsx(De,{size:"small",value:v.key,placeholder:Ds(s.operation,a),onChange:(Q,_)=>g(v.id,_.value),"aria-label":`Row ${F+1} key`,style:{width:"100%"}})}),t.jsx("td",{style:w,children:t.jsx(M,{title:I.join(", "),children:I.length===0?"—":`${I.length}: ${I.slice(0,3).join(", ")}${I.length>3?"…":""}`})}),t.jsx("td",{style:w,children:A?t.jsx(M,{style:{color:P.colorPaletteRedForeground1},children:A}):t.jsx(M,{style:{color:P.colorPaletteGreenForeground1},children:"Ready"})}),t.jsxs("td",{style:{...w,whiteSpace:"nowrap"},children:[t.jsx(te,{content:`Edit ${o(v,F)}`,relationship:"label",children:t.jsx(j,{size:"small",appearance:"subtle",icon:t.jsx(At,{}),onClick:()=>d(v.id)})}),t.jsx(te,{content:"Duplicate row",relationship:"label",children:t.jsx(j,{size:"small",appearance:"subtle",icon:t.jsx(ne,{}),onClick:()=>p(v.id)})}),t.jsx(te,{content:"Remove row",relationship:"label",children:t.jsx(j,{size:"small",appearance:"subtle",icon:t.jsx(se,{}),onClick:()=>m(v.id)})})]})]},v.id)})})]}),y>1&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[t.jsx(j,{size:"small",icon:t.jsx(Ne,{}),disabled:b===0,onClick:()=>S(b-1),"aria-label":"Previous page"}),t.jsxs(M,{children:["Rows ",b*L+1,"–",Math.min((b+1)*L,s.rows.length)," of"," ",s.rows.length]}),t.jsx(j,{size:"small",icon:t.jsx(Fe,{}),disabled:b>=y-1,onClick:()=>S(b+1),"aria-label":"Next page"})]})]})}function Ls({row:s,index:a,count:e,table:r,tbl:o,operation:i,issue:u,themeMode:l,onPatch:d,onNavigate:p,onBack:m,onDuplicate:g,onRemove:k}){const S=q[i];return t.jsxs("div",{children:[t.jsxs(re,{icon:Re,title:`Row ${a+1} of ${e}`,sub:i==="DeleteMultiple"?"Only the key (and partitionid on partitioned elastic tables) is needed.":void 0,group:N,children:[t.jsx(j,{icon:t.jsx(Ft,{}),appearance:"subtle",onClick:m,children:"All rows"}),t.jsx(j,{icon:t.jsx(Ne,{}),disabled:a===0,onClick:()=>p(a-1),"aria-label":"Previous row"}),t.jsx(j,{icon:t.jsx(Fe,{}),disabled:a>=e-1,onClick:()=>p(a+1),"aria-label":"Next row"}),t.jsx(j,{icon:t.jsx(ne,{}),onClick:g,children:"Duplicate"}),t.jsx(j,{icon:t.jsx(se,{}),appearance:"subtle",onClick:k,children:"Remove"})]}),t.jsx(Dt,{label:S.keyRequired?"Key (required)":"Key (optional)",hint:i==="UpsertMultiple"?`A ${o?.primaryKey??"primary key"} GUID, or an alternate key segment such as name='Contoso' — sent as @odata.id.`:i==="CreateMultiple"?`Leave empty to let Dataverse assign the id, or set a ${o?.primaryKey??"primary key"} GUID.`:`The ${o?.primaryKey??"primary key"} GUID of the row.`,validationState:u?"error":"none",validationMessage:u,style:{maxWidth:520,marginBottom:12},children:t.jsx(De,{value:s.key,onChange:(y,b)=>d({key:b.value})})}),S.usesFields&&t.jsx(Xt,{table:r,values:s.fieldValues,setValues:y=>d({fieldValues:y}),nullFields:s.nullFields,setNullFields:y=>d({nullFields:y}),group:N,themeMode:l,purpose:S.fieldPurpose})]})}function As({open:s,tbl:a,onClose:e,onImport:r}){const[o,i]=f.useState(""),[u,l]=f.useState(!1),d=f.useMemo(()=>a?xs(o,a):{rows:[],skippedColumns:[],errors:[]},[o,a]),p=async m=>{m&&i(await m.text())};return t.jsx(qt,{open:s,onOpenChange:(m,g)=>!g.open&&e(),children:t.jsx(_t,{style:{maxWidth:760},children:t.jsxs(Kt,{children:[t.jsxs(zt,{children:["Import rows",a?` into ${a.displayName}`:""]}),t.jsxs(Wt,{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsxs(M,{children:["Paste CSV / tab-separated text with a header row of column logical (or display) names, or a JSON array of objects. A ",t.jsx("code",{children:a?.primaryKey??"primary key"}),","," ",t.jsx("code",{children:"id"})," or ",t.jsx("code",{children:"@key"})," column fills the row key. Lookups take a GUID (first target) or ",t.jsx("code",{children:"table:guid"}),"; choices take the value or the label."]}),t.jsx(Gt,{value:o,onChange:(m,g)=>i(g.value),rows:12,"aria-label":"Rows to import",placeholder:`name,numberofemployees
4
+ Contoso,10
5
+ Fabrikam,25`,textarea:{style:{fontFamily:P.fontFamilyMonospace,fontSize:12}}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[t.jsx("input",{type:"file",accept:".csv,.tsv,.txt,.json","aria-label":"Load rows from a file",onChange:m=>{p(m.target.files?.[0])}}),t.jsx(Ht,{checked:u,onChange:(m,g)=>l(!!g.checked),label:"Replace existing rows"})]}),o.trim()&&t.jsx($,{intent:d.errors.length?"warning":d.rows.length?"success":"info",layout:"multiline",children:t.jsxs(R,{children:[d.rows.length," row",d.rows.length===1?"":"s"," parsed.",d.skippedColumns.length>0&&t.jsxs(t.Fragment,{children:[" Skipped columns (not on this table): ",d.skippedColumns.join(", "),"."]}),d.errors.length>0&&t.jsxs("ul",{style:{margin:"4px 0 0",paddingLeft:18},children:[d.errors.slice(0,6).map(m=>t.jsx("li",{children:m},m)),d.errors.length>6&&t.jsxs("li",{children:["…and ",d.errors.length-6," more"]})]})]})})]}),t.jsxs(Jt,{children:[t.jsx(j,{appearance:"secondary",onClick:e,children:"Cancel"}),t.jsxs(j,{appearance:"primary",disabled:d.rows.length===0,onClick:()=>{r(d.rows,u),i("")},children:["Import ",d.rows.length||""," row",d.rows.length===1?"":"s"]})]})]})})})}function Us({result:s,operation:a}){const e=ae(s.body),[r,o]=f.useState(!1);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,maxWidth:760},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx(Et,{status:"success",code:s.status,ms:s.ms}),t.jsxs(Pt,{weight:"semibold",children:[a," ",e.length>0?`created ${e.length} row${e.length===1?"":"s"}`:"completed"]})]}),e.length>0?t.jsxs(t.Fragment,{children:[t.jsx("div",{children:t.jsx(j,{icon:t.jsx(ne,{}),onClick:()=>{Vt(e.join(`
6
+ `),"the IDs",{toastOnSuccess:!1,shown:!1}).then(i=>i&&o(!0))},children:r?"Copied":"Copy ids"})}),t.jsx("ol",{style:{margin:0,paddingLeft:32,fontFamily:P.fontFamilyMonospace,fontSize:12,maxHeight:480,overflow:"auto"},children:e.map(i=>t.jsx("li",{children:i},i))})]}):t.jsxs(M,{children:[a," returns 204 No Content — Dataverse doesn't report per-row results for it. Every row in the request succeeded (a failure would have rolled back the request on a standard table)."]})]})}export{_s as BulkWriteMode};