@mohsinonxrm/pptb-dataverse-request-studio 1.5.0 → 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 +245 -0
  2. package/README.md +28 -10
  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 +13 -13
  44. package/dist/index.html +7 -1
  45. package/index.html +6 -0
  46. package/package.json +1 -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 oe,bh as de,r as a,R as ce,u as ue,U as be,cX as pe,aD as me,z,cY as ye,cZ as fe,W as he,aH as ge,aI as Se,X as we,c_ as ve,bl as Fe,Y as C,Z as D,cM as Re,_ as xe,$ as Be,a0 as ke,aJ as Ce,aK as Te,a$ as je,b0 as Ne,cP as Le,cQ as Pe,a7 as Ie,a8 as $e,aP as U,b1 as W,j as r,a9 as He,cS as Ve,b2 as Me,ab as Ee,ad as X,ae as Ae,af as Oe,ag as qe,ah as ze,ai as De,c$ as Y,b8 as Ue,b9 as We,ax as Xe,bx as Ye,aj as Ze,e as _e,d0 as Je}from"./index-NW0Z4UWR.js";import{F as Ke,s as Qe}from"./FieldSetEditor-Dg6WsDgG.js";import{d as Ge,s as et,B as tt}from"./bypassAdvisories-BhBeq_oI.js";import{C as st}from"./CodeView-C65Y5vXN.js";import{w as at}from"./writeResultName-Dw705_0B.js";import{d as rt}from"./writeState-DgYICTBE.js";import"./multipart-Bd_eOd8a.js";const Z=()=>({table:"",fieldValues:{},nullFields:[],rawBody:null,prefer:{..._e(),formattedValues:!0,returnRepresentation:!0},headers:Ze(),returnSelect:[],duplicateDetection:!1,bypass:rt(),dirty:new Set});function pt({themeMode:T}){const j=oe("create"),R=de("create",Y,Z),[e,c]=a.useState(R.state),{table:N}=ce(e.table||null),{allEntities:L}=ue(),[P,m]=a.useState("target"),[y,f]=a.useState("builder"),[x,h]=a.useState(null),[_,I]=a.useState(!1),[J,K]=be("create"),[g,S]=a.useState(R.lastSavedId),[w,v]=a.useState(R.lastSavedHash),b=a.useMemo(()=>pe(e),[e,N]),B=a.useMemo(()=>me(e),[e,N]),i=z(e.table),Q=t=>c(s=>{const l=new Set(s.dirty);return l.add(t),{...s,dirty:l}}),o=(t,s,l)=>{c(p=>({...p,[t]:s})),l&&Q(l)},n=a.useMemo(()=>i?ye(i,i.columns,e.rawBody,e.fieldValues,e.nullFields).map(t=>t.logicalName):[],[i,e.rawBody,e.fieldValues,e.nullFields]),$=fe(e.rawBody),H=he([{when:!i,id:"create-table",title:"Pick a target table first.",focusNode:"target"},{when:$,id:"create-json",title:$??"",focusNode:"fieldset"},{when:n.length>0,id:"create-required",title:`${n.length} required field${n.length===1?"":"s"} unset: ${n.slice(0,3).join(", ")}${n.length>3?"…":""}`,focusNode:"fieldset"},{when:e.headers.some(t=>t.enabled&&!t.name),id:"create-header-name",title:"Fix empty header name.",focusNode:"headers"},{when:Object.keys(B).length===0,id:"create-empty-body",title:"Body is empty — set at least one field.",focusNode:"fieldset"}]),G=async()=>{I(!0);const t=await We.create(e,X(F,null));h(t),I(!1),f("results"),K(Xe({snapshot:u,modeId:"create",url:b.relativeUrl,method:"POST",status:t.status,ms:t.ms,rowCount:t.ok?1:0})),c(s=>({...s,dirty:new Set}))},F=a.useMemo(()=>ge(e),[e]),V=a.useMemo(()=>[...Ge(e.bypass,"bypass"),...Se({op:"create",bypass:e.bypass})],[e.bypass]),ee=[...H,...V],te=H[0]?.title??we(V),u=a.useMemo(()=>ve(e),[e]);Fe("create",u,g,w);const se=a.useMemo(()=>C(u),[u]),M=w===null?!0:se!==w,ae=t=>{S(t.id),v(C(t.state))},E=t=>{if(t.modeId!=="create")return;const s=t.state;if(L.length>0&&!L.some(l=>l.logicalName===s.table)){Ue(`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}c(Y(s)),S(t.id),v(C(s)),h(null),m("target")},re=t=>{const s=Ye(t,"create");if(!s)return;const l=g,p=w;E(s),S(l),v(p)},A=D(ae);Re("create",t=>{t.modeId==="create"&&(c(Je(Z(),t)),h(null),f("builder"),m("fieldset"))});const O=D(E);xe(a.useMemo(()=>e.table?{state:u,modeId:"create",dirty:M,lastSavedId:g,onSaved:A,onLoadSaved:O}:null,[u,M,g,e.table,A,O]));const k=e.rawBody!=null?Object.keys(B).length:Object.keys(e.fieldValues).length,q=e.prefer.returnRepresentation,le=[{id:"target",label:"Target",meta:i?`${i.displayName} · ${i.entitySetName}`:"Pick a table",items:[{id:"target",icon:ke,iconFilled:Be,label:i?.displayName??"Pick a table",dirty:e.dirty.has("target")}]},{id:"body",label:"Field set",meta:`${k} field${k===1?"":"s"}`,items:[{id:"fieldset",icon:Te,iconFilled:Ce,label:"Field set",badge:n.length>0?`${n.length} req unset`:`${k} populated`,badgeAppearance:"tint",badgeColor:n.length>0?"danger":"success",dirty:e.dirty.has("fieldset")}]},{id:"prefer",label:"Prefer",meta:q?"return=representation":"204 No Content",items:[{id:"prefer",icon:Ne,iconFilled:je,label:"Prefer header",badge:W(e.prefer)?"on":null,badgeAppearance:"ghost",dirty:e.dirty.has("prefer")},...q?[{id:"returnselect",icon:Pe,iconFilled:Le,label:"$select (response)",code:!0,badge:e.returnSelect.length||null,dirty:e.dirty.has("returnselect")}]:[]]},{id:"headers",label:"Headers",meta:`${F.filter(t=>t.enabled).length} active`,items:[{id:"headers",icon:$e,iconFilled:Ie,label:"HTTP headers",badge:F.filter(t=>t.enabled).length||null,dirty:e.dirty.has("headers")},{id:"bypass",icon:U,iconFilled:U,label:"Bypass logic",badge:et(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;switch(P){case"target":d=r.jsx(Ee,{table:e.table,onTableChange:t=>{const s=z(t),l=s?Qe(s):{};c(p=>({...p,table:t,fieldValues:l,rawBody:null,returnSelect:[],dirty:new Set(["target","fieldset"])})),h(null),S(void 0),v(null)},group:"write",sub:"Pick the entity set the new row will be written to. Switching the target clears the body."});break;case"fieldset":d=r.jsx(Ke,{table:e.table,values:e.fieldValues,setValues:t=>o("fieldValues",t,"fieldset"),nullFields:e.nullFields,setNullFields:t=>o("nullFields",t,"fieldset"),rawBody:e.rawBody??null,setRawBody:t=>o("rawBody",t,"fieldset"),group:"write",themeMode:T,purpose:"create"});break;case"prefer":d=r.jsx(Me,{spec:e.prefer,setSpec:t=>o("prefer",t,"prefer"),group:"write"});break;case"returnselect":d=r.jsx(Ve,{table:e.table,selectedIds:e.returnSelect,setSelectedIds:t=>o("returnSelect",t,"returnselect"),group:"write"});break;case"headers":d=r.jsx(He,{items:e.headers,setItems:t=>o("headers",t,"headers"),group:"write"});break;case"bypass":d=r.jsx(tt,{value:e.bypass,onChange:t=>o("bypass",t,"bypass"),group:"write"});break}const ie=X(F,W(e.prefer)),ne={method:"POST",built:b,headers:ie,body:B,entityLogical:b.entityLogical};return r.jsx(Ae,{sidebar:r.jsx(De,{type:j,urlPreview:b.relativeNoBase,sections:le,activeNode:P,onSelect:t=>{m(t),f("builder")},recents:J,onRecentClick:re}),urlBar:r.jsx(ze,{method:"POST",url:b.relativeUrl,executeVerb:j.executeVerb,writeConfirm:{operation:"Create Record",table:e.table,scope:{kind:"records",count:1},highImpact:!1},disabledReason:te,loading:_,onExecute:G,advisories:ee,onAdvisoryFocus:m}),children:r.jsxs(Oe,{tab:y,onTabChange:f,resultCount:x?.ok?1:null,children:[y==="builder"&&d,y==="code"&&r.jsx(st,{themeMode:T,inputs:ne}),y==="results"&&r.jsx(qe,{result:x,mode:"single",table:e.table,writeContext:{operation:"create",table:e.table,recordId:null,recordName:at(i?.primaryName,x?.body,e.fieldValues)}})]})})}export{pt as CreateMode};
@@ -0,0 +1 @@
1
+ import{dk as qe,r as d,dl as Ke,f as Ge,bh as _e,R as Ve,u as Ye,U as Je,dm as Xe,z as G,dn as Ze,bl as Qe,Y as Z,Z as ye,cM as et,_ as tt,aI as ot,j as e,X as nt,d5 as ge,aH as rt,$ as st,a0 as at,cx as _,aT as it,d6 as D,d7 as fe,a7 as lt,a8 as dt,aP as V,a9 as ct,d8 as ut,ad as xe,ae as ht,af as mt,ag as pt,ah as yt,ai as gt,dp as be,bR as ft,b8 as xt,bb as bt,da as wt,ay as M,M as ne,m as re,o as Se,au as oe,az as kt,aA as we,t as i,C as R,bt as vt,bd as ke,b9 as jt,ax as Tt,bx as Ct,aj as St,dq as Rt,bg as Re,ab as It,bS as Ie,S as Et,bv as Ee,s as K,av as Pt,dr as Ft,at as Bt,ds as Nt,dt as Dt,du as ve,dv as U,dw as Mt,dx as q,B as je}from"./index-NW0Z4UWR.js";import{d as Lt,s as $t,B as At}from"./bypassAdvisories-BhBeq_oI.js";import{C as Wt}from"./CodeView-C65Y5vXN.js";import{d as Ht}from"./writeState-DgYICTBE.js";import"./multipart-Bd_eOd8a.js";const Q=new Map,ee=(n,r=Ke())=>`${r}|${n}`;function zt(n){const r=qe(),[a,t]=d.useState(()=>n?Q.get(ee(n))??[]:[]),[c,y]=d.useState(!1),[s,u]=d.useState(null);return d.useEffect(()=>{if(!n){t([]),u(null);return}const m=Q.get(ee(n,r));if(m){t(m),u(null);return}if(typeof window>"u"||!window.dataverseAPI?.getEntityRelatedMetadata){t([]);return}let p=!1;return y(!0),u(null),window.dataverseAPI.getEntityRelatedMetadata(n,"OneToManyRelationships",["SchemaName","CascadeConfiguration","ReferencedEntity","ReferencingEntity"]).then(l=>{if(p)return;const v=l?.value,C=(Array.isArray(l)?l:Array.isArray(v)?v:[]).map(w=>({schemaName:w.SchemaName,deleteBehavior:w.CascadeConfiguration?.Delete??"NoCascade",full:w.CascadeConfiguration}));Q.set(ee(n,r),C),t(C),y(!1)}).catch(l=>{if(p)return;const v=l instanceof Error?l.message:String(l);u(v),y(!1)}),()=>{p=!0}},[n,r]),{rows:a,loading:c,error:s}}function Te(n){switch(n){case"Cascade":return 1;case"Restrict":return 2;case"Active":return 3;case"UserOwned":return 4;case"RemoveLink":return 5;case"NoCascade":return 6}}function Ot(n){return n==="Cascade"||n==="Active"||n==="UserOwned"}const Ce=()=>({table:"",recordId:null,scope:{kind:"whole-row"},concurrency:{kind:"none"},headers:St(),bypassCustomPlugins:!1,bypass:Ht(),confirmText:"",acknowledged:!1,dirty:new Set}),te=ft;function Qt({themeMode:n}){const r=Ge("delete"),a=_e("delete",be,Ce),[t,c]=d.useState(a.state),{table:y}=Ve(t.table||null),{allEntities:s}=Ye(),[u,m]=d.useState("target"),[p,l]=d.useState("builder"),[v,T]=d.useState(null),[C,w]=d.useState(!1),[h,x]=Je("delete"),[L,$]=d.useState(a.lastSavedId),[A,W]=d.useState(a.lastSavedHash),B=d.useMemo(()=>Xe(t),[t,y]),b=G(t.table),[Y,se]=d.useState(null),ae=Y&&t.recordId&&Y.id.toLowerCase()===t.recordId.toLowerCase()?Y.name:"",[H,P]=d.useState(null),[ie,J]=d.useState(!1),[Pe,z]=d.useState(null);d.useEffect(()=>{let o=!1;if(z(null),!t.recordId||!t.table||!b){P(null);return}if(!te(t.recordId)){P(null);return}if(typeof window>"u"||!window.dataverseAPI?.queryData){P(null);return}const g=new Set([b.primaryKey,b.primaryName]);for(const f of["accountnumber","emailaddress1","fullname","firstname","lastname","createdon","modifiedon"])b.columns.some(S=>S.logicalName===f)&&g.add(f);const k=`/${b.entitySetName}(${t.recordId})?$select=${[...g].join(",")}`;return P(null),z(null),J(!0),window.dataverseAPI.queryData(k).then(f=>{if(o)return;const S=f?.value,Ue=Array.isArray(S)?S[0]??null:S&&typeof S=="object"?S:f&&typeof f=="object"&&b.primaryKey in f?f:null;P(Ue),J(!1),z(null)}).catch(f=>{if(o)return;const S=f instanceof Error?f.message:String(f);P(null),J(!1),z(S)}),()=>{o=!0}},[t.recordId,t.table,b]);const j=ae||(H&&b?String(H[b.primaryName]??""):""),Fe=o=>c(g=>{const k=new Set(g.dirty);return k.add(o),{...g,dirty:k}}),I=(o,g,k)=>{c(f=>({...f,[o]:g})),k&&Fe(k)},N=t.scope.kind==="whole-row",Be=!N||t.confirmText.trim()===j.trim()&&j.length>0,F=d.useMemo(()=>Ze(t),[t]);Qe("delete",F,L,A);const Ne=d.useMemo(()=>Z(F),[F]),le=A===null?!0:Ne!==A,De=o=>{$(o.id),W(Z(o.state))},de=o=>{if(o.modeId!=="delete")return;const g=o.state;if(s.length>0&&!s.some(k=>k.logicalName===g.table)){xt(`Can't load "${o.name}": entity \`${g.table}\` isn't available in this environment. The solution may have been removed or you may be connected to a different org.`);return}c(be(g)),$(o.id),W(Z(g)),T(null),m("target")},Me=o=>{const g=Ct(o,"delete");if(!g)return;const k=L,f=A;de(g),$(k),W(f)},ce=ye(De);et("delete",o=>{o.modeId==="delete"&&(c(Rt(Ce(),o)),T(null),l("builder"),m("target"))});const ue=ye(de);tt(d.useMemo(()=>t.table?{state:F,modeId:"delete",dirty:le,lastSavedId:L,onSaved:ce,onLoadSaved:ue}:null,[F,le,L,t.table,ce,ue]));const he=d.useMemo(()=>{const o=[];return o.push(...Lt(t.bypass,"bypass")),o.push(...ot({op:"delete",concurrency:t.concurrency,bypass:t.bypass,bypassCustomPlugins:t.bypassCustomPlugins})),t.table&&t.recordId&&!te(t.recordId)&&o.push({id:"del-bad-guid",severity:"error",source:"validation",focusNode:"target",title:"Invalid record id",body:`"${t.recordId}" isn't a valid GUID. DELETE will fail at the wire.`}),t.scope.kind==="single-property"&&o.push({id:"del-single-property-unsupported",severity:"error",source:"validation",focusNode:"scope",title:"Single-property DELETE isn't supported by the PPTB host",body:e.jsxs(e.Fragment,{children:["DRS authors the correct URL"," ",e.jsxs("code",{children:["DELETE /",t.table?"&lt;set&gt;":"","(<id>)/<column>"]}),", but PPTB's ",e.jsx("code",{children:"dataverseAPI"})," only exposes whole-row delete — there's no raw-request hook for property-path URLs. To clear one column from inside PPTB, switch to"," ",e.jsx("strong",{children:"Update mode"})," and set the column to ",e.jsx("code",{children:"null"}),". To use the property-DELETE pattern, copy the URL from the URL bar (or the Code-tab"," ",e.jsx("code",{children:"fetch"})," snippet) and run it from Postman / curl / the JS SDK / Power Automate."]})}),o},[t.bypass,t.bypassCustomPlugins,t.concurrency,t.table,t.recordId,t.scope]),Le=nt(he),$e=b?t.recordId?te(t.recordId)?t.scope.kind==="single-property"&&!t.scope.column?"Pick a column to clear.":t.concurrency.kind==="etag"&&ge(t.concurrency.etag)?ge(t.concurrency.etag):t.headers.some(o=>o.enabled&&!o.name)?"Fix empty header name.":N&&ie&&!ae?"Loading the record…":N&&!j?"Waiting for record metadata — pick again or check the GUID.":N&&!Be?`Type the record name "${j}" to confirm.`:N&&!t.acknowledged?"Acknowledge that this action cannot be undone.":Le:"Record id is not a valid GUID.":"Pick a record to delete.":"Pick a target table first.",Ae=async()=>{w(!0);const o=await jt.delete(t,xe(me,null));T(o),w(!1),l("results"),x(Tt({snapshot:F,modeId:"delete",url:B.relativeUrl,method:"DELETE",status:o.status,ms:o.ms,rowCount:o.ok?1:0})),c(g=>({...g,dirty:new Set,confirmText:"",acknowledged:!1}))},me=d.useMemo(()=>rt(t),[t]),We=t.scope.kind==="whole-row"?"row":`clear ${t.scope.column??"?"}`,pe=t.concurrency.kind==="etag"?"If-Match: etag":"none",O=t.scope.kind==="whole-row",X=!O||t.confirmText.trim()===j.trim()&&j.length>0&&t.acknowledged,He=[{id:"target",label:"Target",meta:b?`${b.displayName} record`:"Pick a table",items:[{id:"target",icon:at,iconFilled:st,label:t.recordId?j||`${b?.displayName??""} (selected)`:"Pick a record",dirty:t.dirty.has("target")},{id:"scope",icon:it,iconFilled:_,label:t.scope.kind==="whole-row"?"Whole row":`Clear ${t.scope.column||"?"}`,code:t.scope.kind==="single-property",badge:We,badgeAppearance:"ghost",dirty:t.dirty.has("scope")}]},{id:"confirmation",label:"Confirmation",meta:O?X?"✓ ready":"incomplete":"n/a for single property",items:[{id:"confirmation",icon:fe,iconFilled:D,label:"Type-to-confirm + ack",badge:O?X?"✓":"required":"skipped",badgeAppearance:"tint",badgeColor:O?X?"success":"danger":"subtle",dirty:t.dirty.has("confirmation")}]},{id:"precondition",label:"Precondition",meta:pe,items:[{id:"precondition",icon:fe,iconFilled:D,label:"Optimistic concurrency",badge:pe,badgeAppearance:"ghost",dirty:t.dirty.has("precondition")}]},{id:"headers",label:"Headers",meta:`${t.headers.filter(o=>o.enabled).length+(t.concurrency.kind!=="none"?1:0)} active`,items:[{id:"headers",icon:dt,iconFilled:lt,label:"HTTP headers",badge:t.headers.filter(o=>o.enabled).length||null,dirty:t.dirty.has("headers")},{id:"bypass",icon:V,iconFilled:V,label:"Bypass logic",badge:$t(t.bypass),badgeAppearance:t.bypass.businessLogic!=="none"||t.bypass.suppressFlows?"tint":"ghost",badgeColor:t.bypass.businessLogic!=="none"||t.bypass.suppressFlows?"warning":"subtle",dirty:t.dirty.has("bypass")}]}];let E;switch(u){case"target":E=e.jsx(Ut,{state:t,row:H,rowLoading:ie,rowError:Pe,primaryName:j,tbl:b,onTableChange:o=>{c(g=>({...g,table:o,recordId:null,scope:{kind:"whole-row"},confirmText:"",acknowledged:!1,dirty:new Set(["target","scope"])})),T(null),se(null),$(void 0),W(null)},onRecordChange:(o,g)=>{I("recordId",o,"target"),se(o&&g?{id:o,name:g}:null)},onProceedToConfirmation:()=>m("confirmation")});break;case"confirmation":E=e.jsx(qt,{state:t,row:H,primaryName:j,tbl:b,onConfirmText:o=>I("confirmText",o,"confirmation"),onAck:o=>I("acknowledged",o,"confirmation"),onBackToTarget:()=>m("target")});break;case"scope":E=e.jsx(Gt,{table:t.table,scope:t.scope,setScope:o=>I("scope",o,"scope")});break;case"precondition":E=e.jsx(ut,{mode:t.concurrency,setMode:o=>I("concurrency",o,"precondition"),available:["none","etag"],group:"write"});break;case"headers":E=e.jsx(ct,{items:t.headers,setItems:o=>I("headers",o,"headers"),group:"write"});break;case"bypass":E=e.jsx(At,{value:t.bypass,onChange:o=>I("bypass",o,"bypass"),group:"write"});break}const ze=xe(me,null),Oe={method:"DELETE",built:B,headers:ze,entityLogical:B.entityLogical};return e.jsx(ht,{sidebar:e.jsx(gt,{type:r,urlPreview:B.relativeNoBase,sections:He,activeNode:u,onSelect:o=>{m(o),l("builder")},recents:h,onRecentClick:Me}),urlBar:e.jsx(yt,{method:"DELETE",url:B.relativeUrl,executeVerb:r.executeVerb,writeConfirm:{operation:t.scope.kind==="whole-row"?"Delete Record":`Clear column ${t.scope.column??""}`.trim(),table:t.table,scope:{kind:"records",count:1},highImpact:!1},executeIcon:_,disabledReason:$e,loading:C,onExecute:Ae,advisories:he,onAdvisoryFocus:m}),children:e.jsxs(mt,{tab:p,onTabChange:l,resultCount:v?.ok?1:null,children:[p==="builder"&&E,p==="code"&&e.jsx(Wt,{themeMode:n,inputs:Oe}),p==="results"&&e.jsx(pt,{result:v,mode:"single",table:t.table,writeContext:{operation:"delete",table:t.table,recordId:t.recordId,recordName:j,clearedColumn:t.scope.kind==="single-property"?t.scope.column:null}})]})})}function Ut({state:n,row:r,rowLoading:a,rowError:t,primaryName:c,tbl:y,onTableChange:s,onRecordChange:u,onProceedToConfirmation:m}){const p=Re(),l=n.scope.kind==="whole-row",v=(()=>{if(!r||!y)return null;const T=["accountnumber","emailaddress1",y.primaryKey];for(const C of T){const w=r[C];if(typeof w=="string"&&w.length>0)return w}return null})();return e.jsxs("div",{children:[e.jsx(M,{icon:_,title:l?c?`Delete ${c}`:"Delete record":`Clear ${n.scope.kind==="single-property"?n.scope.column:""}`,sub:l?`This will issue DELETE on the row with ID ${n.recordId??"<no id>"}`:`This will clear a single column on row ${n.recordId??"<no id>"}`,group:"write"}),e.jsx(ne,{layout:"multiline",intent:l?"error":"warning",icon:e.jsx(V,{}),style:{marginBottom:14},children:e.jsxs(re,{children:[e.jsx(Se,{children:l?"This is a destructive, irreversible request.":"Clearing a column is also irreversible."}),l?"Pick the record below. The Confirmation pane will show which relationships may cascade and require a typed name + acknowledgement before Execute lights up.":"The column value is set to null on the row. Other columns are unaffected."]})}),e.jsx("div",{style:{maxWidth:720,marginBottom:14},children:e.jsx(It,{table:n.table,onTableChange:s,recordId:n.recordId,onRecordChange:u,group:"write",sub:"Single-record delete — pick the entity set and the record."})}),n.recordId&&e.jsx("div",{className:Ee(p.inlineCard,p.inlineCardDanger),style:{padding:14,marginBottom:14,maxWidth:880},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:c&&y?e.jsx(e.Fragment,{children:e.jsx(Ie,{size:"huge",name:c,primaryText:c,secondaryText:`${y.primaryKey}: ${String((r&&r[y.primaryKey])??n.recordId)}`,tertiaryText:[`${y.displayName} · ${y.entitySetName}`,v,a?"resolving extra fields…":null].filter(Boolean).join(" · "),avatar:{color:"red"}})}):a?e.jsxs(e.Fragment,{children:[e.jsx(Et,{size:"small"}),e.jsx(R,{style:{color:i.colorNeutralForeground3},children:"Resolving record metadata…"})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{style:{color:i.colorPaletteRedForeground1,width:32,height:32}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600},children:"Couldn't resolve this record"}),e.jsxs(R,{style:{color:i.colorNeutralForeground3,marginTop:4},children:["GUID"," ",e.jsx("code",{style:{fontFamily:i.fontFamilyMonospace},children:n.recordId})," ","didn't resolve in ",e.jsx("code",{children:n.table}),". The record may already be deleted, you might not have read access, or the metadata is still loading.",t&&e.jsxs(e.Fragment,{children:[" ","Server response:"," ",e.jsx("code",{style:{fontFamily:i.fontFamilyMonospace},children:t})]})]})]})]})})}),n.recordId&&l&&c&&e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginTop:8},children:[e.jsx(K,{appearance:"primary",onClick:m,children:"Continue →"}),e.jsx(R,{style:{color:i.colorNeutralForeground3},children:"Next: review the relationships that may be affected, then type the record name to confirm."})]})]})}function qt({state:n,row:r,primaryName:a,tbl:t,onConfirmText:c,onAck:y,onBackToTarget:s}){const u=Re(),m=n.scope.kind==="whole-row";return n.recordId?m?e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,gap:0},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsx(M,{icon:D,title:a?`Confirm: delete ${a}`:"Confirm delete",sub:"Review what may be affected, then type the record name and acknowledge.",group:"write"})}),a&&t&&e.jsxs("div",{className:Ee(u.inlineCard,u.inlineCardDanger),style:{padding:"10px 14px",marginBottom:14,display:"flex",alignItems:"center",gap:12,flexShrink:0},children:[e.jsx(Ie,{size:"medium",name:a,primaryText:a,secondaryText:`${t.primaryKey}: ${String((r&&r[t.primaryKey])??n.recordId)} · ${t.displayName}`,avatar:{color:"red"}}),e.jsx("span",{style:{flex:1}}),e.jsx(K,{size:"small",appearance:"subtle",onClick:s,children:"Change target"})]}),t&&t.navigationProperties.some(p=>p.cardinality!=="ManyToOne")&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 0",minHeight:0,marginBottom:14},children:[e.jsx("strong",{style:{fontSize:12,display:"block",marginBottom:6,flexShrink:0},children:"Related relationships that may be affected"}),e.jsx("div",{style:{flex:"1 1 0",minHeight:120,overflow:"auto",border:`1px solid ${i.colorNeutralStroke2}`,borderRadius:i.borderRadiusMedium,background:i.colorNeutralBackground1},children:e.jsx(Kt,{table:n.table})}),e.jsxs(R,{style:{display:"block",marginTop:6,color:i.colorNeutralForeground3,flexShrink:0},children:["Sorted by severity — ",e.jsx("strong",{children:"Cascade"})," (parental — children will be deleted) and"," ",e.jsx("strong",{children:"Restrict"})," (delete blocked if children exist) are highlighted at the top. Behaviors come from each relationship's ",e.jsx("code",{children:"CascadeConfiguration.Delete"}),"; row counts aren't shown."]})]}),a&&e.jsxs("div",{className:u.inlineCard,style:{padding:14,maxWidth:720,flexShrink:0},children:[e.jsx("strong",{style:{fontSize:12,display:"block",marginBottom:8},children:"Type the record name to confirm"}),e.jsx(oe,{label:e.jsxs("span",{children:["Expected:"," ",e.jsx("strong",{style:{fontFamily:i.fontFamilyMonospace},children:a})]}),validationState:n.confirmText&&n.confirmText.trim()===a.trim()?"success":n.confirmText?"error":"none",validationMessage:n.confirmText&&n.confirmText.trim()!==a.trim()?"Doesn't match — copy the name above exactly.":n.confirmText.trim()===a.trim()&&a.length>0?"Match — Execute is unlocked once you check the box below.":void 0,children:e.jsx(Pt,{value:n.confirmText,onChange:(p,l)=>c(l.value),placeholder:"Type to confirm…",contentAfter:n.confirmText.trim()===a.trim()&&a.length>0?e.jsx(Ft,{style:{color:i.colorPaletteGreenForeground1}}):void 0})}),e.jsx("div",{style:{marginTop:10},children:e.jsx(Bt,{checked:n.acknowledged,onChange:(p,l)=>y(!!l.checked),label:"I understand this action cannot be undone."})})]})]}):e.jsxs("div",{children:[e.jsx(M,{icon:D,title:"Confirmation",sub:"Single-property delete doesn't require type-to-confirm — clearing one column is reversible by re-entering the value.",group:"write"}),e.jsx(ne,{layout:"multiline",intent:"info",style:{marginBottom:14,maxWidth:720},children:e.jsxs(re,{children:["Execute clears"," ",e.jsx("code",{children:n.scope.kind==="single-property"?n.scope.column:""})," on"," ",e.jsx("strong",{children:a||n.recordId})," (",t?.displayName??n.table,"). Other columns are untouched."]})}),e.jsx(K,{appearance:"outline",onClick:s,children:"← Change target"})]}):e.jsxs("div",{children:[e.jsx(M,{icon:D,title:"Confirmation",sub:"Pick a record on the Target pane first — there's nothing to confirm yet.",group:"write"}),e.jsx(K,{appearance:"primary",onClick:s,children:"← Go to Target"})]})}function Kt({table:n}){const r=G(n),a=zt(n||null),t=d.useMemo(()=>{if(!r)return[];const c=new Map(a.rows.map(s=>[s.schemaName,s.deleteBehavior])),y=r.navigationProperties.filter(s=>s.cardinality!=="ManyToOne").map(s=>{const m=G(s.targetEntity)?.displayName??s.targetEntity,p=s.cardinality==="ManyToMany"?"RemoveLink":c.get(s.relationshipName)??null;return{nav:s,display:m,behavior:p}});return y.sort((s,u)=>{const m=s.behavior?Te(s.behavior):3.5,p=u.behavior?Te(u.behavior):3.5;return m!==p?m-p:s.display.localeCompare(u.display)}),y},[r,a.rows]);return!r||t.length===0?null:e.jsxs(Nt,{size:"small","aria-label":"Cascade impact preview",style:{width:"max-content",minWidth:"100%"},children:[e.jsx(Dt,{children:e.jsxs(ve,{style:{position:"sticky",top:0,zIndex:1,backgroundColor:i.colorNeutralBackground1},children:[e.jsx(U,{style:{minWidth:180,position:"sticky",top:0,backgroundColor:i.colorNeutralBackground1,borderBottom:`1px solid ${i.colorNeutralStroke2}`},children:"Related table"}),e.jsx(U,{style:{minWidth:80,position:"sticky",top:0,backgroundColor:i.colorNeutralBackground1,borderBottom:`1px solid ${i.colorNeutralStroke2}`},children:"Cardinality"}),e.jsx(U,{style:{minWidth:260,position:"sticky",top:0,backgroundColor:i.colorNeutralBackground1,borderBottom:`1px solid ${i.colorNeutralStroke2}`},children:"Schema name"}),e.jsx(U,{style:{minWidth:180,position:"sticky",top:0,backgroundColor:i.colorNeutralBackground1,borderBottom:`1px solid ${i.colorNeutralStroke2}`},children:"Delete behavior"})]})}),e.jsx(Mt,{children:t.map(({nav:c,display:y,behavior:s})=>{const u=!!s&&Ot(s),m=s==="Restrict",p=s??(a.loading?"loading…":"unknown"),l=u?"danger":m?"warning":"subtle";return e.jsxs(ve,{style:{borderLeft:u?`3px solid ${i.colorPaletteRedBorder2}`:m?`3px solid ${i.colorPaletteYellowBorder2}`:"3px solid transparent"},children:[e.jsx(q,{style:{minWidth:180},children:e.jsx("span",{style:{fontWeight:600},children:y})}),e.jsx(q,{style:{minWidth:80},children:e.jsx(je,{appearance:"ghost",children:c.cardinality==="OneToMany"?"1:N":c.cardinality==="ManyToMany"?"N:N":"N:1"})}),e.jsx(q,{style:{minWidth:260},children:e.jsx("code",{style:{fontFamily:i.fontFamilyMonospace,fontSize:11,color:i.colorNeutralForeground3,whiteSpace:"nowrap"},children:c.name})}),e.jsx(q,{style:{minWidth:180},children:e.jsx(je,{appearance:"tint",color:l,size:"small",style:{fontFamily:i.fontFamilyMonospace},children:p})})]},c.name)})})]})}function Gt({table:n,scope:r,setScope:a}){const t=G(n),c=bt(),y=r.kind==="single-property"?r.column:null,s=d.useMemo(()=>(t?.columns??[]).filter(h=>(wt(h,c)||h.logicalName===y)&&h.attributeType!=="Uniqueidentifier"&&h.attributeType!=="File"&&h.attributeType!=="Image"&&!h.required).slice().sort((h,x)=>h.displayName.localeCompare(x.displayName)),[t,c,y]),[u,m]=d.useState(""),[p,l]=d.useState(!1);d.useEffect(()=>{(r.kind==="whole-row"||!r.column)&&(m(""),l(!1))},[r]);const T=(r.kind==="single-property"?s.find(h=>h.logicalName===r.column):void 0)?.displayName??(r.kind==="single-property"?r.column:""),C=d.useMemo(()=>{if(!u)return s;const h=u.toLowerCase();return s.filter(x=>x.displayName.toLowerCase().includes(h)||x.logicalName.toLowerCase().includes(h)||x.attributeType.toLowerCase().includes(h))},[s,u]),w=p?u:T;return e.jsxs("div",{children:[e.jsx(M,{icon:_,title:"Delete scope",sub:"Remove the entire row, or just clear one column's value.",group:"write"}),r.kind==="single-property"&&e.jsx(ne,{layout:"multiline",intent:"warning",style:{marginBottom:14,maxWidth:720},children:e.jsxs(re,{children:[e.jsx(Se,{children:"Author-only inside PPTB"}),"PPTB's ",e.jsx("code",{children:"dataverseAPI"})," doesn't expose property-path DELETE — only whole-row. DRS shows the correct URL + code so you can copy it for use outside (Postman, curl, SDK, Flow). To clear one column from inside PPTB, use ",e.jsx("strong",{children:"Update mode"})," ","and set the column to ",e.jsx("code",{children:"null"}),"."]})}),e.jsxs("div",{style:{maxWidth:720},children:[e.jsx(oe,{label:"Scope",children:e.jsxs(kt,{value:r.kind,onChange:(h,x)=>{x.value==="whole-row"?a({kind:"whole-row"}):a({kind:"single-property",column:r.kind==="single-property"?r.column:""})},children:[e.jsx(we,{value:"whole-row",label:e.jsxs("span",{children:[e.jsx("strong",{children:"Whole row"})," ·"," ",e.jsxs("code",{style:{fontFamily:i.fontFamilyMonospace,fontSize:11},children:["DELETE /",t?.entitySetName??"set","(<id>)"]}),e.jsx(R,{style:{display:"block",color:i.colorNeutralForeground3,marginTop:2},children:"Removes the entire record. Cascading delete behavior follows the relationship configuration."})]})}),e.jsx(we,{value:"single-property",label:e.jsxs("span",{children:[e.jsx("strong",{children:"Single property"})," ·"," ",e.jsxs("code",{style:{fontFamily:i.fontFamilyMonospace,fontSize:11},children:["DELETE /",t?.entitySetName??"set","(<id>)/<column>"]}),e.jsx(R,{style:{display:"block",color:i.colorNeutralForeground3,marginTop:2},children:"Clears the value of one column. Required columns and lookups (single-valued navigation properties) aren't supported via this path."})]})})]})}),r.kind==="single-property"&&e.jsx("div",{style:{marginTop:14,maxWidth:480},children:e.jsx(oe,{label:"Column to clear",hint:`${s.length} clearable column${s.length===1?"":"s"} on this entity. Type to filter. Required columns and lookup navigation properties are excluded.`,children:e.jsxs(vt,{freeform:!0,clearable:!0,value:w,selectedOptions:r.column?[r.column]:[],onChange:h=>{const x=h.target.value;m(x),l(!0),!x&&r.column&&a({kind:"single-property",column:""})},onOptionSelect:(h,x)=>{if(!x.optionValue){a({kind:"single-property",column:""}),m(""),l(!1);return}a({kind:"single-property",column:x.optionValue}),m(""),l(!1)},placeholder:"Type to search columns…",listbox:{style:{maxHeight:360}},children:[C.length===0&&e.jsx(ke,{value:"__none",text:"",disabled:!0,children:e.jsxs(R,{style:{color:i.colorNeutralForeground3},children:["No columns match “",u,"”"]})}),C.map(h=>e.jsx(ke,{value:h.logicalName,text:h.displayName,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx("span",{children:h.displayName}),e.jsxs(R,{style:{color:i.colorNeutralForeground3},children:[h.logicalName," ·"," ",e.jsx("span",{style:{color:i.colorBrandForeground2},children:h.attributeType})]})]})},h.logicalName))]})})})]})]})}export{Qt as DeleteMode};
@@ -0,0 +1,2 @@
1
+ import{f as Me,bh as De,r as n,R as $e,u as Fe,U as Le,c4 as Be,c5 as He,z as O,c6 as ze,bW as J,bX as Oe,bj as We,W as qe,bY as de,X as Ue,c7 as Ve,bl as _e,Y as X,Z as ce,_ as Xe,$ as Ye,a0 as Ge,b_ as Ke,b$ as Ze,bN as Z,bO as Je,a7 as Qe,a8 as et,j as e,a9 as tt,ab as at,c1 as st,ad as ue,ae as rt,af as ot,ag as nt,c2 as Y,ah as it,ai as lt,c8 as ge,b8 as dt,ay as he,M as G,m as K,o as me,aP as ct,t as l,C as A,S as ut,c9 as gt,bg as ht,bv as mt,b9 as pt,ax as yt,bx as bt,aj as vt,B as ft}from"./index-NW0Z4UWR.js";import{t as be,N as xt,A as St,a as jt}from"./AllOrNothingOption-C7wGq_-r.js";import{C as Nt}from"./CodeView-C65Y5vXN.js";import"./multipart-Bd_eOd8a.js";const Tt=()=>({table:"",sourceId:null,navProperty:null,targetIds:[],targetNames:{},headers:vt(),dirty:new Set});function At({themeMode:o}){const p=Me("disassociate"),g=De("disassociate",ge,Tt),[t,y]=n.useState(g.state),{table:N}=$e(t.table||null),{allEntities:d}=Fe(),[T,f]=n.useState("source"),[x,c]=n.useState("builder"),[k,M]=n.useState(null),[W,Q]=n.useState(!1),[ve,fe]=Le("disassociate"),[D,$]=n.useState(g.lastSavedId),[F,L]=n.useState(g.lastSavedHash),[ee,q]=n.useState(""),[b,S]=n.useState(null),[te,I]=n.useState(!1),[U,B]=n.useState(null),P=n.useMemo(()=>Be(t),[t,N]),h=n.useMemo(()=>He(t),[t,N]),v=O(t.table),r=t.navProperty?v?.navigationProperties.find(a=>a.name===t.navProperty):void 0,ae=r?ze(r):!1,m=r?J(r):!1,C=m?"PATCH":"DELETE",V=ae&&Oe(t.allOrNothing,h.length);n.useEffect(()=>{let a=!1;if(B(null),!m||!t.sourceId||!v||!r){S(null),I(!1);return}if(typeof window>"u"||!window.dataverseAPI?.queryData){S(null),I(!1),B("The PPTB host is not available, so the current value cannot be read.");return}S(null),I(!0);const s=`_${r.referencingAttribute||r.name}_value`,u=`/${v.entitySetName}(${t.sourceId})?$select=${s}`;return window.dataverseAPI.queryData(u).then(i=>{if(a)return;const R=i?.value,z=Array.isArray(R)?R[0]??null:R&&typeof R=="object"?R:i&&typeof i=="object"&&(s in i||v.primaryKey in i)?i:null;if(!z)B("Dataverse returned no row for the source record.");else{const le=String(z[s]??""),Re=String(z[`${s}@OData.Community.Display.V1.FormattedValue`]??""),Ae=String(z[`${s}@Microsoft.Dynamics.CRM.lookuplogicalname`]??"");S(le?{id:le,name:Re||null,entity:Ae||null}:null)}I(!1)}).catch(i=>{a||(S(null),I(!1),B(i instanceof Error?i.message:String(i)))}),()=>{a=!0}},[m,t.sourceId,t.navProperty,v,r]);const _=a=>y(s=>{const u=new Set(s.dirty);return u.add(a),{...s,dirty:u}}),E=(a,s,u)=>{y(i=>({...i,[a]:s})),u&&_(u)},H=We([["Source record id",t.sourceId],...t.targetIds.map(a=>["Target record id",a])],[["Navigation property",t.navProperty]]),se=qe([{when:!v,id:"disassoc-table",title:"Pick a source table first.",focusNode:"source"},{when:!t.sourceId,id:"disassoc-source",title:"Pick a source record.",focusNode:"source"},{when:!t.navProperty,id:"disassoc-nav",title:"Pick a navigation property.",focusNode:"nav"},{when:ae&&t.targetIds.length===0,id:"disassoc-targets",title:"Pick at least one target record to disassociate.",focusNode:"target"},{when:m&&b===null&&!te&&!U,id:"disassoc-lookup-empty",title:"Source's lookup is already empty — nothing to disassociate.",focusNode:"target"},{when:V&&h.length>de,id:"disassoc-change-set-cap",title:`All or nothing sends at most ${de} requests in one change set; this has ${h.length}. Remove targets or turn it off.`,focusNode:"target"},{when:t.headers.some(a=>a.enabled&&!a.name),id:"disassoc-header-name",title:"Fix empty header name.",focusNode:"headers"},{when:H,id:"disassoc-url-part",title:H??"",focusNode:H?.startsWith("Target")?"target":H?.startsWith("Navigation")?"nav":"source"}]),xe=Ue(se),Se=async()=>{Q(!0);const a=await pt.disassociate(t,ue(t.headers,null));M(a),Q(!1),c("results"),fe(yt({snapshot:j,modeId:"disassociate",url:P.relativeUrl,method:C,status:a.status,ms:a.ms,rowCount:Y(a,h.length)??0,summary:`${Y(a,h.length)??0} of ${h.length} unlinked`})),y(s=>({...s,dirty:new Set}))},j=n.useMemo(()=>Ve(t),[t]);_e("disassociate",j,D,F);const je=n.useMemo(()=>X(j),[j]),re=F===null?!0:je!==F,Ne=a=>{$(a.id),L(X(a.state))},oe=a=>{if(a.modeId!=="disassociate")return;const s=a.state;if(d.length>0&&!d.some(u=>u.logicalName===s.table)){dt(`Can't load "${a.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}y(ge(s)),$(a.id),L(X(s)),M(null),q(""),f("source")},Te=a=>{const s=bt(a,"disassociate");if(!s)return;const u=D,i=F;oe(s),$(u),L(i)},ne=ce(Ne),ie=ce(oe);Xe(n.useMemo(()=>t.table?{state:j,modeId:"disassociate",dirty:re,lastSavedId:D,onSaved:ne,onLoadSaved:ie}:null,[j,re,D,t.table,ne,ie]));const ke=[{id:"source",label:"Target",meta:v?.displayName??"Pick a table",items:[{id:"source",icon:Ge,iconFilled:Ye,label:t.sourceId?ee||`${v?.displayName??""} (selected)`:"Pick a record",badge:r?C:null,badgeAppearance:"tint",badgeColor:"brand",dirty:t.dirty.has("source")}]},{id:"relationship",label:"Relationship",meta:r?ye(r.cardinality):"pick one",items:[{id:"nav",icon:Ze,iconFilled:Ke,label:r?r.name:"Navigation property",code:!!r,badge:r?ye(r.cardinality):null,badgeAppearance:"ghost",dirty:t.dirty.has("nav")}]},{id:"target",label:"Related",meta:m?b?`clear: ${b.name??b.id.slice(0,8)}…`:U?"value unknown":"lookup empty":t.targetIds.length?`${t.targetIds.length} target${t.targetIds.length===1?"":"s"}`:"none",items:[{id:"target",icon:Je,iconFilled:Z,label:m?"Target — implicit":be(!1,t.targetIds.length),badge:m?"∅":t.targetIds.length||null,badgeAppearance:"tint",badgeColor:t.targetIds.length>0?"success":"subtle",dirty:t.dirty.has("target")}]},{id:"headers",label:"Headers",meta:`${t.headers.filter(a=>a.enabled).length} active`,items:[{id:"headers",icon:et,iconFilled:Qe,label:"HTTP headers",badge:t.headers.filter(a=>a.enabled).length||null,dirty:t.dirty.has("headers")}]}];let w;switch(T){case"source":w=e.jsx(at,{table:t.table,onTableChange:a=>{y(s=>({...s,table:a,sourceId:null,navProperty:null,targetIds:[],targetNames:{},dirty:new Set(["source","nav","target"])})),q(""),S(null),M(null),$(void 0),L(null)},recordId:t.sourceId,onRecordChange:(a,s)=>{E("sourceId",a,"source"),q(s??"")},group:"relate",sub:"Pick the source record holding the relationship link to remove."});break;case"nav":w=e.jsx("div",{children:e.jsx(xt,{table:t.table,value:t.navProperty,onChange:a=>{y(s=>({...s,navProperty:a,targetIds:[],targetNames:{}})),_("nav"),_("target")},group:"relate",forOperation:"disassociate",footer:r&&e.jsx(It,{nav:r})})});break;case"target":w=e.jsx(kt,{state:t,setTargetIds:a=>E("targetIds",a,"target"),targetNames:t.targetNames,setTargetNames:a=>E("targetNames",a),setAllOrNothing:a=>E("allOrNothing",a||void 0,"target"),changeSet:V,currentLookup:b,currentLookupLoading:te,currentLookupError:U});break;case"headers":w=e.jsx(tt,{policy:"relate",items:t.headers,setItems:a=>E("headers",a,"headers"),group:"relate"});break}const Ie=st(C,ue(t.headers,null)),Pe=h[0],Ce={method:C,built:P,headers:Ie,body:Pe?.body,entityLogical:P.entityLogical,multiRequests:h.length>1?h.map(a=>({method:a.method,relativeUrl:a.relativeUrl,body:a.body,description:a.targetId?`target ${a.targetId}`:"clear lookup (null)"})):void 0,changeSet:V},Ee=m?b?.name?[b.name]:[]:t.targetIds.map(a=>t.targetNames[a]).filter(a=>!!a),we=m?b?1:0:t.targetIds.length;return e.jsx(rt,{sidebar:e.jsx(lt,{type:p,urlPreview:P.relativeNoBase,sections:ke,activeNode:T,onSelect:a=>{f(a),c("builder")},recents:ve,onRecentClick:Te}),urlBar:e.jsx(it,{method:C,url:P.relativeUrl,executeVerb:p.executeVerb,writeConfirm:{operation:r?`Disassociate (${r.name})`:"Disassociate",table:t.table,scope:{kind:"records",count:Math.max(1,t.targetIds.length)},highImpact:t.targetIds.length>1},disabledReason:xe,loading:W,onExecute:Se,advisories:se,onAdvisoryFocus:f}),children:e.jsxs(ot,{tab:x,onTabChange:c,resultCount:Y(k,h.length),children:[x==="builder"&&w,x==="code"&&e.jsx(Nt,{themeMode:o,inputs:Ce}),x==="results"&&e.jsx(nt,{result:k,mode:"single",table:t.table,writeContext:{operation:"disassociate",table:t.table,recordId:t.sourceId,recordName:ee||null,navProperty:t.navProperty??void 0,targetCount:we,targetNames:Ee,targetNameById:t.targetNames}})]})})}function kt({state:o,setTargetIds:p,targetNames:g,setTargetNames:t,setAllOrNothing:y,changeSet:N,currentLookup:d,currentLookupLoading:T,currentLookupError:f}){const x=O(o.table),c=o.navProperty?x?.navigationProperties.find(W=>W.name===o.navProperty):void 0;if(!c)return e.jsxs("div",{children:[e.jsx(he,{icon:Z,title:be(!1,o.targetIds.length),sub:"Pick a navigation property first.",group:"relate"}),e.jsx(G,{layout:"multiline",intent:"info",style:{maxWidth:720},children:e.jsxs(K,{children:["Switch to the ",e.jsx("strong",{children:"Relationship"})," pane and pick a navigation property."]})})]});const k=O(c.targetEntity);return J(c)?e.jsxs("div",{children:[e.jsx(he,{icon:Z,title:"Target — implicit (single-valued)",sub:e.jsxs(e.Fragment,{children:["Single-valued nav props don't take a target id. The ",e.jsx("code",{children:"PATCH"})," body"," ",e.jsx("code",{children:`{ "${c.name}@odata.bind": null }`})," clears the lookup on the source row."]}),group:"relate"}),e.jsx(G,{layout:"multiline",intent:"warning",icon:e.jsx(ct,{}),style:{maxWidth:880,marginBottom:14},children:e.jsxs(K,{children:[e.jsx(me,{children:"This clears the lookup."}),e.jsx("code",{children:c.name})," on the source row becomes ",e.jsx("code",{children:"null"}),". The related row is"," ",e.jsx("strong",{children:"not"})," deleted — only the link is removed."]})}),e.jsxs("div",{style:{border:`1px solid ${l.colorNeutralStroke2}`,borderRadius:l.borderRadiusMedium,padding:12,maxWidth:560},children:[e.jsxs(A,{style:{color:l.colorNeutralForeground3,display:"block",marginBottom:8},children:["Current lookup value",T?" (loading…)":""]}),T?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(ut,{size:"tiny"}),e.jsx(A,{children:"Fetching the lookup's current value from Dataverse…"})]}):d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(gt,{size:28,name:d.name??void 0,color:"colorful"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600},children:d.name??"(name not available)"}),e.jsxs("div",{style:{fontFamily:l.fontFamilyMonospace,fontSize:10,color:l.colorNeutralForeground3},children:["/",(d.entity&&O(d.entity)?.entitySetName)??k?.entitySetName??c.targetEntity,"(",d.id,")"]})]})]}),d.entity&&d.entity!==c.targetEntity&&e.jsxs(A,{style:{display:"block",marginTop:8,color:l.colorNeutralForeground3},children:["The lookup currently references a ",e.jsx("code",{children:d.entity})," row, not"," ",e.jsx("code",{children:c.targetEntity}),"."]})]}):f?e.jsx(G,{layout:"multiline",intent:"warning",children:e.jsxs(K,{children:[e.jsx(me,{children:"Couldn't read the current value."}),"Execute still sends the ",e.jsx("code",{children:"PATCH"}),"; if the lookup is already empty it changes nothing. ",e.jsx("code",{children:f})]})}):e.jsx(A,{style:{color:l.colorNeutralForeground3,fontStyle:"italic"},children:"Source's lookup is already empty — the PATCH would be a no-op."})]})]}):e.jsx(St,{table:o.table,navProperty:o.navProperty,targets:o.targetIds,setTargets:p,targetNames:g,setTargetNames:t,group:"relate",resolvedMethod:null,verb:"DELETE",changeSet:N,footer:e.jsx(jt,{checked:!!o.allOrNothing,onChange:y,targets:o.targetIds.length,verb:"DELETE"}),sub:e.jsxs(e.Fragment,{children:["Pick one or more ",e.jsx("code",{children:k?.logicalName})," rows to remove from the collection.",N?"The DELETE requests go together as one change set":"Each fires a separate DELETE request per docs"," ","— the target rows are ",e.jsx("strong",{children:"not"})," deleted, only the links."]})})}function It({nav:o}){const p=ht(),g=J(o);return e.jsxs("div",{className:mt(p.inlineCard),style:{padding:12},children:[e.jsx("strong",{style:{fontSize:12,display:"block",marginBottom:8},children:"URL shape per cardinality"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:10},children:[e.jsx(pe,{label:"Collection-valued (1:N / N:N)",syntax:"DELETE /<set>(<id>)/<nav>(<related-id>)/$ref",note:"One DELETE per target id.",active:!g}),e.jsx(pe,{label:"Single-valued (N:1)",syntax:`PATCH /<set>(<id>)
2
+ { "<nav>@odata.bind": null }`,note:"Clears the lookup — docs-preferred over DELETE/$ref (and the only path PPTB exposes).",active:g})]})]})}function pe({label:o,syntax:p,note:g,active:t}){return e.jsxs("div",{style:{padding:10,border:`1px solid ${t?l.colorBrandStroke1:l.colorNeutralStroke2}`,background:t?l.colorBrandBackground2:"transparent",borderRadius:l.borderRadiusMedium,opacity:t?1:.55},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx("strong",{style:{fontSize:11},children:o}),t&&e.jsx(ft,{appearance:"tint",color:"brand",size:"small",style:{marginLeft:"auto",fontWeight:700},children:"ACTIVE"})]}),e.jsx("code",{style:{fontFamily:l.fontFamilyMonospace,fontSize:11,wordBreak:"break-all",display:"block",whiteSpace:"pre-wrap"},children:p}),e.jsx(A,{style:{display:"block",marginTop:4,color:l.colorNeutralForeground3},children:g})]})}function ye(o){switch(o){case"OneToMany":return"1:N";case"ManyToOne":return"N:1";case"ManyToMany":return"N:N"}}export{At as DisassociateMode};
@@ -0,0 +1 @@
1
+ import{bg as je,j as s,c0 as Re,t as k,B as K,aW as Ce,s as Ie,ao as we,ap as Ae,C as Ne,bv as $e,f as Be,bh as Pe,r as o,U as Te,w as Q,R as Ee,dD as Me,dE as Fe,u as Le,dF as Oe,bj as Ve,W as He,X as qe,dG as De,bl as ze,Y as L,Z as ee,cM as Ue,_ as We,aL as te,aM as Ge,$ as Je,a0 as Xe,a$ as Ye,b0 as ae,a7 as Ze,a8 as _e,a9 as Ke,M as N,m as $,o as se,ab as Qe,ad as ne,ae as et,af as tt,ag as at,ah as st,ai as nt,dH as ie,b8 as it,b9 as ot,ax as rt,bx as dt,aj as lt,dI as ct}from"./index-NW0Z4UWR.js";import{A as ut,R as mt,a as pt}from"./ActionParamForm-DvTh6hUs.js";import{C as bt}from"./CodeView-C65Y5vXN.js";import"./OptionGroup-DYAAm_pt.js";import"./FieldSetEditor-Dg6WsDgG.js";import"./multipart-Bd_eOd8a.js";function ht({body:r,title:d="Request body preview",pillText:c,maxHeight:g=360}){const f=je(),t=JSON.stringify(r,null,2),u=Object.keys(r).length===0;return s.jsxs("div",{className:$e(f.inlineCard),style:{padding:12,maxWidth:980},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[s.jsx(Re,{style:{width:16,height:16,color:k.colorBrandForeground1}}),s.jsx("strong",{style:{fontSize:12},children:d}),c&&s.jsx(K,{appearance:"ghost",children:c}),u&&s.jsx(K,{appearance:"tint",color:"subtle",children:"empty"}),s.jsx("span",{style:{flexGrow:1}}),s.jsx(Ce,{content:"Copy body JSON",relationship:"label",children:s.jsx(Ie,{size:"small",appearance:"subtle",icon:s.jsx(Ae,{}),onClick:()=>{we(t,"the body JSON")},disabled:u})})]}),u?s.jsx(Ne,{style:{color:k.colorNeutralForeground3,fontStyle:"italic",display:"block",padding:"8px 4px"},children:"No parameters set yet. The wire body will appear here as you fill in the form above."}):s.jsx("pre",{style:{margin:0,padding:10,fontFamily:k.fontFamilyMonospace,fontSize:11,background:k.colorNeutralBackground3,borderRadius:k.borderRadiusSmall,maxHeight:g,overflow:"auto",whiteSpace:"pre"},children:t})]})}const gt={oob:{registryId:"exec-action",picker:{title:"Browse OOB actions",sub:"Out-of-the-box Dataverse actions exposed via the Microsoft.Dynamics.CRM namespace."},filter:r=>r.kind==="Action"&&r.source==="oob"},"custom-api":{registryId:"exec-customapi",picker:{title:"Browse Custom APIs",sub:"Custom API messages — modern replacement for custom process actions. Definition lives in the customapi table."},filter:r=>r.kind==="Action"&&r.source==="custom-api"},"custom-action":{registryId:"exec-customaction",picker:{title:"Browse Custom Process Actions",sub:"Legacy custom process actions — defined in Workflow designer with Category = Action."},filter:r=>r.kind==="Action"&&r.source==="custom-action"}},oe=r=>({actionName:null,boundRecordId:null,paramValues:{},headers:lt(),category:r,dirty:new Set});function Rt({themeMode:r,category:d}){const c=gt[d],g=Be(c.registryId),f=Pe(`exec-action:${d}`,ie,()=>oe(d)),[t,u]=o.useState(f.state),[B,S]=o.useState("pick"),[v,j]=o.useState("builder"),[O,P]=o.useState(null),[re,V]=o.useState(!1),[de,le]=Te(c.registryId),[n,H]=o.useState(void 0);o.useEffect(()=>{let e=!1;if(!t.actionName){H(void 0);return}return Q.find(t.actionName).then(a=>{e||H(a)}),()=>{e=!0}},[t.actionName]);const p=n&&n.binding.kind!=="unbound"?n.binding.entityType:null,{table:T}=Ee(p),y=o.useMemo(()=>Me(t),[t,n,T]),q=o.useMemo(()=>Fe(t),[t,n]),{allEntities:D}=Le(),[R,E]=o.useState(f.lastSavedId),[C,M]=o.useState(f.lastSavedHash),[ce,F]=o.useState(""),I=e=>u(a=>{const i=new Set(a.dirty);return i.add(e),{...a,dirty:i}}),w=(e,a,i)=>{u(b=>({...b,[e]:a})),i&&I(i)},[z,ue]=o.useState(null),[me,pe]=o.useState(!1);o.useEffect(()=>{if(d==="oob")return;let e=!1;return Oe().then(a=>{if(e)return;pe(!a.publishers);const i=[a.customApis?null:"customapis",a.customActions?null:"workflows"].filter(Boolean);ue(i.length>0?`${i.join(" and ")} table${i.length>1?"s":""}`:null)}).catch(()=>{}),()=>{e=!0}},[d]);const A=n?.binding.kind==="entity",l=n?.binding.kind==="entity"?n.binding.entityType:null,U=n?.parameters.length??0,W=Object.values(t.paramValues).filter(e=>!(e==null||typeof e=="string"&&e===""||Array.isArray(e)&&e.length===0)).length,m=(n?.parameters??[]).filter(e=>e.required).filter(e=>{const a=t.paramValues[e.name];return a==null||typeof a=="string"&&a===""||Array.isArray(a)&&a.length===0}),G=Ve(A?[["Bound record id",t.boundRecordId]]:[]),J=He([{when:!n,id:"action-pick",title:"Pick an action.",focusNode:"pick"},{when:A&&!t.boundRecordId,id:"action-bound-record",title:`Action '${n?.name}' is bound to ${l} — supply a source record.`,focusNode:"target"},{when:p&&!T,id:"action-binding-metadata",title:`Can't build the URL yet — ${p} table metadata isn't loaded.`,focusNode:A?"target":"pick"},{when:m.length>0,id:"action-required",title:`${m.length} required param${m.length===1?"":"s"} unset: ${m.slice(0,3).map(e=>e.name).join(", ")}${m.length>3?"…":""}`,focusNode:m[0]?`param:${m[0].name}`:"params"},{when:t.headers.some(e=>e.enabled&&!e.name),id:"action-header-name",title:"Fix empty header name.",focusNode:"headers"},{when:G,id:"action-url-part",title:G??"",focusNode:"target"}]),be=qe(J),he=async()=>{V(!0);const e=await ot.action(t,ne(t.headers,null));P(e),V(!1),j("results"),le(rt({snapshot:h,modeId:c.registryId,url:y.relativeUrl,method:"POST",status:e.status,ms:e.ms,rowCount:e.ok?1:0})),u(a=>({...a,dirty:new Set}))},h=o.useMemo(()=>De(t),[t]);ze(`exec-action:${d}`,h,R,C);const ge=o.useMemo(()=>L(h),[h]),X=C===null?!0:ge!==C,fe=e=>{E(e.id),M(L(e.state))},Y=async e=>{if(e.modeId!=="exec-action")return;const a=e.state,i=a.actionName?await Q.find(a.actionName).catch(()=>{}):void 0,b=i&&i.binding.kind!=="unbound"?i.binding.entityType:null;if(b&&D.length>0&&!D.some(ve=>ve.logicalName===b)){it(`Can't load "${e.name}": bound entity \`${b}\` isn't available in this environment.`);return}u(ie(a)),E(e.id),M(L(a)),P(null),F(""),S("pick")},ye=e=>{const a=dt(e,"exec-action");if(!a)return;const i=R,b=C;Y(a),E(i),M(b)},Z=ee(fe);Ue(c.registryId,e=>{e.modeId!=="exec-action"&&e.modeId!=="exec-customapi"&&e.modeId!=="exec-customaction"||(u(ct(oe(d),e)),P(null),F(""),j("builder"),S("pick"))});const _=ee(Y);We(o.useMemo(()=>t.actionName?{state:h,modeId:"exec-action",dirty:X,lastSavedId:R,onSaved:Z,onLoadSaved:_}:null,[h,X,R,t.actionName,Z,_]));const xe=[{id:"action",label:"Action",meta:n?n.binding.kind==="unbound"?"unbound":n.binding.kind==="collection"?`bound to ${p} collection`:`bound to ${l}`:"pick one",items:[{id:"pick",icon:Ge,iconFilled:te,label:n?.displayName??n?.name??`Pick ${d} action`,code:!!n,dirty:t.dirty.has("pick")}]},...A&&l?[{id:"binding",label:`Bound to ${l}`,meta:t.boundRecordId?"✓ record selected":"pick a record",items:[{id:"target",icon:Xe,iconFilled:Je,label:"Source record",badge:t.boundRecordId?"✓":null,badgeAppearance:"ghost",dirty:t.dirty.has("target")}]}]:[],{id:"request",label:"Parameters",meta:`${W} of ${U} param${U===1?"":"s"}`,items:[{id:"params",icon:ae,iconFilled:Ye,label:"Parameters",badge:m.length>0?`${m.length} req unset`:W||null,badgeAppearance:"tint",badgeColor:m.length>0?"danger":"success",dirty:t.dirty.has("params"),children:n?.parameters.filter(e=>e.required).map(e=>{const a=t.paramValues[e.name],i=!(a==null||a===""||Array.isArray(a)&&a.length===0);return{id:`param:${e.name}`,icon:ae,label:e.name,code:!0,badge:i?"✓":"req",badgeAppearance:"ghost",badgeColor:i?"subtle":"danger"}})??[]}]},{id:"headers",label:"Headers",meta:`${t.headers.filter(e=>e.enabled).length} active`,items:[{id:"headers",icon:_e,iconFilled:Ze,label:"HTTP headers",badge:t.headers.filter(e=>e.enabled).length||null,dirty:t.dirty.has("headers")}]}];let x;switch(B.startsWith("param:")?"params":B){case"pick":x=s.jsxs(s.Fragment,{children:[z&&s.jsx(N,{layout:"multiline",intent:"warning",style:{marginBottom:12},children:s.jsxs($,{children:[s.jsx(se,{children:"Classification is approximate."}),"Couldn't read the ",z," (you may lack read privilege), so Custom APIs, custom process actions and OOB actions are partly told apart by name prefix. Some messages may be listed under a different Execute mode."]})}),d!=="oob"&&me&&s.jsx(N,{layout:"multiline",intent:"info",style:{marginBottom:12},children:s.jsx($,{children:"Couldn't read the solution table (you may lack read privilege), so operations aren't grouped by publisher or badged with one."})}),s.jsx(pt,{filter:c.filter,title:c.picker.title,sub:c.picker.sub,value:t.actionName,onChange:e=>{u(a=>({...a,actionName:e??"",paramValues:{},boundRecordId:null})),I("pick"),I("params"),I("target")},group:"execute"})]});break;case"target":x=l?s.jsx(Qe,{table:l,onTableChange:()=>{},recordId:t.boundRecordId,onRecordChange:(e,a)=>{w("boundRecordId",e,"target"),F(a??"")},group:"execute",sub:`Pick the ${l} record this action operates on. The id slots into the URL: /${T?.entitySetName??`${l}s`}(<id>)/Microsoft.Dynamics.CRM.${n?.name}.`}):s.jsx(N,{layout:"multiline",intent:"info",children:s.jsx($,{children:n?.binding.kind==="collection"?`The selected action is bound to the ${p} collection — no source record required.`:"The selected action is unbound — no source record required."})});break;case"params":x=n?s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[s.jsx(ut,{action:n,values:t.paramValues,setValue:(e,a)=>w("paramValues",{...t.paramValues,[e]:a},"params"),setValues:e=>w("paramValues",e,"params"),group:"execute",themeMode:r}),s.jsx(ht,{body:q,pillText:"from $metadata"}),s.jsx(mt,{action:n})]}):s.jsx(N,{layout:"multiline",intent:"info",children:s.jsx($,{children:s.jsx(se,{children:"Pick an action first."})})});break;case"headers":x=s.jsx(Ke,{items:t.headers,setItems:e=>w("headers",e,"headers"),group:"execute",sendsHeaders:!0});break}const ke=ne(t.headers,null),Se={method:"POST",built:y,headers:ke,body:q,entityLogical:y.entityLogical};return s.jsx(et,{sidebar:s.jsx(nt,{type:g,urlPreview:y.relativeNoBase,sections:xe,activeNode:B,onSelect:e=>{S(e),j("builder")},recents:de,onRecentClick:ye}),urlBar:s.jsx(st,{method:"POST",url:y.relativeUrl,executeVerb:g.executeVerb,writeConfirm:n?{operation:`${g.name} ${n.name}`,table:p??void 0,scope:n.binding.kind==="entity"?{kind:"records",count:1}:n.binding.kind==="collection"?{kind:"text",text:`Bound to the ${p} collection`}:{kind:"text",text:"Unbound: runs against the environment"},highImpact:!0,confirmWord:n.name}:null,executeIcon:te,disabledReason:be,loading:re,onExecute:he,advisories:J,onAdvisoryFocus:S}),children:s.jsxs(tt,{tab:v,onTabChange:j,resultCount:O?.ok?1:null,children:[v==="builder"&&x,v==="code"&&s.jsx(bt,{themeMode:r,inputs:Se}),v==="results"&&s.jsx(at,{result:O,mode:"single",table:l??"",writeContext:{operation:"action",table:l??"",recordId:t.boundRecordId,recordName:ce||null,operationName:n?.name??t.actionName??void 0,boundEntity:l??void 0}})]})})}export{Rt as ExecuteActionMode};
@@ -0,0 +1 @@
1
+ import{bg as ue,j as e,b_ as me,t as o,B as he,aW as pe,s as ge,ao as be,ap as ye,C as U,bv as fe,f as xe,bh as ve,r as l,U as je,w as _,R as ke,dJ as Fe,u as Re,bj as Se,dK as Ne,W as Pe,X as we,dL as Te,bl as Ce,Y as M,Z as J,_ as $e,aL as K,aM as Le,$ as Be,a0 as Ae,dM as Ie,dN as Q,a$ as X,b0 as Ee,a7 as Me,a8 as Ue,a9 as De,ay as qe,an as Ve,M as He,m as Oe,o as ze,ab as Ge,ad as Y,ae as We,af as _e,ag as Je,ah as Ke,ai as Qe,dO as Z,b8 as Xe,b9 as Ye,ax as Ze,bx as ea,b6 as aa}from"./index-NW0Z4UWR.js";import{A as na,R as ta,a as sa}from"./ActionParamForm-DvTh6hUs.js";import{d as oa}from"./decodeForDisplay-D55DM53E.js";import{C as ra}from"./CodeView-C65Y5vXN.js";import"./OptionGroup-DYAAm_pt.js";import"./FieldSetEditor-Dg6WsDgG.js";import"./multipart-Bd_eOd8a.js";function ia({built:u,useParamAliases:m}){const r=ue(),n=u.relativeNoBase||u.relativeUrl,h=n.match(/^([^?]*)\??(.*)$/),f=h?.[1]??n,x=h?.[2]??"",p=f.match(/^(.*?)\/([^/]+)\((.*)\)$/),F=p?.[1]??"",P=p?.[2]??"",R=p?.[3]??"",S=x?x.split("&").map(d=>{const g=d.indexOf("=");return g===-1?{key:d,value:""}:{key:d.slice(0,g),value:d.slice(g+1)}}):[];return e.jsxs("div",{className:fe(r.inlineCard),style:{padding:12,maxWidth:980},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[e.jsx(me,{style:{width:16,height:16,color:o.colorBrandForeground1}}),e.jsx("strong",{style:{fontSize:12},children:"URL preview"}),e.jsx(he,{appearance:"ghost",children:m?"param aliases":"inline literals"}),e.jsx("span",{style:{flexGrow:1}}),e.jsx(pe,{content:"Copy URL",relationship:"label",children:e.jsx(ge,{size:"small",appearance:"subtle",icon:e.jsx(ye,{}),onClick:()=>{be(u.relativeUrl,"the URL")}})})]}),e.jsxs("div",{style:{padding:10,background:o.colorNeutralBackground3,borderRadius:o.borderRadiusSmall,fontFamily:o.fontFamilyMonospace,fontSize:11,wordBreak:"break-all",whiteSpace:"pre-wrap",lineHeight:1.6},children:[e.jsxs("span",{style:{color:o.colorNeutralForeground3},children:[F,"/"]}),e.jsx("span",{style:{color:o.colorBrandForeground1,fontWeight:700},children:P||f}),R!==""&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:o.colorNeutralForeground3},children:"("}),e.jsx(la,{segment:R}),e.jsx("span",{style:{color:o.colorNeutralForeground3},children:")"})]}),S.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:o.colorNeutralForeground3},children:"?"}),S.map((d,g)=>e.jsxs("span",{children:[g>0&&e.jsx("span",{style:{color:o.colorNeutralForeground3},children:"&"}),e.jsx("span",{style:{color:o.colorPaletteDarkOrangeForeground1},children:d.key}),e.jsx("span",{style:{color:o.colorNeutralForeground3},children:"="}),e.jsx("span",{style:{color:o.colorPaletteGreenForeground1},children:oa(d.value)})]},d.key+g))]})]}),m&&S.length>0&&e.jsxs(U,{style:{display:"block",marginTop:8,color:o.colorNeutralForeground3},children:["Aliased — each"," ",e.jsxs("code",{style:{color:o.colorPaletteDarkOrangeForeground1},children:["@p",e.jsx("i",{children:"n"})]})," ","in the path is bound by the query string. Recommended by docs for any non-trivial value."]}),!m&&e.jsx(U,{style:{display:"block",marginTop:8,color:o.colorNeutralForeground3},children:"Inline — values are embedded directly in the path. Beware URL-length limits + DateTimeOffset encoding bugs."})]})}function la({segment:u}){const m=u.split(",").map(r=>{const n=r.indexOf("=");return n===-1?{key:r,value:""}:{key:r.slice(0,n),value:r.slice(n+1)}});return e.jsx(e.Fragment,{children:m.map((r,n)=>e.jsxs("span",{children:[n>0&&e.jsx("span",{style:{color:o.colorNeutralForeground3},children:","}),e.jsx("span",{style:{color:o.colorNeutralForeground2},children:r.key}),e.jsx("span",{style:{color:o.colorNeutralForeground3},children:"="}),e.jsx("span",{style:{color:o.colorPaletteDarkOrangeForeground1},children:r.value})]},r.key+n))})}const da=()=>({functionName:null,boundRecordId:null,paramValues:{},useParamAliases:!0,headers:aa(),category:"oob",dirty:new Set});function fa({themeMode:u}){const m=xe("exec-function"),r=ve("exec-function",Z,da),[n,h]=l.useState(r.state),[f,x]=l.useState("pick"),[p,F]=l.useState("builder"),[P,R]=l.useState(null),[S,d]=l.useState(!1),[g,ee]=je("exec-function"),[s,D]=l.useState(void 0);l.useEffect(()=>{let a=!1;if(!n.functionName){D(void 0);return}return _.find(n.functionName).then(t=>{a||D(t)}),()=>{a=!0}},[n.functionName]);const w=s&&s.binding.kind!=="unbound"?s.binding.entityType:null,{table:A}=ke(w),v=l.useMemo(()=>Fe(n),[n,s,A]),{allEntities:q}=Re(),[T,I]=l.useState(r.lastSavedId),[C,E]=l.useState(r.lastSavedHash),[ae,V]=l.useState(""),$=a=>h(t=>{const i=new Set(t.dirty);return i.add(a),{...t,dirty:i}}),N=(a,t,i)=>{h(y=>({...y,[a]:t})),i&&$(i)},L=s?.binding.kind==="entity",c=s?.binding.kind==="entity"?s.binding.entityType:null,b=(s?.parameters??[]).filter(a=>a.required).filter(a=>{const t=n.paramValues[a.name];return t==null||typeof t=="string"&&t===""||Array.isArray(t)&&t.length===0}),B=Se(L?[["Bound record id",n.boundRecordId]]:[])??Ne(s?.parameters??[],n.paramValues),H=Pe([{when:!s,id:"function-pick",title:"Pick a function.",focusNode:"pick"},{when:L&&!n.boundRecordId,id:"function-bound-record",title:`Function '${s?.name}' is bound to ${c} — supply a source record.`,focusNode:"target"},{when:w&&!A,id:"function-binding-metadata",title:`Can't build the URL yet — ${w} table metadata isn't loaded.`,focusNode:L?"target":"pick"},{when:b.length>0,id:"function-required",title:`${b.length} required param${b.length===1?"":"s"} unset.`,focusNode:b[0]?`param:${b[0].name}`:"params"},{when:n.headers.some(a=>a.enabled&&!a.name),id:"function-header-name",title:"Fix empty header name.",focusNode:"headers"},{when:B,id:"function-url-part",title:B??"",focusNode:B?.startsWith("Bound")?"target":`param:${/^Parameter (\S+):/.exec(B??"")?.[1]??""}`}]),ne=we(H),te=async()=>{d(!0);const a=await Ye.function(n,Y(n.headers,null));R(a),d(!1),F("results"),ee(Ze({snapshot:j,modeId:"exec-function",url:v.relativeUrl,method:"GET",status:a.status,ms:a.ms,rowCount:a.ok?1:0})),h(t=>({...t,dirty:new Set}))},j=l.useMemo(()=>Te(n),[n]);Ce("exec-function",j,T,C);const se=l.useMemo(()=>M(j),[j]),O=C===null?!0:se!==C,oe=a=>{I(a.id),E(M(a.state))},z=async a=>{if(a.modeId!=="exec-function")return;const t=a.state,i=t.functionName?await _.find(t.functionName).catch(()=>{}):void 0,y=i&&i.binding.kind!=="unbound"?i.binding.entityType:null;if(y&&q.length>0&&!q.some(ce=>ce.logicalName===y)){Xe(`Can't load "${a.name}": bound entity \`${y}\` isn't available in this environment.`);return}h(Z(t)),I(a.id),E(M(t)),R(null),V(""),x("pick")},re=a=>{const t=ea(a,"exec-function");if(!t)return;const i=T,y=C;z(t),I(i),E(y)},G=J(oe),W=J(z);$e(l.useMemo(()=>n.functionName?{state:j,modeId:"exec-function",dirty:O,lastSavedId:T,onSaved:G,onLoadSaved:W}:null,[j,O,T,n.functionName,G,W]));const ie=[{id:"function",label:"Function",meta:s?s.binding.kind==="unbound"?"unbound":s.binding.kind==="collection"?`bound to ${w} collection`:`bound to ${c}`:"pick one",items:[{id:"pick",icon:Le,iconFilled:K,label:s?.displayName??s?.name??"Pick function",code:!!s,dirty:n.dirty.has("pick")}]},...L&&c?[{id:"binding",label:`Bound to ${c}`,meta:n.boundRecordId?"✓ record selected":"pick a record",items:[{id:"target",icon:Ae,iconFilled:Be,label:"Source record",badge:n.boundRecordId?"✓":null,badgeAppearance:"ghost",dirty:n.dirty.has("target")}]}]:[],...s&&s.parameters.length>0?[{id:"params",label:"Parameters",meta:`${Object.values(n.paramValues).filter(a=>a!=null&&a!=="").length} of ${s.parameters.length} set`,items:[{id:"params",icon:Q,iconFilled:Ie,label:"Function parameters",badge:b.length>0?`${b.length} req unset`:null,badgeAppearance:"tint",badgeColor:b.length>0?"danger":"subtle",dirty:n.dirty.has("params"),children:s?.parameters.filter(a=>a.required).map(a=>{const t=n.paramValues[a.name],i=!(t==null||t===""||Array.isArray(t)&&t.length===0);return{id:`param:${a.name}`,icon:Q,label:a.name,code:!0,badge:i?"✓":"req",badgeAppearance:"ghost",badgeColor:i?"subtle":"danger"}})??[]}]}]:[],{id:"options",label:"Aliasing",meta:n.useParamAliases?"param aliases":"inline literals",items:[{id:"options",icon:Ee,iconFilled:X,label:"Parameter encoding",badge:n.useParamAliases?"aliased":"inline",badgeAppearance:"ghost",dirty:n.dirty.has("options")}]},{id:"headers",label:"Headers",meta:`${n.headers.filter(a=>a.enabled).length} active`,items:[{id:"headers",icon:Ue,iconFilled:Me,label:"HTTP headers",badge:n.headers.filter(a=>a.enabled).length||null,dirty:n.dirty.has("headers")}]}];let k;switch(f.startsWith("param:")?"params":f){case"pick":k=e.jsx(sa,{filter:a=>a.kind==="Function"&&!a.isQueryFunction,title:"Browse OData functions",sub:"Functions are read-only operations exposed via GET. Composable functions accept $select/$filter for column scoping.",value:n.functionName,onChange:a=>{h(t=>({...t,functionName:a,paramValues:{},boundRecordId:null})),$("pick"),$("params"),$("target")},group:"execute"});break;case"target":k=c?e.jsx(Ge,{table:c,onTableChange:()=>{},recordId:n.boundRecordId,onRecordChange:(a,t)=>{N("boundRecordId",a,"target"),V(t??"")},group:"execute",sub:`Pick the ${c} record. The id slots into the URL: /${A?.entitySetName??`${c}s`}(<id>)/Microsoft.Dynamics.CRM.${s?.name}.`}):null;break;case"params":k=s?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx(na,{action:s,values:n.paramValues,setValue:(a,t)=>N("paramValues",{...n.paramValues,[a]:t},"params"),setValues:a=>N("paramValues",a,"params"),group:"execute",themeMode:u}),e.jsx(ia,{built:v,useParamAliases:n.useParamAliases}),e.jsx(ta,{action:s})]}):null;break;case"options":k=e.jsxs("div",{children:[e.jsx(qe,{icon:X,title:"Parameter encoding",sub:"Controls how function parameters are serialized into the URL.",group:"execute"}),e.jsxs("div",{style:{maxWidth:760,display:"flex",flexDirection:"column",gap:14},children:[e.jsx("div",{style:{padding:12,border:`1px solid ${o.colorNeutralStroke2}`,borderRadius:o.borderRadiusMedium},children:e.jsx(Ve,{checked:n.useParamAliases,onChange:(a,t)=>N("useParamAliases",t.checked,"options"),label:e.jsxs("span",{children:[e.jsx("strong",{children:"Use parameter aliases"})," ",e.jsx("code",{style:{fontFamily:o.fontFamilyMonospace,fontSize:11,color:o.colorBrandForeground2},children:"(p1=@p1)?@p1=value"}),e.jsx(U,{style:{display:"block",color:o.colorNeutralForeground3,marginTop:2},children:"Recommended by docs — avoids the 400 Bad Request thrown on long URLs and the DateTimeOffset inline-encoding bug."})]})})}),e.jsx(He,{layout:"multiline",intent:n.useParamAliases?"info":"warning",children:e.jsxs(Oe,{children:[e.jsx(ze,{children:n.useParamAliases?"Param aliases are on.":"Inline literals are on."}),n.useParamAliases?e.jsxs(e.Fragment,{children:["Each param becomes ",e.jsx("code",{children:"p=@pN"})," in the URL path, with values in the query string. Strings stay single-quoted; numbers/booleans/GUIDs/date-times go bare; collections are JSON arrays; enums are"," ",e.jsx("code",{children:"Namespace.Type'Member'"}),"."]}):e.jsxs(e.Fragment,{children:["Params are written inline like ",e.jsx("code",{children:"(p='val',q=42)"}),". Faster to read but breaks for long URLs, and Dataverse rejects inline values containing"," ",e.jsx("code",{children:"/ < > * % & : \\ ? +"})," — which includes every DateTimeOffset. Use aliases for those."]})]})})]})]});break;case"headers":k=e.jsx(De,{policy:"impersonation",items:n.headers,setItems:a=>N("headers",a,"headers"),group:"execute"});break}const le=Y(n.headers,null),de={method:"GET",built:v,headers:le,entityLogical:v.entityLogical};return e.jsx(We,{sidebar:e.jsx(Qe,{type:m,urlPreview:v.relativeNoBase,sections:ie,activeNode:f,onSelect:a=>{x(a),F("builder")},recents:g,onRecentClick:re}),urlBar:e.jsx(Ke,{method:"GET",url:v.relativeUrl,executeVerb:m.executeVerb,executeIcon:K,disabledReason:ne,loading:S,onExecute:te,advisories:H,onAdvisoryFocus:x}),children:e.jsxs(_e,{tab:p,onTabChange:F,resultCount:P?.ok?1:null,children:[p==="builder"&&k,p==="code"&&e.jsx(ra,{themeMode:u,inputs:de}),p==="results"&&e.jsx(Je,{result:P,mode:"single",table:c??"",writeContext:{operation:"function",table:c??"",recordId:n.boundRecordId,recordName:ae||null,operationName:s?.name??n.functionName??void 0,boundEntity:c??void 0}})]})})}export{fa as ExecuteFunctionMode};
@@ -0,0 +1 @@
1
+ import{bg as oe,j as e,bv as ve,t as w,r as l,C as S,S as ae,M as R,m as C,o as V,B as b,f as Se,bh as Ee,U as Ie,cc as Ne,cd as Pe,R as Te,z as Re,u as Ce,bj as Le,W as We,X as Ae,ce as Me,bl as qe,Y as O,Z as Q,_ as Be,cf as L,cg as Fe,$ as ee,a0 as $e,a7 as De,a8 as He,a9 as ze,ay as ne,au as ie,be as Oe,ad as te,ae as Ve,af as Ue,ag as _e,ah as Ge,ai as Ke,ch as Xe,s as Ye,am as Ze,bt as Je,bd as re,ci as se,b8 as Qe,b9 as et,ax as tt,bx as rt,aj as st}from"./index-NW0Z4UWR.js";import{C as ot}from"./CodeView-C65Y5vXN.js";import"./multipart-Bd_eOd8a.js";function at({rows:i,keyWidth:s,className:c}){const t=oe(),o=s!=null?{gridTemplateColumns:`${typeof s=="number"?`${s}px`:s} 1fr`}:void 0;return e.jsx("div",{className:ve(t.kvGrid,c),style:o,children:i.map((u,n)=>e.jsx(nt,{k:u.k,v:u.v,mono:u.mono},n))})}function nt({k:i,v:s,mono:c}){const t=oe();return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:t.kvKey,children:i}),e.jsx("span",{className:c?t.kvValMono:t.kvVal,children:s==null||s===""?e.jsx("em",{style:{color:w.colorNeutralForeground4},children:"—"}):s})]})}const it="http://schemas.microsoft.com/winfx/2006/xaml",lt=new Set(["InputEntities","CreatedEntities"]);function dt(i){if(!i||typeof DOMParser>"u")return[];let s;try{s=new DOMParser().parseFromString(i,"application/xml")}catch{return[]}if(s.getElementsByTagName("parsererror").length>0)return[];const c=[],t=s.getElementsByTagNameNS(it,"Property");for(const o of Array.from(t)){const u=o.getAttribute("Name"),n=/^(In|InOut)Argument\((.*)\)$/.exec((o.getAttribute("Type")??"").trim());if(!u||!n||lt.has(u))continue;let y=!1,h=null;for(const g of Array.from(o.getElementsByTagName("*"))){const a=g.getAttribute("Value");g.localName==="ArgumentRequiredAttribute"&&(y=a?.toLowerCase()==="true"),g.localName==="ArgumentDescriptionAttribute"&&a&&(h=a)}c.push({name:u,direction:n[1],type:n[2].trim(),required:y,description:h})}return c}function ct(i){return i.replace(/\b[a-z]+:/g,"")}function ut({workflowId:i}){const[s,c]=l.useState({status:"loading"});l.useEffect(()=>{if(typeof window>"u"||!window.dataverseAPI?.queryData){c({status:"ready",args:[]});return}let o=!1;return c({status:"loading"}),window.dataverseAPI.queryData(`workflows?$select=xaml&$filter=workflowid eq ${i}`).then(u=>{if(o)return;const n=u?.value?.[0],y=typeof n?.xaml=="string"?n.xaml:null;c({status:"ready",args:dt(y)})}).catch(u=>{o||c({status:"error",message:u instanceof Error?u.message:String(u)})}),()=>{o=!0}},[i]);const t={color:w.colorNeutralForeground3,display:"block",marginTop:10};return s.status==="loading"?e.jsxs(S,{style:{...t,display:"flex",alignItems:"center",gap:6},children:[e.jsx(ae,{size:"extra-tiny"})," Reading the workflow's input arguments…"]}):s.status==="error"?e.jsxs(S,{style:t,children:["Couldn't read the workflow definition to check for input arguments: ",s.message]}):s.args.length===0?e.jsxs(S,{style:t,children:["No input arguments declared — ",e.jsx("code",{children:"EntityId"})," is the whole request body."]}):e.jsx(R,{layout:"multiline",intent:"warning",style:{marginTop:12},children:e.jsxs(C,{children:[e.jsxs(V,{children:["This workflow declares ",s.args.length," input argument",s.args.length===1?"":"s"]}),"The Web API ",e.jsx("code",{children:"ExecuteWorkflow"})," action only takes ",e.jsx("code",{children:"EntityId"}),", so these can't be set from here; the workflow runs with their default values.",e.jsx("ul",{style:{margin:"6px 0 0",paddingLeft:18},children:s.args.map(o=>e.jsxs("li",{children:[e.jsx("code",{children:o.name})," ",e.jsx(b,{appearance:"outline",size:"small",children:ct(o.type)}),o.direction==="InOut"&&e.jsx(b,{appearance:"tint",size:"small",style:{marginLeft:4},children:"in/out"}),o.required&&e.jsx(b,{appearance:"tint",color:"danger",size:"small",style:{marginLeft:4},children:"required"}),o.description&&e.jsxs("span",{style:{color:w.colorNeutralForeground3},children:[" — ",o.description]})]},o.name))})]})})}const mt=()=>({workflowId:null,entityId:null,headers:st(),dirty:new Set});function gt({themeMode:i}){const s=Se("exec-workflow"),c=Ee("exec-workflow",se,mt),[t,o]=l.useState(c.state),[u,n]=l.useState("pick"),[y,h]=l.useState("builder"),[g,a]=l.useState(null),[p,j]=l.useState(!1),[W,A]=Ie("exec-workflow"),E=l.useMemo(()=>Ne(t),[t]),le=l.useMemo(()=>Pe(t),[t]),[M,U]=l.useState([]),[de,q]=l.useState(!1),[ce,B]=l.useState(null),[ue,me]=l.useState(0),fe=typeof window<"u"&&!!window.dataverseAPI?.queryData;l.useEffect(()=>{let r=!1;if(typeof window>"u"||!window.dataverseAPI?.queryData){U([]),B("Workflows can only be loaded from a live Dataverse connection (PPTB).");return}return q(!0),B(null),window.dataverseAPI.queryData("workflows?$select=workflowid,name,uniquename,primaryentity,description&$filter=(statecode eq 1 and type eq 1 and ondemand eq true and category eq 0)&$orderby=name asc").then(m=>{if(r)return;const x=m?.value??[];U(x.map(k=>({id:String(k.workflowid??""),name:String(k.name??"(unnamed)"),uniqueName:k.uniquename!=null?String(k.uniquename):null,primaryEntity:String(k.primaryentity??""),description:k.description!=null?String(k.description):null}))),q(!1)}).catch(m=>{r||(B(m instanceof Error?m.message:String(m)),q(!1))}),()=>{r=!0}},[ue]);const d=t.workflowId?M.find(r=>r.id===t.workflowId):void 0;Te(d?.primaryEntity??null);const I=d?Re(d.primaryEntity):void 0,{allEntities:_}=Ce(),[N,F]=l.useState(c.lastSavedId),[P,$]=l.useState(c.lastSavedHash),[ye,D]=l.useState(""),H=r=>o(f=>{const m=new Set(f.dirty);return m.add(r),{...f,dirty:m}}),G=(r,f,m)=>{o(x=>({...x,[r]:f})),m&&H(m)},z=Le([["Workflow id",t.workflowId],["Record id",t.entityId]]),K=We([{when:!d,id:"workflow-pick",title:"Pick a workflow.",focusNode:"pick"},{when:!t.entityId,id:"workflow-record",title:`Pick a ${d?.primaryEntity} record to run the workflow on.`,focusNode:"target"},{when:t.headers.some(r=>r.enabled&&!r.name),id:"workflow-header-name",title:"Fix empty header name.",focusNode:"headers"},{when:z,id:"workflow-url-part",title:z??"",focusNode:z?.startsWith("Workflow")?"pick":"target"}]),he=Ae(K),pe=async()=>{j(!0);const r=await et.workflow(t,te(t.headers,null));a(r),j(!1),h("results"),A(tt({snapshot:v,modeId:"exec-workflow",url:E.relativeUrl,method:"POST",status:r.status,ms:r.ms,rowCount:r.ok?1:0})),o(f=>({...f,dirty:new Set}))},v=l.useMemo(()=>Me(t),[t]);qe("exec-workflow",v,N,P);const we=l.useMemo(()=>O(v),[v]),X=P===null?!0:we!==P,ge=r=>{F(r.id),$(O(r.state))},Y=r=>{if(r.modeId!=="exec-workflow")return;const f=r.state,m=M.find(x=>x.id===f.workflowId);if(m&&_.length>0&&!_.some(x=>x.logicalName===m.primaryEntity)){Qe(`Can't load "${r.name}": workflow's primary entity \`${m.primaryEntity}\` isn't available in this environment.`);return}o(se(f)),F(r.id),$(O(f)),a(null),D(""),n("pick")},xe=r=>{const f=rt(r,"exec-workflow");if(!f)return;const m=N,x=P;Y(f),F(m),$(x)},Z=Q(ge),J=Q(Y);Be(l.useMemo(()=>t.workflowId?{state:v,modeId:"exec-workflow",dirty:X,lastSavedId:N,onSaved:Z,onLoadSaved:J}:null,[v,X,N,t.workflowId,Z,J]));const ke=[{id:"workflow",label:"Target",meta:d?.name??"pick one",items:[{id:"pick",icon:Fe,iconFilled:L,label:d?.name??"Pick on-demand workflow",dirty:t.dirty.has("pick")}]},{id:"target",label:"Bound to",meta:d?`${I?.displayName??d.primaryEntity} record`:"—",items:[{id:"target",icon:$e,iconFilled:ee,label:t.entityId?`${I?.displayName??""} (selected)`:"Pick a record",badge:t.entityId?"✓":null,badgeAppearance:"ghost",dirty:t.dirty.has("target")}]},{id:"headers",label:"Headers",meta:`${t.headers.filter(r=>r.enabled).length} active`,items:[{id:"headers",icon:He,iconFilled:De,label:"HTTP headers",badge:t.headers.filter(r=>r.enabled).length||null,dirty:t.dirty.has("headers")}]}];let T;switch(u){case"pick":T=e.jsx(ft,{workflows:M,loading:de,error:ce,onRetry:fe?()=>me(r=>r+1):void 0,workflowId:t.workflowId,setWorkflowId:r=>{o(f=>({...f,workflowId:r,entityId:null})),D(""),H("pick"),H("target")}});break;case"target":T=d?e.jsxs("div",{children:[e.jsx(ne,{icon:ee,title:"Target record",sub:`The ${I?.displayName??d.primaryEntity} record the workflow operates on. Slots into the request body as "EntityId".`,group:"execute"}),e.jsxs("div",{style:{maxWidth:480},children:[e.jsx(ie,{label:`${I?.displayName??d.primaryEntity} record`,children:e.jsx(Oe,{table:d.primaryEntity,selectedId:t.entityId,onPick:r=>{G("entityId",r?.id??null,"target"),D(r?.primary??"")},placeholder:`Search ${I?.displayName??d.primaryEntity} records…`})}),e.jsx(ut,{workflowId:d.id})]})]}):e.jsx(R,{layout:"multiline",intent:"info",children:e.jsx(C,{children:"Pick a workflow first."})});break;case"headers":T=e.jsx(ze,{items:t.headers,setItems:r=>G("headers",r,"headers"),group:"execute",sendsHeaders:!0});break}const be=te(t.headers,null),je={method:"POST",built:E,headers:be,body:le,entityLogical:E.entityLogical};return e.jsx(Ve,{sidebar:e.jsx(Ke,{type:s,urlPreview:E.relativeNoBase,sections:ke,activeNode:u,onSelect:r=>{n(r),h("builder")},recents:W,onRecentClick:xe}),urlBar:e.jsx(Ge,{method:"POST",url:E.relativeUrl,executeVerb:s.executeVerb,writeConfirm:d?{operation:`Execute Workflow "${d.name}"`,table:d.primaryEntity||void 0,scope:{kind:"records",count:1},highImpact:!0}:null,executeIcon:L,disabledReason:he,loading:p,onExecute:pe,advisories:K,onAdvisoryFocus:n}),children:e.jsxs(Ue,{tab:y,onTabChange:h,resultCount:g?.ok?1:null,children:[y==="builder"&&T,y==="code"&&e.jsx(ot,{themeMode:i,inputs:je}),y==="results"&&e.jsx(_e,{result:g,mode:"single",table:d?.primaryEntity??"",writeContext:{operation:"workflow",table:d?.primaryEntity??"",recordId:t.entityId,recordName:ye||null,operationName:d?.name??void 0}})]})})}function ft({workflows:i,loading:s,error:c,onRetry:t,workflowId:o,setWorkflowId:u}){const n=o?i.find(a=>a.id===o):void 0,[y,h]=l.useState("");l.useEffect(()=>{h(n?.name??"")},[n?.name]);const g=l.useMemo(()=>{const a=y.trim().toLowerCase();return!a||a===(n?.name??"").toLowerCase()?i:i.filter(p=>p.name.toLowerCase().includes(a)||(p.uniqueName?.toLowerCase().includes(a)??!1)||p.primaryEntity.toLowerCase().includes(a)||(p.description?.toLowerCase().includes(a)??!1))},[i,y,n]);return e.jsxs("div",{children:[e.jsx(ne,{icon:L,title:"On-demand workflow",sub:"Pick an activated workflow (type=Definition, category=Workflow). The workflow's primary entity drives the Target picker.",group:"execute",children:s?e.jsx(b,{appearance:"ghost",icon:e.jsx(ae,{size:"extra-tiny"}),children:"loading…"}):c?null:e.jsxs(b,{appearance:"ghost",children:[i.length," workflow",i.length===1?"":"s"]})}),c&&!s&&e.jsxs(R,{intent:"error",layout:"multiline",style:{marginBottom:12,maxWidth:760},children:[e.jsxs(C,{children:[e.jsx(V,{children:"Couldn't load workflows"}),c]}),t&&e.jsx(Xe,{containerAction:e.jsx(Ye,{appearance:"primary",size:"small",icon:e.jsx(Ze,{}),onClick:t,children:"Retry"})})]}),e.jsxs("div",{style:{maxWidth:760},children:[e.jsx(ie,{label:"Workflow",children:e.jsxs(Je,{freeform:!0,clearable:!0,value:y,selectedOptions:o?[o]:[],onChange:a=>{const p=a.target.value;h(p),p===""&&o&&u(null)},onOptionSelect:(a,p)=>{const j=p.optionValue??null;if(u(j),j){const W=i.find(A=>A.id===j);h(W?.name??"")}else h("")},placeholder:s?"Loading workflows…":c?"Workflows didn’t load":i.length===0?"No activated workflows in this environment":"Search workflows…",disabled:s||i.length===0,listbox:{style:{maxHeight:420}},children:[g.length===0&&y.trim()&&e.jsx(re,{value:"__none",text:"",disabled:!0,children:e.jsxs(S,{style:{color:w.colorNeutralForeground3},children:['No workflows match "',y.trim(),'"']})}),g.map(a=>e.jsx(re,{value:a.id,text:a.name,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx("span",{children:a.name}),e.jsxs(S,{style:{color:w.colorNeutralForeground3},children:["Primary entity:"," ",e.jsx("span",{style:{fontFamily:w.fontFamilyMonospace},children:a.primaryEntity}),a.description?` · ${a.description}`:""]})]})},a.id))]})}),n&&e.jsxs("div",{style:{marginTop:16,padding:12,border:`1px solid ${w.colorNeutralStroke2}`,borderRadius:w.borderRadiusMedium,background:w.colorNeutralBackground1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx(L,{style:{color:w.colorBrandForeground1}}),e.jsx("strong",{style:{fontSize:13},children:n.name}),e.jsx(b,{appearance:"ghost",children:n.primaryEntity}),e.jsx("span",{style:{flexGrow:1}}),e.jsx(b,{appearance:"filled",color:"success",style:{fontWeight:700},children:"POST"})]}),e.jsx(S,{style:{color:w.colorNeutralForeground2,display:"block",marginBottom:8},children:n.description}),e.jsx(at,{keyWidth:120,rows:[{k:"Workflow id",v:n.id,mono:!0},{k:"Primary entity",v:n.primaryEntity,mono:!0},{k:"URL shape",v:`POST /workflows(${n.id})/Microsoft.Dynamics.CRM.ExecuteWorkflow`,mono:!0},{k:"Body shape",v:'{ "EntityId": "<target-guid>" }',mono:!0},{k:"Response",v:"204 No Content — workflow runs async"}]}),e.jsx(R,{layout:"multiline",intent:"info",style:{marginTop:12},children:e.jsxs(C,{children:[e.jsx(V,{children:"Workflow runs are asynchronous."}),"The 204 only confirms the request was accepted. Check the ",e.jsx("code",{children:"workflowlogs"})," ","/ ",e.jsx("code",{children:"asyncoperations"})," tables for completion + result."]})})]})]})]})}export{gt as ExecuteWorkflowMode,ft as WorkflowPickerPane};
@@ -0,0 +1,3 @@
1
+ import{e4 as Se,r as f,e5 as Ye,j as e,bt as Z,bd as F,C as w,t as d,e6 as Qe,aF as Y,bG as ve,e7 as ye,e8 as Xe,e9 as et,z as se,c as ge,ea as fe,aE as je,eb as tt,ec as K,bb as nt,ed as it,M as D,m as P,ay as at,aJ as lt,av as oe,bC as st,B as V,br as rt,bs as be,aK as ot,cr as ct,o as re,s as z,aU as dt,I as ut,ee as mt,bg as pt,aW as B,ef as ht,an as Ee,aT as gt,bv as ft,eg as xt,eh as yt,ch as Le,ao as jt,ap as bt,ei as St,da as vt,bF as Nt,ej as Ft,bS as kt,ek as wt,el as Tt,em as Mt,en as xe,eo as Ct,d_ as $e,d$ as Lt,aB as $t,au as Ot,T as Re,ep as It,eq as Oe,er as Dt,es as Pt,et as zt,dZ as Et,eu as Rt,ev as Bt,ew as Vt,ex as qt,ey as At,b$ as _t}from"./index-NW0Z4UWR.js";import{M as Wt}from"./CodeView-C65Y5vXN.js";const Ht=Se("ListBar20Regular","20",["M5 3a2 2 0 0 0-2 2v1a2 2 0 0 0 .68 1.5A2 2 0 0 0 3 9v2a2 2 0 0 0 .68 1.5A2 2 0 0 0 3 14v1c0 1.1.9 2 2 2h10a2 2 0 0 0 2-2v-1a2 2 0 0 0-.68-1.5A2 2 0 0 0 17 11V9a2 2 0 0 0-.68-1.5A2 2 0 0 0 17 6V5a2 2 0 0 0-2-2H5ZM4 14a1 1 0 0 1 1-1h2v3H5a1 1 0 0 1-1-1v-1Zm4 2v-3h7a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H8Zm0-4V8h7a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H8ZM7 8v4H5a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h2Zm0-1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h2v3Zm1 0V4h7a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H8Z"]),Fn=Se("Key20Filled","20",["M7 7.5C7 4.42 9.42 2 12.5 2S18 4.42 18 7.5 15.58 13 12.5 13c-.5 0-1-.05-1.5-.18V13a1 1 0 0 1-1 1H9v1a1 1 0 0 1-1 1H7v.5c0 .83-.67 1.5-1.5 1.5h-2A1.5 1.5 0 0 1 2 16.5v-1.59c0-.4.16-.78.44-1.06l4.54-4.54c.13-.13.2-.37.14-.64A5.62 5.62 0 0 1 7 7.5ZM15 6a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z"]),Be=Se("Key20Regular","20",["M15 6a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm-2.5-4a5.45 5.45 0 0 0-5.38 6.67c.06.27 0 .5-.14.64l-4.54 4.54A1.5 1.5 0 0 0 2 14.91v1.59c0 .83.67 1.5 1.5 1.5h2c.83 0 1.5-.67 1.5-1.5V16h1a1 1 0 0 0 1-1v-1h1a1 1 0 0 0 1-1v-.18c.5.13 1 .18 1.5.18 3.08 0 5.5-2.42 5.5-5.5S15.58 2 12.5 2ZM8 7.5C8 4.98 9.98 3 12.5 3S17 4.98 17 7.5 15.02 12 12.5 12c-.66 0-1.27-.1-1.78-.35a.5.5 0 0 0-.72.45v.9H9a1 1 0 0 0-1 1v1H7a1 1 0 0 0-1 1v.5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-1.59a.5.5 0 0 1 .15-.35l4.54-4.54c.43-.43.52-1.04.4-1.56-.06-.3-.09-.63-.09-.96Z"]);function Jt({addable:t,onPick:n}){const[i,a]=f.useState(""),{visible:l,matchCount:c,hiddenCount:r}=Ye(t,i,o=>[o.displayName,o.logicalName]);return e.jsxs(Z,{freeform:!0,size:"small",value:i,placeholder:`Add one of ${t.length} fields…`,style:{minWidth:320},onChange:o=>a(o.target.value),onOptionSelect:(o,m)=>{m.optionValue&&n(m.optionValue)},children:[c===0&&e.jsx(F,{value:"__none",text:"",disabled:!0,children:e.jsxs(w,{style:{color:d.colorNeutralForeground3},children:['No fields match "',i,'"']})}),l.map(o=>e.jsx(F,{value:o.logicalName,text:o.displayName,children:e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx("span",{children:o.displayName}),e.jsxs(w,{style:{color:d.colorNeutralForeground3},children:[o.logicalName," · ",e.jsx("code",{children:o.attributeType}),o.required&&e.jsx("span",{style:{marginLeft:6,color:d.colorPaletteRedForeground1},children:"required"})]})]})},o.logicalName)),e.jsx(Qe,{hiddenCount:r})]})}const Ie="00000000-0000-0000-0000-000000000000";function Ut(t){const n=t.attributeType;if(ye.has(n))return["integer"];if(Xe.has(n))return["number"];if(n==="Boolean")return["boolean"];if(n==="MultiSelectPicklist")return["string"];if(et.has(n))return["string"];if(n==="EntityName")return["string","number"]}function Ve(t){return t.requiredLevel==="ApplicationRequired"?" Business required.":t.requiredLevel==="SystemRequired"?" System required.":""}const Zt=25;function De(t){const n=t.slice(0,Zt).map(a=>`${String(a.value)} = ${a.label}`),i=t.length-n.length;return n.join(", ")+(i>0?`, and ${i} more`:"")}function Gt(t,n){const i=Ut(t),a=ve(t);let l=`${t.displayName} (${t.attributeType}).${Ve(t)}`;t.attributeType==="DateTime"&&(l+=t.dateTimeBehavior==="DateOnly"?' A date, e.g. "2026-11-01".':' ISO 8601, e.g. "2026-11-01T09:00:00Z".'),t.attributeType==="Boolean"?l+=` true = ${t.trueOption.label}, false = ${t.falseOption.label}.`:t.attributeType==="MultiSelectPicklist"&&a?.length?l+=` Comma-separated values: ${De(a)}.`:ye.has(t.attributeType)&&a?.length&&(l+=` Values: ${De(a)}.`),t.description&&(l+=`
2
+
3
+ ${t.description}`);const c={description:l};return i&&(c.type=n?[...i,"null"]:i.length===1?i[0]:i),ye.has(t.attributeType)&&a?.length&&(c.defaultSnippets=a.map(r=>({label:`${r.label} · ${r.value}`,description:r.label,body:r.value}))),t.attributeType==="MultiSelectPicklist"&&(c.pattern="^\\s*(-?\\d+\\s*)?(,\\s*(-?\\d+\\s*)?)*$",c.patternErrorMessage='Expected comma-separated option values, e.g. "1,2".',a?.length&&(c.defaultSnippets=a.map(r=>({label:`${r.label} · "${r.value}"`,description:`${r.label}. Add more values after a comma.`,body:String(r.value)})))),c}function Kt(t,n){const i=t.navigationProperties.filter(m=>m.cardinality==="ManyToOne"&&m.referencingAttribute===n.logicalName),a=n.targets.length?n.targets:[...new Set(i.map(m=>m.targetEntity).filter(m=>m!=="owner"))],l=new Map,c=(m,h)=>l.set(m,[...new Set([...l.get(m)??[],...h])]);for(const m of i)c(`${m.name}@odata.bind`,a.includes(m.targetEntity)?[m.targetEntity]:a);const r=new Set([...l.values()].flat()),o=a.filter(m=>!r.has(m));return(o.length>0||l.size===0)&&c(`${n.logicalName}@odata.bind`,o.length>0?o:a),[...l].map(([m,h])=>({key:m,targets:h}))}function Yt(t,n,i,a){const l=n.map(o=>({target:o,set:a(o)})),c=l.length?l.map(o=>`/${o.set??`{${o.target} entity set}`}({guid})`).join(" or "):"/{entity set}({guid})",r=n.length?` → ${n.join(", ")}`:"";return{type:i?["string","null"]:"string",description:`${t.displayName} (${t.attributeType}${r}).${Ve(t)} Value: "${c}"${i?", or null to clear it":""}.`,defaultSnippets:l.map(o=>({label:`/${o.set??o.target}(<guid>)`,description:`A ${o.target} row`,body:o.set?`/${o.set}(\${1:${Ie}})`:`/\${1:${o.target}s}(\${2:${Ie}})`}))}}function Qt(t,n,{nullSupported:i,suggest:a=()=>!0,entitySetOf:l=()=>{}}){const c={};for(const r of n){const o=!a(r);if(Y(r)){for(const{key:m,targets:h}of Kt(t,r))c[m]=Yt(r,h,i,l),o&&(c[m].doNotSuggest=!0);continue}c[r.logicalName]=Gt(r,i),o&&(c[r.logicalName].doNotSuggest=!0)}return{type:"object",properties:c}}const Xt=new Set(["createdon","modifiedon","createdby","modifiedby","createdonbehalfby","modifiedonbehalfby","versionnumber","importsequencenumber","overriddencreatedon","utcconversiontimezonecode","timezoneruleversionnumber"]),qe=t=>Xt.has(t.logicalName)||t.attributeType==="File"||t.attributeType==="Image"||t.attributeType==="Uniqueidentifier"&&t.isPrimaryKey===!0;function kn({table:t,values:n,setValues:i,nullFields:a,setNullFields:l,rawBody:c,setRawBody:r,group:o="write",themeMode:m="light",purpose:h="create",method:p}){const b=p??(h==="create"?"POST":"PATCH"),S=h!=="update",j=a??[],T=!!l,E=s=>k.includes(s),q=s=>{if(l&&!k.includes(s)&&(l([...k,s]),$[s]!==void 0)){const u={...$};delete u[s],i(u)}},y=s=>{l&&l(k.filter(u=>u!==s))},g=se(t),[R,C]=f.useState(""),[L,A]=f.useState("set"),[v,ce]=f.useState(!1),X=!!r,[_e,Fe]=f.useState("form"),[We,ke]=f.useState(""),M=X?c!=null?"json":"form":_e,_=X?c??"":We,[de,W]=f.useState(null),we=(s,u)=>i({...$,[s]:u}),He=s=>{const u={...$};delete u[s],i(u)},N=f.useMemo(()=>(g?.columns??[]).filter(s=>!qe(s)).filter(s=>h==="create"?s.isValidForCreate!==!1:h==="update"?s.isValidForUpdate!==!1:h==="upsert"?s.isValidForCreate!==!1&&s.isValidForUpdate!==!1:!0),[g,h]),H=f.useMemo(()=>M==="json"?ge(_):null,[M,_]),ee=f.useMemo(()=>{const s=new Set(N.map(u=>u.logicalName));return{editable:u=>s.has(u),nullSupported:T}},[N,T]),G=f.useMemo(()=>g&&H?.ok?fe(g,H.body,ee):null,[g,H,ee]),$=G?G.values:n,k=G?G.nullFields:j,Je=()=>{if(M==="json"||!g)return;const s=JSON.stringify(mt(g,n,j),null,2);W(null),r?r(s):(ke(s),Fe("json"))},te=s=>{s&&(i(s.values),l&&l(s.nullFields)),W(null),r?r(null):Fe("form")},Ue=()=>{if(M==="form"||!g)return;if(!X)return te(null);const s=ge(_);if(!s.ok)return W({kind:"invalid",error:s.error});const u=fe(g,s.body,ee);if(u.unmapped.length>0)return W({kind:"unmapped",decoded:u});te(u)},Ze=s=>{if(W(null),r){r(s);return}ke(s);const u=ge(s);u.ok&&g&&i(fe(g,u.body,ee).values)},J=f.useMemo(()=>N.filter(je),[N]),ne=f.useMemo(()=>g?tt(g,M==="json"?_:null,n):()=>!1,[g,M,_,n]),ue=f.useCallback(s=>ne(s)||k.includes(s.logicalName),[ne,k]),Ge=f.useMemo(()=>N.filter(ue),[N,ue]),ie=f.useCallback(s=>s.logicalName in $||k.includes(s.logicalName),[$,k]),Ke=f.useMemo(()=>N.filter(ie).length,[N,ie]),O=f.useMemo(()=>J.filter(s=>S&&!ne(s)||k.includes(s.logicalName)),[J,ne,k,S]),ae=f.useMemo(()=>{const s=new Map(N.map(x=>[x.logicalName,x])),u=N.filter(K),he=new Set(u.map(x=>x.logicalName)),Te=[],Me=new Set,Ce=x=>{if(he.has(x)||Me.has(x))return;const U=s.get(x);U&&(Te.push(U),Me.add(x))};for(const x of Object.keys($))Ce(x);for(const x of k)Ce(x);let I=[...u,...Te];if(L==="required"&&(I=I.filter(je)),L==="set"&&(I=I.filter(ie)),L==="common"&&(I=I.filter(x=>K(x)||x.logicalName===g?.primaryName||x.logicalName==="statecode"||x.logicalName==="statuscode"||Y(x))),R){const x=R.toLowerCase();I=I.filter(U=>U.displayName.toLowerCase().includes(x)||U.logicalName.toLowerCase().includes(x)||U.attributeType.toLowerCase().includes(x))}return I},[N,$,k,L,R,g,ie]),me=nt(),pe=f.useMemo(()=>{const s=new Set(ae.map(u=>u.logicalName));return it(N,me).filter(u=>!s.has(u.logicalName))},[N,ae,me]);return g?e.jsxs("div",{children:[e.jsxs(at,{icon:lt,title:"Field set",sub:e.jsxs("span",{children:["Pick the columns this ",e.jsx("code",{children:b})," should set."," ",e.jsx("span",{style:{color:d.colorNeutralForeground3},children:"Only fields below are emitted in the body — empty columns stay out."})]}),group:o,children:[M==="form"&&e.jsx(oe,{contentBefore:e.jsx(st,{}),"aria-label":"Filter fields",placeholder:"Filter fields…",value:R,onChange:(s,u)=>C(u.value),size:"small",style:{width:220}}),e.jsxs(V,{appearance:"ghost",children:[Ge.length," populated"]}),S&&J.length>0&&e.jsxs(V,{appearance:"tint",color:O.length?"danger":"success",children:[J.length-O.length,"/",J.length," required"]}),e.jsxs(rt,{ariaLabel:"Body editor mode",children:[e.jsx(be,{checked:M==="form",icon:e.jsx(ot,{}),onClick:Ue,children:"Form"}),e.jsx(be,{checked:M==="json",icon:e.jsx(ct,{}),onClick:Je,children:"JSON"})]})]}),O.length>0&&(S?e.jsx(D,{layout:"multiline",intent:"warning",style:{marginBottom:12},children:e.jsxs(P,{children:[e.jsxs(re,{children:[O.length," required field",O.length===1?" is":"s are"," unset."]}),"Dataverse will reject the"," ",h==="upsert"?"upsert when it creates the row":"create"," with"," ",e.jsx("code",{children:"0x80040217 · A required field is missing"})," unless every required column has a value. ",e.jsx("strong",{children:"Missing:"})," ",O.map(s=>e.jsx("code",{style:{marginRight:6},children:s.logicalName},s.logicalName))]})}):e.jsx(D,{layout:"multiline",intent:"warning",style:{marginBottom:12},children:e.jsxs(P,{children:[e.jsxs(re,{children:[O.length," required field",O.length===1?" is":"s are"," set to null."]}),"Dataverse may reject the update for clearing a required column. Columns left out of the body keep their current value. ",e.jsx("strong",{children:"Cleared:"})," ",O.map(s=>e.jsx("code",{style:{marginRight:6},children:s.logicalName},s.logicalName))]})})),M==="form"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:14,flexWrap:"wrap"},children:[e.jsx(le,{label:"Set",count:Ke,active:L==="set",onClick:()=>A("set")}),e.jsx(le,{label:"Required",count:J.length,active:L==="required",onClick:()=>A("required")}),e.jsx(le,{label:"Common",active:L==="common",onClick:()=>A("common")}),e.jsx(le,{label:"All",count:N.length,active:L==="all",onClick:()=>A("all")})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14,maxWidth:880},children:[ae.length===0&&e.jsx(w,{style:{padding:"24px 4px",color:d.colorNeutralForeground3,textAlign:"center",fontStyle:"italic"},children:"No fields match. Switch the filter or use “Add field”."}),jn(ae).map(s=>e.jsx(bn,{title:s.title,icon:s.icon,tagText:s.tagText,tagAppearance:s.tagAppearance,children:s.cols.map(u=>e.jsx(tn,{table:g,col:u,value:$[u.logicalName],populated:ue(u),isNull:E(u.logicalName),nullSupported:T,requiredOnWrite:S,onChange:he=>we(u.logicalName,he),onRemove:()=>{He(u.logicalName),k.includes(u.logicalName)&&y(u.logicalName)},onSetNull:()=>q(u.logicalName),onClearNull:()=>y(u.logicalName)},u.logicalName))},s.id))]})]}):e.jsx(Sn,{text:_,error:H&&!H.ok?H.error:null,unmapped:G?.unmapped??[],verbatim:X,switchIssue:de,onDiscard:()=>te(null),onSwitchAnyway:()=>{de?.kind==="unmapped"&&te(de.decoded)},onStay:()=>W(null),themeMode:m,onChange:Ze,table:g,writable:N,nullSupported:T,advancedFindOnly:me}),M==="form"&&pe.length>0&&e.jsxs("div",{style:{marginTop:14,display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[v?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[e.jsx(Jt,{addable:pe,onPick:s=>{const u=ut(g,s);u&&(we(u.logicalName,Ae(u)),ce(!1))}}),e.jsx(z,{size:"small",appearance:"subtle",onClick:()=>ce(!1),children:"Cancel"})]}):e.jsx(z,{icon:e.jsx(dt,{}),appearance:"outline",size:"small",onClick:()=>ce(!0),children:"Add field"}),e.jsxs(w,{style:{color:d.colorNeutralForeground3,marginLeft:"auto"},children:[pe.length," more available on ",e.jsx("code",{children:g.logicalName})]})]})]}):e.jsx(D,{layout:"multiline",intent:"error",children:e.jsxs(P,{children:["Unknown table ",e.jsx("code",{children:t}),"."]})})}const en=St({valueLine:{display:"flex",flexWrap:"wrap",alignItems:"center",columnGap:"8px",rowGap:"4px",minWidth:0},valueInput:{flex:"1 1 160px",minWidth:0,"& .fui-Input, & .fui-Combobox, & .fui-Dropdown, & .fui-SpinButton, & .fui-Textarea, & .fui-TagPickerControl":{minWidth:0,maxWidth:"100%"},"& .fui-Combobox":{minWidth:"0 !important"}},nullSwitch:{flexShrink:0}});function tn({table:t,col:n,value:i,populated:a,isNull:l,nullSupported:c,requiredOnWrite:r,onChange:o,onRemove:m,onSetNull:h,onClearNull:p}){const b=pt(),S=K(n)&&(r?!a:l),j=en();return e.jsxs("div",{className:ft(b.inlineCard),style:{padding:"10px 12px",display:"grid",gridTemplateColumns:"minmax(120px, min(220px, 35%)) minmax(0, 1fr) 30px",gap:12,alignItems:"start",borderColor:S?d.colorPaletteRedBorder2:void 0},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,paddingTop:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontWeight:500,color:d.colorNeutralForeground1},children:n.displayName}),K(n)&&e.jsx(B,{content:r?"Required — Dataverse rejects the create when this is empty.":"Required — leave it out to keep its value; clearing it to null may be rejected.",relationship:"description",children:e.jsx(V,{appearance:"tint",color:"danger",size:"small",children:"req"})}),Y(n)&&e.jsx(B,{content:`Lookup → emits ${n.logicalName}@odata.bind`,relationship:"description",children:e.jsx(ht,{style:{width:12,height:12,color:d.colorBrandForeground1}})}),n.attributeType==="Uniqueidentifier"&&e.jsx(B,{content:"Primary key — Dataverse will auto-generate this. Override only if you know what you're doing.",relationship:"description",children:e.jsx(Be,{style:{width:12,height:12,color:d.colorPaletteGoldBorderActive}})})]}),e.jsxs(w,{style:{color:d.colorNeutralForeground3,fontFamily:d.fontFamilyMonospace,fontSize:10},children:[n.logicalName," ·"," ",e.jsx("span",{style:{color:d.colorBrandForeground2},children:n.attributeType}),xn(n)]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0},children:[e.jsxs("div",{className:j.valueLine,children:[e.jsx("div",{className:j.valueInput,children:l?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",background:d.colorPaletteDarkOrangeBackground1,border:`1px dashed ${d.colorPaletteDarkOrangeBorder2}`,borderRadius:d.borderRadiusSmall,minHeight:28,overflow:"hidden"},title:"This field will be sent as null. Toggle the Switch off to enter a value.",children:[e.jsx(V,{appearance:"filled",color:"warning",size:"small",style:{fontFamily:d.fontFamilyMonospace,fontWeight:700},children:"null"}),e.jsx("code",{style:{fontFamily:d.fontFamilyMonospace,fontSize:11,color:d.colorNeutralForeground2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:Y(n)?`"${n.logicalName}@odata.bind": null`:`"${n.logicalName}": null`})]}):e.jsx(nn,{table:t,col:n,value:i,onChange:o})}),c&&e.jsx(Ee,{className:j.nullSwitch,checked:l,onChange:(T,E)=>{E.checked?h():p()},label:e.jsxs("span",{style:{fontSize:11,color:d.colorNeutralForeground3,whiteSpace:"nowrap"},children:["Send as"," ",e.jsx("code",{style:{fontFamily:d.fontFamilyMonospace,fontSize:11},children:"null"})]}),labelPosition:"after"})]}),n.description&&!l&&e.jsx(w,{style:{color:d.colorNeutralForeground3},children:n.description})]}),K(n)?e.jsx("span",{style:{width:30},"aria-hidden":"true"}):e.jsx(B,{content:"Remove field from the body",relationship:"label",children:e.jsx(z,{size:"small",appearance:"subtle",icon:e.jsx(gt,{}),onClick:m,"aria-label":`Remove ${n.displayName}`})})]})}const Ne=f.createContext("Field value");function nn(t){return e.jsx(Ne.Provider,{value:t.col.displayName,children:e.jsx(an,{...t})})}function an({table:t,col:n,value:i,onChange:a}){const l=Nt(t.logicalName,n.logicalName),c=ln(n,i,a);return l.error?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[c,e.jsxs(w,{style:{color:d.colorPaletteRedForeground1},children:["Couldn’t load column details: ",l.error]})]}):c}function ln(t,n,i){switch(t.attributeType){case"String":return e.jsx(sn,{col:t,value:n,onChange:i});case"Memo":return e.jsx(rn,{col:t,value:n,onChange:i});case"Integer":return e.jsx(on,{col:t,value:n,onChange:i});case"BigInt":return e.jsx(Q,{value:n,onChange:i,integer:!0,min:t.minValue,max:t.maxValue});case"Decimal":return e.jsx(Pe,{col:t,value:n,onChange:i});case"Double":return e.jsx(Pe,{col:t,value:n,onChange:i});case"Money":return e.jsx(cn,{col:t,value:n,onChange:i});case"Boolean":return e.jsx(dn,{col:t,value:n,onChange:i});case"DateTime":return e.jsx(un,{col:t,value:n,onChange:i});case"Picklist":case"State":case"Status":case"EntityName":return e.jsx(mn,{col:t,value:n,onChange:i});case"MultiSelectPicklist":return e.jsx(pn,{col:t,value:n,onChange:i});case"Lookup":case"Customer":case"Owner":return e.jsx(gn,{col:t,value:n,onChange:i});case"Uniqueidentifier":return e.jsx(fn,{value:n,onChange:i});default:return e.jsx(oe,{"aria-label":t.displayName,size:"small",value:String(n??""),onChange:(a,l)=>i(l.value),placeholder:"value"})}}function sn({col:t,value:n,onChange:i}){if(t.format==="TextArea")return e.jsx(Re,{"aria-label":t.displayName,rows:3,value:n??"",maxLength:t.maxLength,onChange:(r,o)=>i(o.value),style:{fontFamily:d.fontFamilyMonospace,fontSize:12}});const l=t.format==="Email"?"email":t.format==="Url"?"url":t.format==="Phone"?"tel":"text",c=t.format==="Email"?"name@example.com":t.format==="Url"?"https://example.com":t.format==="Phone"?"+1 (555) 555-0000":t.format==="TickerSymbol"?"MSFT":`up to ${t.maxLength} chars`;return e.jsx(oe,{"aria-label":t.displayName,size:"small",type:l,value:n??"",maxLength:t.maxLength,placeholder:c,onChange:(r,o)=>i(o.value)})}function rn({col:t,value:n,onChange:i}){const a=n??"";return e.jsx(Ot,{hint:e.jsxs("span",{style:{color:d.colorNeutralForeground3},children:[a.length.toLocaleString()," / ",t.maxLength.toLocaleString()]}),children:e.jsx(Re,{"aria-label":t.displayName,rows:4,value:a,maxLength:t.maxLength,placeholder:`up to ${t.maxLength.toLocaleString()} chars`,onChange:(l,c)=>i(c.value),style:{fontFamily:d.fontFamilyMonospace,fontSize:12}})})}function on({col:t,value:n,onChange:i}){return t.format==="Language"||t.format==="Locale"?e.jsxs(Z,{"aria-label":t.displayName,size:"small",value:n!=null?String(n):"",selectedOptions:n!=null?[String(n)]:[],onOptionSelect:(a,l)=>l.optionValue&&i(Number(l.optionValue)),placeholder:"LCID",children:[e.jsx(F,{value:"1033",children:"English (US) · 1033"}),e.jsx(F,{value:"1031",children:"German · 1031"}),e.jsx(F,{value:"1036",children:"French · 1036"}),e.jsx(F,{value:"1041",children:"Japanese · 1041"}),e.jsx(F,{value:"1043",children:"Dutch · 1043"})]}):t.format==="Duration"?e.jsxs("span",{style:{display:"inline-flex",gap:4,alignItems:"center"},children:[e.jsx(Q,{value:n,onChange:i,min:t.minValue??0,max:t.maxValue??525600,step:1,integer:!0}),e.jsx("span",{style:{fontSize:10,color:d.colorNeutralForeground3},children:"min"})]}):e.jsx(Q,{value:n,onChange:i,min:t.minValue,max:t.maxValue,step:1,integer:!0})}function Pe({col:t,value:n,onChange:i}){return e.jsx(Q,{value:n,onChange:i,min:t.minValue,max:t.maxValue,step:Math.pow(10,-t.precision)})}function Q({value:t,onChange:n,min:i,max:a,step:l,integer:c}){const r=f.useContext(Ne);return e.jsx($t,{"aria-label":r,size:"small",value:t??0,min:i,max:a,step:l??(c?1:.01),onChange:(o,m)=>{const h=m.value??Number(m.displayValue??0);Number.isFinite(h)&&n(c?Math.round(h):h)}})}function cn({col:t,value:n,onChange:i}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontFamily:d.fontFamilyMonospace,fontSize:12,color:d.colorNeutralForeground3},children:"$"}),e.jsx(Q,{value:n,onChange:i,min:t.minValue,max:t.maxValue,step:Math.pow(10,-t.precision)}),e.jsx(w,{style:{color:d.colorNeutralForeground3,fontSize:10},children:"currency = active org transactioncurrency"})]})}function dn({col:t,value:n,onChange:i}){const a=n===!0;return e.jsx(Ee,{checked:a,onChange:(l,c)=>i(c.checked),label:a?t.trueOption.label:t.falseOption.label})}function un({col:t,value:n,onChange:i}){const a=wt(t),l=Tt(n,t),c=Mt(t,l),r=h=>{if(!h){i("");return}i(Vt(n,h,t))},o=h=>{if(!h)return;const p=qt(n,h,t);p!==null&&i(p)},m=n?e.jsxs(w,{style:{color:d.colorNeutralForeground3},children:["Sends ",e.jsx("code",{style:{fontFamily:d.fontFamilyMonospace},children:n}),xe(t)==="UserLocal"&&e.jsxs(e.Fragment,{children:[" (UTC) · shown in ",Ct(l??void 0)]})]}):null;return a?e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",gap:2},children:[e.jsx(B,{content:`Behavior: ${xe(t)} — ${c}`,relationship:"description",children:e.jsx($e,{size:"small",value:l,onSelectDate:r,placeholder:"Pick a date…",formatDate:h=>h?h.toLocaleDateString():"",allowTextInput:!0})}),m]}):e.jsxs("span",{style:{display:"inline-flex",flexDirection:"column",gap:2},children:[e.jsx(B,{content:`Behavior: ${xe(t)} — ${c}`,relationship:"description",children:e.jsxs("span",{style:{display:"inline-flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[e.jsx($e,{size:"small",value:l,onSelectDate:r,placeholder:"Date…",formatDate:h=>h?h.toLocaleDateString():"",style:{minWidth:130},allowTextInput:!0}),e.jsx(Lt,{size:"small",freeform:!0,selectedTime:l,onTimeChange:(h,p)=>o(p.selectedTime),placeholder:"Time…",style:{minWidth:100},hourCycle:"h23"})]})}),m]})}function mn({col:t,value:n,onChange:i}){const a=ve(t)??[],l=a.find(c=>c.value===n);return e.jsx(Z,{"aria-label":t.displayName,size:"small",value:l?.label??(n!=null?String(n):""),selectedOptions:n!=null?[String(n)]:[],onOptionSelect:(c,r)=>r.optionValue&&i(Number(r.optionValue)),placeholder:"Pick a value…",children:a.map(c=>e.jsxs(F,{value:String(c.value),text:c.label,children:[c.label,e.jsxs("span",{style:{color:d.colorNeutralForeground3,fontFamily:d.fontFamilyMonospace,fontSize:10,marginLeft:6},children:["· ",c.value]})]},c.value))})}function pn({col:t,value:n,onChange:i}){return e.jsxs("div",{children:[e.jsx(hn,{col:t,value:n,onChange:i}),e.jsxs(w,{style:{display:"block",color:d.colorNeutralForeground3,marginTop:4,fontSize:10},children:["Emitted as comma-separated integers (e.g. ",e.jsx("code",{children:'"1,2,3"'}),") per Dataverse Web API contract."]})]})}function hn({col:t,value:n,onChange:i}){const a=ve(t)??[],[l,c]=f.useState(""),r=(n??[]).map(String),o=f.useMemo(()=>{const p=new Map;for(const b of a)p.set(String(b.value),b.label);return p},[a]),m=f.useMemo(()=>a.map(p=>String(p.value)),[a]),h=It({query:l,options:m,noOptionsElement:e.jsx(Oe,{value:"__no-matches",children:"No matches"}),renderOption:p=>e.jsx(Oe,{value:p,text:o.get(p)??p,children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[o.get(p)??p,e.jsxs("span",{style:{fontFamily:d.fontFamilyMonospace,fontSize:10,color:d.colorNeutralForeground3},children:["· ",p]})]})},p),filter:p=>r.includes(p)?!1:(o.get(p)??p).toLowerCase().includes(l.toLowerCase())});return e.jsxs(Dt,{selectedOptions:r,onOptionSelect:(p,b)=>{if(b.value==="__no-matches")return;const S=b.selectedOptions.map(j=>Number(j)).filter(j=>Number.isFinite(j)).sort((j,T)=>j-T);i(S),c("")},disableAutoFocus:l.length===0,children:[e.jsxs(Pt,{style:{maxWidth:520},children:[e.jsx(zt,{"aria-label":"Selected choices",children:r.map(p=>e.jsx(Et,{value:p,shape:"rounded",children:o.get(p)??p},p))}),e.jsx(Rt,{"aria-label":"Choose options",placeholder:r.length===0?"Type to filter options…":"",value:l,onChange:p=>c(p.target.value)})]}),e.jsx(Bt,{children:h})]})}function gn({col:t,value:n,onChange:i}){const[a,l]=f.useState(n?.targetEntity??t.targets[0]??""),c=t.targets.length>1;f.useEffect(()=>{n?.targetEntity&&n.targetEntity!==a?l(n.targetEntity):!a&&t.targets.length>0&&l(t.targets[0])},[t.targets,n?.targetEntity]);const r=se(a),[o,m]=f.useState(""),[h,p]=f.useState(!1),{rows:b,loading:S,error:j}=Ft(a,h?o:"");f.useEffect(()=>{n?.id||(m(""),p(!1))},[n?.id,a]);const E=(n?.id?b.find(y=>y.id.toLowerCase()===n.id.toLowerCase()):void 0)?.name??(n?.id?`(${n.id.slice(0,8)}…)`:""),q=h?o:E;return a?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[c?e.jsx(Z,{"aria-label":`${t.displayName} (target table)`,size:"small",value:r?.displayName??a,selectedOptions:[a],onOptionSelect:(y,g)=>{g.optionValue&&(l(g.optionValue),i({id:"",targetEntity:g.optionValue}),m(""),p(!1))},style:{width:130},children:t.targets.map(y=>{const g=se(y);return e.jsx(F,{value:y,text:g?.displayName??y,children:g?.displayName??y},y)})}):e.jsxs(V,{appearance:"ghost",style:{fontFamily:d.fontFamilyMonospace},children:["→ ",r?.entitySetName??a]}),e.jsxs(Z,{"aria-label":t.displayName,size:"small",freeform:!0,clearable:!0,value:q,selectedOptions:n?.id?[n.id]:[],onChange:y=>{const g=y.target.value;m(g),p(!0),!g&&n?.id&&i({id:"",targetEntity:a})},onOptionSelect:(y,g)=>{g.optionValue&&(i({id:g.optionValue,targetEntity:a}),m(""),p(!1))},placeholder:`Search ${r?.displayName??a} records…`,style:{minWidth:240},listbox:{style:{maxHeight:320}},children:[S&&e.jsx(F,{value:"__loading",text:"",disabled:!0,children:e.jsx(w,{style:{color:d.colorNeutralForeground3},children:"Searching…"})}),!S&&j&&e.jsx(F,{value:"__error",text:"",disabled:!0,children:e.jsx(w,{style:{color:d.colorPaletteRedForeground1},children:j})}),!S&&!j&&b.length===0&&e.jsx(F,{value:"__none",text:"",disabled:!0,children:e.jsx(w,{style:{color:d.colorNeutralForeground3},children:o?`No ${a} records match "${o}"`:`Type to search ${a}`})}),!S&&!j&&b.map(y=>e.jsx(F,{value:y.id,text:y.name,children:e.jsx(kt,{size:"extra-small",name:y.name,secondaryText:y.id,avatar:{color:"colorful"}})},y.id))]})]}):e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[e.jsx(V,{appearance:"ghost",style:{fontFamily:d.fontFamilyMonospace},children:"→ loading targets…"}),e.jsx(Z,{"aria-label":t.displayName,size:"small",disabled:!0,placeholder:"Loading…",style:{minWidth:240},children:e.jsx(F,{value:"__loading",text:"",disabled:!0,children:"—"})})]})}function fn({value:t,onChange:n}){const i=f.useContext(Ne),a=t??"",l=!a||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(a);return e.jsx(oe,{"aria-label":i,size:"small",value:a,placeholder:"00000000-0000-0000-0000-000000000000",onChange:(c,r)=>n(r.value),style:{fontFamily:d.fontFamilyMonospace},contentAfter:l?void 0:e.jsx("span",{style:{color:d.colorPaletteRedForeground1,fontSize:10},children:"invalid GUID"})})}function le({label:t,count:n,active:i,onClick:a}){return e.jsxs(be,{size:"small",shape:"circular",checked:i,onClick:a,children:[t,n!=null?` · ${n}`:""]})}function xn(t){switch(t.attributeType){case"String":case"Memo":return` · max ${t.maxLength}`;case"Decimal":case"Double":return` · ${t.precision} dec`;case"Money":return` · ${t.precision} dec`;case"Integer":return t.minValue!=null||t.maxValue!=null?` · [${t.minValue??"−∞"}…${t.maxValue??"∞"}]`:"";case"Lookup":case"Customer":case"Owner":return` · → ${t.targets.join(" | ")}`;case"Picklist":case"MultiSelectPicklist":case"State":case"Status":case"EntityName":return` · ${("options"in t?t.options:[]).length} options`;case"DateTime":return` · ${t.format} (${t.dateTimeBehavior})`;default:return""}}function Ae(t){switch(t.attributeType){case"String":case"Memo":return"";case"Integer":case"BigInt":case"Decimal":case"Double":case"Money":return 0;case"Boolean":return t.defaultValue??!1;case"DateTime":return"";case"Picklist":return ze(t)??null;case"State":return t.options[0]?.value??0;case"Status":return t.options[0]?.value??1;case"EntityName":return t.options[0]?.value??0;case"MultiSelectPicklist":{const n=ze(t);return n!=null?[n]:[]}case"Lookup":case"Customer":case"Owner":return{id:"",targetEntity:t.targets[0]};case"Uniqueidentifier":return"";default:return""}}function ze(t){const n=t.defaultFormValue;if(!(typeof n!="number"||n===-1)&&!(t.options.length>0&&!t.options.some(i=>i.value===n)))return n}function yn(t){if(Y(t))return"lookups";switch(t.attributeType){case"Picklist":case"MultiSelectPicklist":case"State":case"Status":case"EntityName":return"choices";case"Uniqueidentifier":return"system";default:return"general"}}function jn(t){const n={general:[],choices:[],lookups:[],system:[]};for(const a of t)n[yn(a)].push(a);const i=[];return n.general.length&&i.push({id:"general",title:"General",icon:At,cols:n.general}),n.choices.length&&i.push({id:"choices",title:"Choices",icon:Ht,tagText:"option sets",tagAppearance:"subtle",cols:n.choices}),n.lookups.length&&i.push({id:"lookups",title:"Lookups",icon:_t,tagText:"@odata.bind",tagAppearance:"brand",cols:n.lookups}),n.system.length&&i.push({id:"system",title:"System",icon:Be,cols:n.system}),i}function bn({title:t,icon:n,tagText:i,tagAppearance:a,children:l}){return e.jsxs("div",{style:{border:`1px solid ${d.colorNeutralStroke2}`,borderRadius:d.borderRadiusMedium,background:d.colorNeutralBackground1,padding:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[e.jsx(n,{style:{width:16,height:16,color:d.colorNeutralForeground2}}),e.jsx("strong",{style:{fontSize:12,color:d.colorNeutralForeground1},children:t}),i&&e.jsx(V,{appearance:a==="brand"?"tint":"ghost",color:a==="brand"?"brand":void 0,children:i})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:l})]})}function Sn({text:t,error:n,unmapped:i,verbatim:a,switchIssue:l,onDiscard:c,onSwitchAnyway:r,onStay:o,themeMode:m,onChange:h,table:p,writable:b,nullSupported:S,advancedFindOnly:j}){const{entities:T,loading:E}=xt(),{table:q,loading:y}=yt(p.logicalName),g=f.useMemo(()=>{const C=q??p,L=new Map(C.columns.map(v=>[v.logicalName,v])),A=new Map(T.map(v=>[v.logicalName,v.entitySetName]));return Qt(C,b.map(v=>L.get(v.logicalName)??v),{nullSupported:S,suggest:v=>vt(v,j),entitySetOf:v=>se(v)?.entitySetName??A.get(v)})},[p,q,b,S,j,T]),R=e.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18},children:i.map(C=>e.jsxs("li",{children:[e.jsx("code",{style:{fontFamily:d.fontFamilyMonospace},children:C.key})," — ",C.reason]},C.key))});return e.jsxs("div",{style:{maxWidth:880,display:"flex",flexDirection:"column",gap:10},children:[e.jsx(D,{layout:"multiline",intent:"info",children:e.jsxs(P,{children:[a?e.jsxs(e.Fragment,{children:["Raw JSON edit mode — the request body is exactly this JSON, including"," ",e.jsx("code",{style:{fontFamily:d.fontFamilyMonospace},children:"null"})," values and keys the form doesn't know."," "]}):e.jsxs(e.Fragment,{children:["Raw JSON edit mode — edits are applied to the fields as you type. Keys that don't map to a field aren't sent."," "]}),"Lookups use"," ",e.jsx("code",{style:{fontFamily:d.fontFamilyMonospace},children:'"<col>@odata.bind": "/<entitySet>(<guid>)"'})," ","and multi-select choices are comma-separated integer strings. Switch back to"," ",e.jsx("strong",{children:"Form"})," to use the metadata-driven controls."]})}),l?.kind==="invalid"&&e.jsxs(D,{layout:"multiline",intent:"error",children:[e.jsxs(P,{children:[e.jsx(re,{children:"Can't switch to Form — the JSON doesn't parse."}),l.error," Fix it, or discard your JSON edits and go back to the form as it was."]}),e.jsxs(Le,{children:[e.jsx(z,{size:"small",onClick:c,children:"Discard JSON edits"}),e.jsx(z,{size:"small",appearance:"primary",onClick:o,children:"Keep editing"})]})]}),l?.kind==="unmapped"&&e.jsxs(D,{layout:"multiline",intent:"warning",children:[e.jsxs(P,{children:[e.jsxs(re,{children:[i.length," key",i.length===1?"":"s"," can't be shown in the Form view."]}),"Switching to Form drops ",i.length===1?"it":"them"," from the body:",R]}),e.jsxs(Le,{children:[e.jsxs(z,{size:"small",onClick:r,children:["Switch and drop ",i.length===1?"it":"them"]}),e.jsx(z,{size:"small",appearance:"primary",onClick:o,children:"Stay in JSON"})]})]}),n&&!l&&e.jsx(D,{layout:"multiline",intent:"error",children:e.jsxs(P,{children:[e.jsx("strong",{children:"Invalid JSON."})," ",n,a&&" Execute is disabled until the body parses."]})}),!n&&!l&&i.length>0&&e.jsx(D,{layout:"multiline",intent:a?"info":"warning",children:e.jsxs(P,{children:[a?e.jsxs(e.Fragment,{children:["Sent as typed, but the Form view can't show"," ",i.length===1?"this key":"these keys",":"]}):e.jsxs(e.Fragment,{children:["Not sent — ",i.length===1?"this key doesn’t":"these keys don’t"," map to a field:"]}),R]})}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{style:{height:360,border:`1px solid ${d.colorNeutralStroke2}`,borderRadius:d.borderRadiusMedium,overflow:"hidden",background:m==="dark"?"#1e1e1e":d.colorNeutralBackground1},children:e.jsx(Wt,{height:"100%",language:"json",value:t,jsonSchema:E||y?null:g,onChange:C=>h(C??""),theme:m==="dark"?"vs-dark":"light",options:{lineNumbers:"on",renderLineHighlight:"line",minimap:{enabled:!1},scrollBeyondLastLine:!1,fontFamily:"Cascadia Mono, Consolas, monospace",fontSize:13,tabSize:2,insertSpaces:!0,wordWrap:"on",automaticLayout:!0,padding:{top:10,bottom:10},formatOnPaste:!0,formatOnType:!0,bracketPairColorization:{enabled:!0},guides:{bracketPairs:!0,indentation:!0}}})}),e.jsx(B,{content:"Copy body JSON",relationship:"label",children:e.jsx(z,{icon:e.jsx(bt,{}),size:"small",appearance:"subtle",style:{position:"absolute",top:6,right:6,zIndex:2},onClick:()=>{jt(t,"the body JSON")}})})]})]})}function wn(t){const n={};for(const i of t.columns)je(i)&&(qe(i)||(n[i.logicalName]=Ae(i)));return n}export{kn as F,Fn as K,gn as L,Be as a,wn as s};
@@ -0,0 +1,7 @@
1
+ import{i as X,a as Pe,n as Ie,b as qe,p as ye,d as De,c as Be,e as Ue,r as J,u as Ne,f as ze,j as f,D as _e,g as Me,h as We,k as Fe,l as Ge,C as ae,t as V,T as He,S as Je,M as $e,m as we,o as Ve,B as Ze,q as Ye,s as ie,v as Qe,w as Xe,x as Ke,y as et}from"./index-NW0Z4UWR.js";import{d as be}from"./writeState-DgYICTBE.js";import{p as tt}from"./multipart-Bd_eOd8a.js";const xe=new Set(["-X","--request","-H","--header","-d","--data","--data-raw","--data-binary","--data-ascii","--data-urlencode","--json","-u","--user","-b","--cookie","-c","--cookie-jar","-A","--user-agent","-e","--referer","-o","--output","--url","-m","--max-time","--connect-timeout","-x","--proxy","--retry","-w","--write-out","--oauth2-bearer","-E","--cert","--key","--cacert","-T","--upload-file","-F","--form"]),nt=new Set(["-d","--data","--data-raw","--data-binary","--data-ascii","--data-urlencode","--json"]),ve=new Set("sSLkivgGIfnqN#0123".split(""));function st(d){return/\^"|\s\^\r?\n/.test(d)?d.replace(/\^\r?\n/g," ").replace(/\^([\s\S])/g,"$1"):d}function ot(d){const n=st(d).replace(/`\r?\n/g," "),c=[];let s="",o=!1,e=0;const g=()=>{o&&c.push(s),s="",o=!1};for(;e<n.length;){const r=n[e];if(r==="\\"&&(n[e+1]===`
2
+ `||n[e+1]==="\r"&&n[e+2]===`
3
+ `)){e+=n[e+1]==="\r"?3:2;continue}if(/\s/.test(r)){g(),e++;continue}if(!o&&r==="#"){const a=n.indexOf(`
4
+ `,e);e=a<0?n.length:a;continue}if(!o&&(r==="|"||r===";"||r===">"||r==="&"))break;if(o=!0,r==="'"){const a=n.indexOf("'",e+1);if(a<0)throw new Error("A single-quoted value is never closed.");s+=n.slice(e+1,a),e=a+1}else if(r==="$"&&n[e+1]==="'")for(e+=2;;){if(e>=n.length)throw new Error("A $'…' value is never closed.");const a=n[e];if(a==="'"){e++;break}if(a!=="\\"){s+=a,e++;continue}const h=n[e+1],x={n:`
5
+ `,r:"\r",t:" ","\\":"\\","'":"'",'"':'"',a:"\x07",b:"\b",f:"\f",v:"\v",e:"\x1B"};if(h in x)s+=x[h],e+=2;else if(h==="x"&&/^[0-9a-fA-F]{1,2}/.test(n.slice(e+2))){const y=/^[0-9a-fA-F]{1,2}/.exec(n.slice(e+2))[0];s+=String.fromCharCode(parseInt(y,16)),e+=2+y.length}else if((h==="u"||h==="U")&&/^[0-9a-fA-F]{1,8}/.test(n.slice(e+2))){const y=new RegExp(`^[0-9a-fA-F]{1,${h==="u"?4:8}}`).exec(n.slice(e+2))[0];s+=String.fromCodePoint(parseInt(y,16)),e+=2+y.length}else s+="\\",e++}else if(r==='"')for(e++;;){if(e>=n.length)throw new Error("A double-quoted value is never closed.");const a=n[e];if(a==='"'){e++;break}if(a==="\\"&&'"\\$`\n'.includes(n[e+1])){n[e+1]!==`
6
+ `&&(s+=n[e+1]),e+=2;continue}s+=a,e++}else r==="\\"?(e+1<n.length&&(s+=n[e+1]),e+=2):(s+=r,e++)}return g(),c}function rt(d){let n;try{n=ot(d.trim())}catch($){return{ok:!1,error:$ instanceof Error?$.message:String($)}}n[0]==="$"&&n.shift();const c=n.shift()??"";if(!/^curl(\.exe)?$/i.test(c.replace(/^.*[\\/]/,"")))return{ok:!1,error:"Paste a command that starts with curl."};let s,o;const e=[],g=[],r=[];let a=!1,h=!1;const x=new Set;for(let $=0;$<n.length;$++){let i=n[$],T;if(i.startsWith("--")&&i.includes("=")){const l=i.indexOf("=");T=i.slice(l+1),i=i.slice(0,l)}if(!i.startsWith("-")||i==="-"){if(/^curl(\.exe)?$/i.test(i))return{ok:!1,error:"Paste one curl command at a time."};if(o)return{ok:!1,error:`The command has more than one URL ("${i}").`};o=i;continue}if(/^-[^-]/.test(i)&&i.length>2){let l=1;for(;l<i.length&&ve.has(i[l]);){if(i[l]==="G"&&(a=!0),i[l]==="I")return{ok:!1,error:"A HEAD request (-I) has nothing to import."};l++}if(l===i.length)continue;const m=`-${i[l]}`;xe.has(m)&&(T=l+1<i.length?i.slice(l+1):void 0,i=m)}if(xe.has(i)&&T===void 0){if($+1>=n.length)return{ok:!1,error:`${i} needs a value.`};T=n[++$]}switch(i){case"-X":case"--request":s=T.toUpperCase();break;case"-H":case"--header":{const l=T.indexOf(":");if(l<=0){const A=T.split(/[\s;:]/)[0];r.push(`Left out the header "${A}": it has no value.`);break}const m=T.slice(l+1).trim();m&&e.push({name:T.slice(0,l).trim(),value:m});break}case"--url":if(o)return{ok:!1,error:"The command has more than one URL."};o=T;break;case"-u":case"--user":case"--oauth2-bearer":r.push(`Left out ${i}: ToolBox signs you in.`);break;case"-b":case"--cookie":r.push(`Left out ${i}: ToolBox signs you in, so cookies aren't needed.`);break;case"-G":case"--get":a=!0;break;case"-I":case"--head":return{ok:!1,error:"A HEAD request (-I) has nothing to import."};case"-F":case"--form":case"-T":case"--upload-file":return{ok:!1,error:`${i} uploads a file or form, which import doesn't read. Use the file / image / attachment modes instead.`};default:if(nt.has(i)){i==="--json"&&(h=!0);const l=T;if(l.startsWith("@")&&i!=="--data-raw")return{ok:!1,error:`The body is read from a file (${l}). Paste the command with the body inline, for example --data-raw '{…}'.`};g.push(l)}else!T&&!i.startsWith("--")?ve.has(i.slice(1))||x.add(i):["--compressed","--globoff","--silent","--show-error","--location","--insecure","--include","--verbose","--fail","--http1.1","--http2","-A","--user-agent","-e","--referer","-o","--output","-m","--max-time","--connect-timeout","--retry","-w","--write-out","-c","--cookie-jar"].includes(i)||x.add(i)}}if(!o)return{ok:!1,error:"The command has no URL."};x.size>0&&r.push(`Ignored ${[...x].join(", ")}.`);let y=g.length?g.join("&"):void 0;return a&&y!==void 0&&(o+=(o.includes("?")?"&":"?")+y,y=void 0),h&&(e.some($=>$.name.toLowerCase()==="content-type")||e.push({name:"Content-Type",value:"application/json"}),e.some($=>$.name.toLowerCase()==="accept")||e.push({name:"Accept",value:"application/json"})),{ok:!0,command:{method:s??(a?"GET":y!==void 0?"POST":"GET"),url:o,headers:e,body:y,notes:r}}}const le=/^\{?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}?$/i,ce=/^[A-Za-z_][A-Za-z0-9_]*$/,at=/^\/api\/data\/v9\.\d+\/(.*)$/i,G="Microsoft.Dynamics.CRM.",Te=new Set(["user-agent","referer","origin","accept-language","accept-encoding","priority","dnt","connection","host","content-length","cache-control","pragma","x-requested-with","clienthost","x-ms-user-agent","x-ms-client-request-id","x-ms-client-session-id","x-ms-app-name","x-ms-correlation-id"]),ke={"odata.community.display.v1.formattedvalue":"formattedValues","microsoft.dynamics.crm.lookuplogicalname":"lookupLogicalNames","microsoft.dynamics.crm.associatednavigationproperty":"associatedNavProperty","microsoft.dynamics.crm.totalrecordcount":"totalRecordCount","microsoft.dynamics.crm.totalrecordcountlimitexceeded":"totalRecordCount"};function it(d){const n=[];let c="",s=!1;for(const o of d)o==='"'&&(s=!s),o===","&&!s?(n.push(c.trim()),c=""):c+=o;return c.trim()&&n.push(c.trim()),n.filter(Boolean)}function ct(d){const n={...Ue(),formattedValues:!1},c=[];let s=!1;if(!d)return{spec:n,continueOnError:s,unknown:c};for(const o of it(d)){const e=o.toLowerCase(),g=/^odata\.include-annotations\s*=\s*"?([^"]*)"?$/i.exec(o);if(g)for(const r of g[1].split(",").map(a=>a.trim()))r==="*"?n.allAnnotations=!0:ke[r.toLowerCase()]?n[ke[r.toLowerCase()]]=!0:r&&c.push(`odata.include-annotations="${r}"`);else e==="return=representation"?n.returnRepresentation=!0:e==="return=minimal"?n.returnRepresentation=!1:/^odata\.maxpagesize\s*=\s*\d+$/.test(e)?n.maxpagesize=Number(e.split("=")[1]):e==="odata.continue-on-error"?s=!0:c.push(o)}return{spec:n,continueOnError:s,unknown:c}}const K="mscrm.bypassbusinesslogicexecution",Le="mscrm.bypassbusinesslogicexecutionstepids",Se="mscrm.bypasscustompluginexecution",Ce="mscrm.suppresscallbackregistrationexpanderjob";function lt(d){const n=be(),c=r=>[K,Le,Se].includes(r.name.toLowerCase()),s=d.filter(c),o=d.filter(r=>r.name.toLowerCase()===Ce);let e=d.filter(r=>!c(r)&&r.name.toLowerCase()!==Ce),g=s.length<=1&&o.length<=1;if(g&&s.length===1){const r=s[0],a=r.name.toLowerCase(),h=r.value.replace(/\s+/g,"").toLowerCase(),x=new Set(h.split(","));if(a===K&&x.size===2&&x.has("customsync")&&x.has("customasync"))n.businessLogic="both";else if(a===K&&h==="customsync")n.businessLogic="sync";else if(a===K&&h==="customasync")n.businessLogic="async";else if(a===Se&&h==="true")n.businessLogic="sync",n.useLegacyHeader=!0;else if(a===Le){const y=r.value.split(",").map(S=>S.trim());y.every(S=>le.test(S))?(n.businessLogic="steps",n.stepIds=y.map(Ee)):g=!1}else g=!1}return g&&o.length===1&&(o[0].value.trim().toLowerCase()==="true"?n.suppressFlows=!0:g=!1),g?{bypass:n,rest:e,kept:!1}:(e=d,{bypass:be(),rest:e,kept:s.length+o.length>0})}function ut(d,n){return n?.trim()==="*"?{kind:"create-only"}:d?.trim()==="*"?{kind:"update-only"}:d?{kind:"etag",etag:d.trim()}:{kind:"none"}}const Ee=d=>d.replace(/^\{|\}$/g,"").toLowerCase();function ue(d){try{return decodeURIComponent(d)}catch{return d}}function je(d){const n=new Map;for(const c of d.split("&")){if(!c)continue;const s=c.indexOf("="),o=ue(s<0?c:c.slice(0,s));n.set(o,ue(s<0?"":c.slice(s+1)))}return n}async function dt(d,n){const c=[],s=[],o=[],e=t=>({notes:c,warnings:s,errors:[...o,t]}),g=rt(d);if(!g.ok)return e(g.error);const r=g.command;c.push(...r.notes);const a=r.method;if(!["GET","POST","PATCH","PUT","DELETE"].includes(a))return e(`${a} isn't a Dataverse Web API method.`);const h=/^(https?):\/\/([^/?#]+)(.*)$/i.exec(r.url);if(!h&&!r.url.startsWith("/"))return e(`"${r.url}" isn't a Dataverse Web API URL (https://<org>/api/data/v9.x/…).`);if(h&&h[1].toLowerCase()!=="https")return e("The URL must use https: Dataverse only answers over https.");const x=h?h[2].toLowerCase():"",y=(h?h[3]:r.url).replace(/#.*$/,""),S=y.indexOf("?"),$=S<0?y:y.slice(0,S),i=S<0?"":y.slice(S+1),T=at.exec($);if(!T)return e(`The URL path isn't under /api/data/v9.x/ — "${$||"/"}".`);const l=T[1].replace(/\/+$/,"");if(x&&n.host&&x!==n.host.toLowerCase()&&s.push(`The command is for ${x}; it opens against the environment you're connected to (${n.host}).`),l.split("/").some(t=>t===".."||t==="."))return e('The URL path has "." or ".." segments.');const m=[],A=[];let D=null,j=null,B=null,H=null;for(const t of r.headers){const u=t.name.toLowerCase();if(!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(t.name))return e(`"${t.name}" isn't a header name.`);if(/[\x00-\x1f\x7f]/.test(t.value))return e(`The ${t.name} header has a control character.`);X(t.name)?c.push(`Left out ${t.name}: ToolBox signs you in.`):Te.has(u)||u.startsWith("sec-")?A.push(t.name):u==="prefer"?D=D?`${D}, ${t.value}`:t.value:u==="if-match"?j=t.value:u==="if-none-match"?B=t.value:(u==="content-type"&&(H=t.value),m.push(t))}A.length&&c.push(`Left out browser headers: ${A.join(", ")}.`);const k=ct(D),{bypass:ee,rest:te,kept:Re}=lt(m),ne=()=>{Re&&s.push("Kept the bypass headers as header rows: the Bypass pane can't show this combination.")},Z=(t,u)=>s.push(`Left out ${t}: ${u}.`),de=t=>{j&&Z(`If-Match: ${j}`,t),B&&Z(`If-None-Match: ${B}`,t)},se=()=>{k.spec.maxpagesize!=null&&Z(`Prefer: odata.maxpagesize=${k.spec.maxpagesize}`,"only queries page")},fe=()=>(j&&Z(`If-Match: ${j}`,"reads use If-None-Match"),B?[...m,{name:"If-None-Match",value:B}]:m),U={method:a,path:l+(i?`?${i}`:"")},N=t=>({request:t,...U,notes:c,warnings:s,errors:o}),z=(t,u)=>e(`Import doesn't open ${t} yet. ${u}`),_=t=>{k.unknown.length&&s.push(`Left out Prefer: ${k.unknown.join(", ")}.`),k.continueOnError&&s.push("Left out Prefer: odata.continue-on-error (only $batch uses it)."),t==="none"&&D&&s.push(`Left out Prefer: ${D} (this mode doesn't send one).`),t==="read"&&k.spec.returnRepresentation&&s.push("Left out Prefer: return=representation (reads return the rows anyway).")},oe=()=>{r.body!==void 0&&r.body!==""&&s.push(`Left out the body: a ${a} request doesn't send one.`)},re=t=>{if(r.body===void 0||r.body==="")return t?(o.push(`A ${a} request needs a JSON body.`),null):"{}";if(H&&!/json/i.test(H))return o.push(`The body is ${H}, not JSON.`),null;const u=Be(r.body);return u.ok?JSON.stringify(u.body,null,2):(o.push(`The body isn't a JSON object: ${u.error}`),null)},pe=()=>{const t=je(i),u=t.get("$select");return t.delete("$select"),t.size&&s.push(`Left out ${[...t.keys()].join(", ")} from the URL.`),u?u.split(",").map(p=>p.trim().replace(/^_(.+)_value$/,"$1")).filter(Boolean):[]};if(/^\$batch$/i.test(l)){if(a!=="POST")return e("A $batch request is a POST.");if(!r.body)return e("The $batch request has no body.");let t;try{t=tt(r.body,H??"")}catch(w){return e(`The $batch body can't be read: ${w instanceof Error?w.message:String(w)}`)}k.unknown.length&&s.push(`Left out Prefer: ${k.unknown.join(", ")}.`),(k.spec.returnRepresentation||k.spec.maxpagesize!=null||D?.includes("annotations"))&&s.push("Left out the batch-level Prefer preferences other than odata.continue-on-error: put them on the requests that need them.");const u=r.headers.filter(w=>!X(w.name)).filter(w=>!/^(content-type|accept|odata-version|odata-maxversion|prefer)$/i.test(w.name)&&!Te.has(w.name.toLowerCase())&&!w.name.toLowerCase().startsWith("sec-")&&!(w.name.toLowerCase()==="if-none-match"&&w.value.trim()==="null"));u.length&&s.push(`Left out ${u.map(w=>w.name).join(", ")} on the batch itself: DRS sends headers on each request in it.`);const p=[];let b=0,R=!1;const M=new Set;for(const w of t){const Y=w.requests.map(C=>{b+=1,C.contentId&&C.contentId!==String(b)&&(R=!0);const W=/^https?:\/\/([^/?#]+)/i.exec(C.url)?.[1]?.toLowerCase();W&&W!==(x||n.host.toLowerCase())&&s.push(`Request ${b} is for ${W}; it goes to the environment you're connected to.`);const F=Object.entries(C.headers).filter(([q])=>(X(q)&&M.add(q),!X(q)&&q!=="content-id")).map(([q,Oe])=>({name:q,value:Oe,enabled:!0})),Q=F.find(q=>Pe(q.name));return Q&&s.push(`Request ${b} runs as another user (${Q.name}).`),Ie("custom",{method:C.method,url:C.url,body:C.body,headers:F})}),O=p[p.length-1];!w.atomic&&O&&!O.atomic?O.items.push(...Y):p.push(qe(w.atomic,Y))}return b===0?e("The $batch body has no requests."):(M.size&&c.push(`Left out ${[...M].join(", ")} from the batch's requests.`),R&&s.push("DRS numbers Content-IDs 1, 2, 3 … in batch order; check any $n references against the new numbers."),N({modeId:"batch",groups:p,continueOnError:k.continueOnError}))}const he=/^([A-Za-z_][A-Za-z0-9_.]*)(?:\(([^)]*)\))?(?:\/(.*))?$/.exec(ue(l));if(!he)return e(`"${l}" isn't an entity set, row or operation.`);const[,L,P,v=""]=he,I=L.includes(".")?void 0:n.resolveEntitySet(L);if(!I){const t=L.startsWith(G)?L.slice(G.length):L;return v||P!==void 0&&le.test(P.trim())?e(`No table with the entity set name "${L}" in this environment.`):a==="GET"?(await n.findAction?.(t).catch(()=>{}))?.kind==="Function"?z("functions",`Open Execute Function and pick ${t}.`):e(`No table or function named "${L}" in this environment.`):a!=="POST"?e(`No table with the entity set name "${L}" in this environment.`):P!==void 0?e(`An action is called without parentheses: POST /${t}.`):ge(t,null,null)}let E=null;if(P!==void 0)if(le.test(P.trim()))E=Ee(P.trim());else return P.includes("=")?z("rows addressed by an alternate key","Open Update or Upsert and enter the key there."):e(`"${P}" isn't a row id (a GUID).`);if(v.startsWith(G)){const t=v.slice(G.length);return ce.test(t)?a==="GET"?z("bound functions",`Open Execute Function and pick ${t}.`):a!=="POST"?e(`Call ${t} with POST.`):ge(t,I,E):e(`"${v}" isn't an operation name.`)}if(v&&!/^\$count$/i.test(v)){if(/\/\$ref$/i.test(v)||/^\$ref$/i.test(v))return z("associations","Use Associate or Disassociate.");if(!ce.test(v))return e(`"${v}" isn't a column or navigation property.`);if(a==="DELETE"&&E){const t=await n.loadTable?.(I);return t&&!t.columns.some(u=>u.logicalName===v)?e(`${I} has no column named "${v}".`):(oe(),me({kind:"single-property",column:v}))}return a==="PUT"?z("single-column updates (PUT)","Open Update and pick the column."):z(`${a} /${L}(…)/${v}`,"Import opens table rows and queries, actions and $batch.")}if(a==="GET"){if(oe(),!E){_("read");const p=await ye(`${L}${v?`/${v}`:""}${i?`?${i}`:""}`,n.resolveEntitySet,n.loadTable);return s.push(...p.warnings.map(b=>b.message)),!p.ok||!p.parsed||p.errors.length?(o.push(...p.errors.map(b=>b.message)),o.length||o.push("The query couldn't be read."),{...U,notes:c,warnings:s,errors:o}):N({modeId:"retrieve-multiple",parsed:p.parsed,prefer:{...k.spec,returnRepresentation:!1},headers:fe()})}if(v)return e("$count counts a table's rows, not one row.");_("read");const t=await ye(`${L}${i?`?${i}`:""}`,n.resolveEntitySet,n.loadTable);if(s.push(...t.warnings.map(p=>p.message)),!t.ok||!t.parsed||t.errors.length)return o.push(...t.errors.map(p=>p.message)),o.length||o.push("The query couldn't be read."),{...U,notes:c,warnings:s,errors:o};se();const u=[...je(i).keys()].filter(p=>p!=="$select"&&p!=="$expand");return u.length&&s.push(`Left out ${u.join(", ")}: Retrieve Single sends only $select and $expand.`),N({modeId:"retrieve-single",table:I,recordId:E,select:t.parsed.select,expand:t.parsed.expand,prefer:{...k.spec,returnRepresentation:!1,maxpagesize:null},headers:fe()})}if(v)return e("$count is only read with GET.");if(a==="POST"){if(E)return e(`POST creates a row in /${L}, not in /${L}(${E}).`);_("write");const t=re(!1);return t===null?{...U,notes:c,warnings:s,errors:o}:(r.body===void 0&&s.push("The command has no body; Create opens with {}."),de("Create doesn't send one"),se(),ne(),N({modeId:"create",table:I,rawBody:t,prefer:{...k.spec,maxpagesize:null},returnSelect:pe(),bypass:ee,headers:te}))}if(!E)return e(`${a} needs a row: /${L}(<id>).`);if(a==="PATCH"){_("write");const t=re(!0);if(t===null)return{...U,notes:c,warnings:s,errors:o};const u=ut(j,B);se(),ne();const p=u.kind==="update-only"||u.kind==="etag"?"update":"upsert";return N({modeId:p,table:I,recordId:E,rawBody:t,prefer:{...k.spec,maxpagesize:null},returnSelect:pe(),concurrency:u,bypass:ee,headers:te})}if(a==="DELETE")return oe(),me({kind:"whole-row"});return z("whole-row PUT","Use PATCH to update a row.");function me(t){_("none"),B&&s.push("Left out If-None-Match: Delete doesn't use it."),i&&s.push("Left out the query string: Delete doesn't send one."),ne();const u=j&&j.trim()!=="*"?j.trim():null;return j&&!u&&c.push("Left out If-Match: * — a DELETE of a missing row fails without it."),N({modeId:"delete",table:I,recordId:E,scope:t,concurrency:u?{kind:"etag",etag:u}:{kind:"none"},bypass:ee,headers:te})}async function ge(t,u,p){if(!ce.test(t))return e(`"${t}" isn't an action name.`);const b=await n.findAction?.(t).catch(()=>{});if(!b||b.kind!=="Action")return e(`No action named ${t} in this environment.`);const R=b.binding;if(u){if(R.kind==="unbound"||R.entityType!==u)return e(`${t} isn't bound to ${u}.`);if(R.kind==="entity"&&!p)return e(`${t} is bound to one row: /${L}(<id>)/${G}${t}.`);if(R.kind==="collection"&&p)return e(`${t} is bound to the table, not a row.`)}else if(R.kind!=="unbound")return e(`${t} is bound to ${R.entityType}; call it on /<${R.entityType} set>…/${G}${t}.`);_("none"),Ae(),de("actions don't use one");const M=re(!1);if(M===null)return{...U,notes:c,warnings:s,errors:o};for(const O of new Set(b.parameters.map(C=>C.entityType).filter(Boolean)))await n.loadTable?.(O).catch(()=>{});const w={};for(const[O,C]of Object.entries(JSON.parse(M))){const W=b.parameters.find(Q=>Q.name===O);if(!W){o.push(`${b.name} has no parameter named "${O}".`);continue}const F=De(W,C,n.resolveEntitySet);"error"in F?o.push(F.error):w[O]=F.value}if(o.length)return{...U,notes:c,warnings:s,errors:o};const Y=b.source==="custom-api"?"exec-customapi":b.source==="custom-action"?"exec-customaction":"exec-action";return N({modeId:Y,actionName:b.name,boundRecordId:p,paramValues:w,headers:m})}function Ae(){i&&s.push("Left out the query string: actions don't use one.")}}function mt({open:d,onClose:n}){const[c,s]=J.useState(""),[o,e]=J.useState(null),[g,r]=J.useState(!1),a=J.useRef(0),{allEntities:h}=Ne(),x=J.useMemo(()=>l=>h.find(m=>m.entitySetName===l)?.logicalName,[h]),y=()=>{a.current+=1,r(!1),s(""),e(null),n()},S=async()=>{if(!c.trim())return;const l=++a.current;r(!0);try{const m=await dt(c,{host:et().host,resolveEntitySet:x,loadTable:A=>Ke.getTable(A),findAction:A=>Xe.find(A)});l===a.current&&e(m)}finally{l===a.current&&r(!1)}},$=o?.errors.length?void 0:o?.request,i=$?ze($.modeId).name:"",T=()=>{$&&(Qe($)?y():e(l=>l&&{...l,errors:["Can't switch modes here. Open DRS in ToolBox."]}))};return f.jsx(_e,{open:d,onOpenChange:(l,m)=>!m.open&&y(),children:f.jsx(Me,{style:{maxWidth:760},children:f.jsxs(We,{children:[f.jsx(Fe,{children:"Import a cURL command"}),f.jsxs(Ge,{style:{display:"flex",flexDirection:"column",gap:12},children:[f.jsxs(ae,{style:{color:V.colorNeutralForeground3},children:["Paste a ",f.jsx("code",{children:"curl"})," command, for example from your browser's Copy as cURL or DRS's cURL code. It opens in the mode that sends it, filled in and not run. Authorization and cookies are left out: ToolBox signs you in."]}),f.jsx(He,{"aria-label":"cURL command",value:c,onChange:(l,m)=>{a.current+=1,r(!1),s(m.value),e(null)},rows:8,resize:"vertical",placeholder:`curl 'https://contoso.crm.dynamics.com/api/data/v9.2/accounts?$top=5' \\
7
+ -H 'Accept: application/json'`,textarea:{style:{fontFamily:V.fontFamilyMonospace,fontSize:12}}}),g&&f.jsx(Je,{size:"tiny",label:"Reading the command…"}),o&&o.errors.length>0&&f.jsx($e,{intent:"error",layout:"multiline",children:f.jsxs(we,{children:[f.jsx(Ve,{children:"Can't import this command"}),o.errors.map((l,m)=>f.jsx("div",{children:l},m))]})}),$&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",border:`1px solid ${V.colorNeutralStroke2}`,borderRadius:V.borderRadiusMedium,minWidth:0},children:[f.jsx(Ze,{appearance:"tint",shape:"rounded",children:o?.method}),f.jsx("code",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:1},title:o?.path,children:o?.path}),f.jsxs(ae,{style:{whiteSpace:"nowrap"},children:["Opens in ",f.jsx("strong",{children:i})]})]}),o&&o.warnings.length>0&&f.jsx($e,{intent:"warning",layout:"multiline",children:f.jsx(we,{children:o.warnings.map((l,m)=>f.jsx("div",{children:l},m))})}),o&&o.notes.length>0&&f.jsx("ul",{style:{margin:0,paddingLeft:18,color:V.colorNeutralForeground3},children:o.notes.map((l,m)=>f.jsx("li",{children:f.jsx(ae,{children:l})},m))})]}),f.jsxs(Ye,{children:[f.jsx(ie,{appearance:"secondary",onClick:y,children:"Cancel"}),$?f.jsxs(ie,{appearance:"primary",onClick:T,children:["Open in ",i]}):f.jsx(ie,{appearance:"primary",disabled:!c.trim()||g,onClick:()=>{S()},children:"Read command"})]})]})})})}export{mt as ImportCurlDialog};
@@ -0,0 +1 @@
1
+ import{f as pe,bh as me,r as c,U as ge,ez as be,eA as ye,eB as xe,bj as fe,W as ve,X as je,eC as Se,bl as ke,Y as D,Z as V,_ as Ie,aG as Ce,cm as Ae,j as t,cn as J,co as Te,$ as we,a0 as Fe,cp as E,cq as X,a$ as L,b0 as ze,c0 as Be,cr as Ne,a7 as Pe,a8 as Me,eD as De,a9 as Ee,ct as Le,ad as Re,cu as Ue,ae as _e,af as He,ag as Oe,ah as qe,cv as Ge,cw as $e,cx as We,ai as Ve,eE as Y,ay as S,au as u,az as R,aA as f,t as i,C as h,aB as Z,cs as K,av as x,T as Xe,eF as Ye,bg as Je,cz as Ze,bv as Ke,b9 as Qe,ax as et,bx as tt,aj as at}from"./index-NW0Z4UWR.js";import{B as nt,a as ot}from"./BinaryPipelineCard-CSklRaME.js";import{C as it}from"./CodeView-C65Y5vXN.js";import"./multipart-Bd_eOd8a.js";const rt=5*1024*1024,lt=()=>({target:"attachment",recordId:null,parentActivityId:null,parentEntityLogical:null,parentEntityId:null,operation:"upload",uploadMethod:{kind:"inline-base64"},downloadMethod:{kind:"single-request"},source:{kind:"file"},fileName:"",fileSize:0,mimeType:"application/octet-stream",bodyBase64:"",bodyUrl:"",subject:"",noteText:"",headers:at(),dirty:new Set});function xt({themeMode:n}){const r=pe("manage-attachment"),o=me("manage-attachment",Y,lt),[e,s]=c.useState(o.state),[b,A]=c.useState("pipeline"),[k,T]=c.useState("builder"),[U,w]=c.useState(null),[Q,_]=c.useState(!1),[ee,te]=ge("manage-attachment"),v=c.useMemo(()=>be(e),[e]),p=c.useMemo(()=>ye(e),[e]),F=xe[e.target],ae=a=>s(d=>{const g=new Set(d.dirty);return g.add(a),{...d,dirty:g}}),l=(a,d,g)=>{s(M=>({...M,[a]:d})),g&&ae(g)},z=p[0]?.method??"POST",H=fe([["Record id",e.recordId],["Parent activity id",e.parentActivityId]]),O=ve([{when:e.operation==="upload"&&e.target==="attachment"&&!e.parentActivityId,id:"attach-parent",title:"Pick the parent email activity for the attachment.",focusNode:"parent"},{when:e.operation==="upload"&&e.target==="annotation"&&!e.recordId,id:"attach-annotation-id",title:"Provide a caller-generated annotationid (Annotations require an explicit GUID).",focusNode:"parent"},{when:e.operation!=="upload"&&!e.recordId,id:"attach-record",title:`Pick the existing ${e.target} record.`,focusNode:"parent"},{when:e.operation==="upload"&&e.source.kind==="file"&&!e.bodyBase64&&!e.fileName,id:"attach-upload-source",title:"Choose a file to upload.",focusNode:"source"},{when:e.headers.some(a=>a.enabled&&!a.name),id:"attach-header-name",title:"Fix empty header name.",focusNode:"headers"},{when:H,id:"attach-url-part",title:H??"",focusNode:"parent"}]),ne=je(O),oe=async()=>{_(!0);const a=await Qe.manageAttachment(e);w(a),_(!1),T("results"),te(et({snapshot:y,modeId:"manage-attachment",url:v.relativeUrl,method:z,status:a.status,ms:a.ms,rowCount:a.ok?1:0})),s(d=>({...d,dirty:new Set}))},[I,B]=c.useState(o.lastSavedId),[C,N]=c.useState(o.lastSavedHash),y=c.useMemo(()=>Se(e),[e]);ke("manage-attachment",y,I,C);const ie=c.useMemo(()=>D(y),[y]),q=C===null?!0:ie!==C,re=a=>{B(a.id),N(D(a.state))},G=a=>{if(a.modeId!=="manage-attachment")return;const d=a.state;s(Y(d)),B(a.id),N(D(d)),w(null),A("pipeline")},le=a=>{const d=tt(a,"manage-attachment");if(!d)return;const g=I,M=C;G(d),B(g),N(M)},$=V(re),W=V(G);Ie(c.useMemo(()=>({state:y,modeId:"manage-attachment",dirty:q,lastSavedId:I,onSaved:$,onLoadSaved:W}),[y,q,I,$,W]));const se=c.useMemo(()=>Ce()?[Ae.warn("binary-host-unsupported","header","Attachment / Note operations run externally",t.jsxs("span",{children:["PPTB's ",t.jsx("code",{children:"dataverseAPI"})," doesn't expose the attachment / annotation message endpoints. Build the request here, then copy a snippet from the ",t.jsx("strong",{children:"Code"})," tab (fetch / curl / C# / PowerShell) and run it from there. Execute will return"," ",t.jsx("code",{children:"501 Not Implemented"}),"."]}),"pipeline","https://learn.microsoft.com/en-us/power-apps/developer/data-platform/attachment-annotation-files")]:[],[]),j=e.operation==="upload"?"UPLOAD":e.operation==="download"?"DOWNLOAD":"DELETE",de=e.operation==="delete"?"danger":"brand",P=e.operation==="upload"?e.uploadMethod.kind:e.operation==="download"?e.downloadMethod.kind:"simple",ce=[{id:"operation",label:"Operation",meta:j.toLowerCase(),items:[{id:"operation",icon:Te,iconFilled:J,label:j.charAt(0)+j.slice(1).toLowerCase(),badge:j,badgeAppearance:"tint",badgeColor:de,dirty:e.dirty.has("operation")}]},{id:"target",label:"Target",meta:e.target,items:[{id:"target",icon:Fe,iconFilled:we,label:De(e.target),badge:e.target,badgeAppearance:"ghost",dirty:e.dirty.has("target")}]},{id:"parent",label:e.target==="attachment"?"Parent email":"Annotation id",meta:e.target==="attachment"?e.parentActivityId?e.parentActivityId.slice(0,8):"unset":e.recordId?e.recordId.slice(0,8):"unset",items:[{id:"parent",icon:X,iconFilled:E,label:e.target==="attachment"?"Email + record reference":"Annotation id + optional parent",badge:(e.target==="attachment"?e.parentActivityId:e.recordId)?"✓":null,badgeAppearance:"ghost",dirty:e.dirty.has("parent")}]},...e.operation!=="delete"?[{id:"method",label:"Method",meta:P,items:[{id:"method",icon:ze,iconFilled:L,label:e.operation==="upload"?"Upload method":"Download method",badge:P,badgeAppearance:"ghost",dirty:e.dirty.has("method")}]}]:[],...e.operation==="upload"?[{id:"payload",label:"Payload",meta:e.fileName||"—",items:[{id:"source",icon:X,iconFilled:E,label:"Source",badge:e.source.kind,badgeAppearance:"ghost",dirty:e.dirty.has("source")}]}]:[],{id:"pipe",label:"Pipeline",meta:`${p.length} request${p.length===1?"":"s"}`,items:[{id:"pipeline",icon:Ne,iconFilled:Be,label:"Generated requests",badge:p.length||null,badgeAppearance:"tint",badgeColor:"brand",dirty:e.dirty.has("pipeline")}]},{id:"headers",label:"Headers",meta:`${e.headers.filter(a=>a.enabled).length} active`,items:[{id:"headers",icon:Me,iconFilled:Pe,label:"HTTP headers",badge:e.headers.filter(a=>a.enabled).length||null,dirty:e.dirty.has("headers")}]}];let m;switch(b){case"operation":m=t.jsx(st,{value:e.operation,onChange:a=>l("operation",a,"operation")});break;case"target":m=t.jsx(dt,{value:e.target,onChange:a=>{s(d=>({...d,target:a,recordId:null,parentActivityId:null,parentEntityLogical:null,parentEntityId:null,dirty:new Set(["target","parent"])})),w(null)}});break;case"parent":m=t.jsx(ct,{target:e.target,recordId:e.recordId,parentActivityId:e.parentActivityId,parentEntityLogical:e.parentEntityLogical,parentEntityId:e.parentEntityId,subject:e.subject,noteText:e.noteText,onRecordIdChange:a=>l("recordId",a,"parent"),onParentActivityIdChange:a=>l("parentActivityId",a,"parent"),onParentEntityLogicalChange:a=>l("parentEntityLogical",a,"parent"),onParentEntityIdChange:a=>l("parentEntityId",a,"parent"),onSubjectChange:a=>l("subject",a,"parent"),onNoteTextChange:a=>l("noteText",a,"parent")});break;case"method":m=e.operation==="upload"?t.jsx(ut,{value:e.uploadMethod,onChange:a=>l("uploadMethod",a,"method")}):t.jsx(ht,{value:e.downloadMethod,onChange:a=>l("downloadMethod",a,"method")});break;case"source":m=t.jsx(ot,{source:e.source,setSource:a=>l("source",a,"source"),fileName:e.fileName,setFileName:a=>l("fileName",a,"source"),fileSize:e.fileSize,setFileSize:a=>l("fileSize",a,"source"),mimeType:e.mimeType,setMimeType:a=>l("mimeType",a,"source"),bodyBase64:e.bodyBase64,setBodyBase64:a=>l("bodyBase64",a,"source"),bodyUrl:e.bodyUrl,setBodyUrl:a=>l("bodyUrl",a,"source"),group:"binary"});break;case"pipeline":m=t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:t.jsx(nt,{steps:p,title:`${j} pipeline — ${P}`,sub:p.length>1?"Each request fires sequentially.":void 0,sizeAdvisory:e.operation==="upload"?Le(e.fileSize,rt,e.target):null})});break;case"headers":m=t.jsx(Ee,{items:e.headers,setItems:a=>l("headers",a,"headers"),group:"binary"});break}const ue=Re(e.headers,null),he={method:z,built:v,...Ue(p,ue),entityLogical:v.entityLogical};return t.jsx(_e,{sidebar:t.jsx(Ve,{type:r,urlPreview:v.relativeNoBase,sections:ce,activeNode:b,onSelect:a=>{A(a),T("builder")},recents:ee,onRecentClick:le}),urlBar:t.jsx(qe,{method:z,url:v.relativeUrl,executeVerb:e.operation==="upload"?"Upload":e.operation==="download"?"Download":"Delete",executeIcon:e.operation==="upload"?Ge:e.operation==="download"?$e:We,disabledReason:ne,loading:Q,onExecute:oe,advisories:[...O,...se],onAdvisoryFocus:A}),children:t.jsxs(He,{tab:k,onTabChange:T,resultCount:U?.ok?p.length:null,children:[k==="builder"&&m,k==="code"&&t.jsx(it,{themeMode:n,inputs:he}),k==="results"&&t.jsx(Oe,{result:U,mode:"single",table:F.entityLogical,writeContext:{operation:"manage-attachment",table:F.entityLogical,recordId:e.recordId,recordName:e.fileName||null,fileOperation:e.operation,columnName:F.bodyColumn,fileName:e.fileName||void 0}})]})})}function st({value:n,onChange:r}){const o=Je(),e=[{id:"upload",label:"Upload",sub:"Inline base 64 (≲4 MB) or Initialize/UploadBlock/Commit messages.",tone:"brand"},{id:"download",label:"Download",sub:"GET /<set>(<id>)/{body|documentbody}/$value or Initialize/DownloadBlock messages.",tone:"brand"},{id:"delete",label:"Delete",sub:"DELETE /<set>(<id>) — removes the entire attachment / note record.",tone:"danger"}];return t.jsxs("div",{children:[t.jsx(S,{icon:J,title:"Operation",sub:"What to do with the attachment or annotation.",group:"binary"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12,maxWidth:960},children:e.map(s=>{const b=n===s.id;return t.jsxs("button",{type:"button",onClick:()=>r(s.id),className:Ke(o.inlineCard),style:{textAlign:"left",padding:14,cursor:"pointer",background:b?s.tone==="danger"?i.colorPaletteRedBackground2:i.colorBrandBackground2:i.colorNeutralBackground1,border:`1px solid ${b?s.tone==="danger"?i.colorPaletteRedBorderActive:i.colorBrandStroke1:i.colorNeutralStroke2}`,borderRadius:i.borderRadiusMedium},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("strong",{style:{fontSize:13},children:s.label}),b&&t.jsx(Ze,{style:{marginLeft:"auto",color:s.tone==="danger"?i.colorPaletteRedForeground1:i.colorBrandForeground1},"aria-label":"Selected"})]}),t.jsx(h,{style:{color:i.colorNeutralForeground2,lineHeight:1.4,marginTop:6,display:"block"},children:s.sub})]},s.id)})})]})}function dt({value:n,onChange:r}){return t.jsxs("div",{children:[t.jsx(S,{icon:Ye,title:"Target type",sub:"Pick the record type — drives the body column, message names, and parent reference shape.",group:"binary"}),t.jsx("div",{style:{maxWidth:760},children:t.jsx(u,{label:"Type",children:t.jsxs(R,{value:n,onChange:(o,e)=>r(e.value),children:[t.jsx(f,{value:"attachment",label:t.jsxs("span",{children:[t.jsx("strong",{children:"Attachment"})," ",t.jsx("code",{style:{fontFamily:i.fontFamilyMonospace,fontSize:11},children:"activitymimeattachment.body"}),t.jsxs(h,{style:{display:"block",color:i.colorNeutralForeground3,marginTop:2},children:["Hangs off an email activity. Upload requires"," ",t.jsx("code",{children:"objectid_email@odata.bind"}),". Server generates the activitymimeattachmentid."]})]})}),t.jsx(f,{value:"annotation",label:t.jsxs("span",{children:[t.jsx("strong",{children:"Note (Annotation)"})," ",t.jsx("code",{style:{fontFamily:i.fontFamilyMonospace,fontSize:11},children:"annotation.documentbody"}),t.jsx(h,{style:{display:"block",color:i.colorNeutralForeground3,marginTop:2},children:"Hangs off any HasNotes=true entity. Caller MUST generate the annotationid GUID for Initialize/Commit messages."})]})})]})})})]})}function ct(n){return t.jsxs("div",{children:[t.jsx(S,{icon:E,title:n.target==="attachment"?"Parent email & record reference":"Annotation id & parent reference",sub:n.target==="attachment"?"Attachment must reference its parent email activity. The attachment id is server-assigned on create.":"Annotation messages require a caller-generated GUID. Parent reference is optional but recommended for navigation.",group:"binary"}),t.jsx("div",{style:{maxWidth:760,display:"flex",flexDirection:"column",gap:14},children:n.target==="attachment"?t.jsxs(t.Fragment,{children:[t.jsx(u,{label:"Parent email activityid (GUID)",hint:"Bound via objectid_email@odata.bind: emails(<id>) on the Initialize/Commit Target.",children:t.jsx(x,{value:n.parentActivityId??"",onChange:(r,o)=>n.onParentActivityIdChange(o.value||null),placeholder:"00000000-0000-0000-0000-000000000000"})}),t.jsx(u,{label:"Existing activitymimeattachmentid (update/download/delete only)",children:t.jsx(x,{value:n.recordId??"",onChange:(r,o)=>n.onRecordIdChange(o.value||null),placeholder:"leave empty for create"})}),t.jsx(u,{label:"Subject",hint:"Optional. Stored on the attachment record alongside the binary.",children:t.jsx(x,{value:n.subject,onChange:(r,o)=>n.onSubjectChange(o.value),placeholder:"e.g. Sample attached 25mb.pdf"})})]}):t.jsxs(t.Fragment,{children:[t.jsx(u,{label:"Annotation id (GUID)",hint:"Caller-generated. Initialize / Commit will NOT auto-assign one for these messages.",children:t.jsx(x,{value:n.recordId??"",onChange:(r,o)=>n.onRecordIdChange(o.value||null),placeholder:"00000000-0000-0000-0000-000000000000"})}),t.jsx(u,{label:"Parent entity logical name (optional)",hint:"Annotations can hang off any HasNotes=true entity. Leave blank for unparented notes.",children:t.jsx(x,{value:n.parentEntityLogical??"",onChange:(r,o)=>n.onParentEntityLogicalChange(o.value||null),placeholder:"account / contact / opportunity / …"})}),t.jsx(u,{label:"Parent entity id (GUID)",children:t.jsx(x,{value:n.parentEntityId??"",onChange:(r,o)=>n.onParentEntityIdChange(o.value||null),placeholder:"00000000-0000-0000-0000-000000000000"})}),t.jsx(u,{label:"Notetext",hint:"Free-text body of the note — separate from documentbody (which carries the binary).",children:t.jsx(Xe,{value:n.noteText,onChange:(r,o)=>n.onNoteTextChange(o.value),placeholder:"Please see attached…"})})]})})]})}function ut({value:n,onChange:r}){return t.jsxs("div",{children:[t.jsx(S,{icon:L,title:"Upload method",sub:"Per attachment-annotation-files — two supported approaches.",group:"binary"}),t.jsxs("div",{style:{maxWidth:760,display:"flex",flexDirection:"column",gap:14},children:[t.jsx(u,{label:"Approach",children:t.jsxs(R,{value:n.kind,onChange:(o,e)=>{e.value==="inline-base64"?r({kind:"inline-base64"}):r({kind:"dataverse-messages",blockSize:n.kind==="dataverse-messages"?n.blockSize:4*1024*1024})},children:[t.jsx(f,{value:"inline-base64",label:t.jsxs("span",{children:[t.jsx("strong",{children:"Inline base 64"})," ",t.jsx("code",{style:{fontFamily:i.fontFamilyMonospace,fontSize:11},children:"POST / PATCH with body column set"}),t.jsx(h,{style:{display:"block",color:i.colorNeutralForeground3,marginTop:2},children:"Works for files ≲ 4 MB (Organization.MaxUploadFileSize default 5 MB). One round-trip. Body column = base 64 string in the JSON body."})]})}),t.jsx(f,{value:"dataverse-messages",label:t.jsxs("span",{children:[t.jsx("strong",{children:"Dataverse messages"})," ",t.jsx("code",{style:{fontFamily:i.fontFamilyMonospace,fontSize:11},children:"Initialize* / UploadBlock / Commit*"}),t.jsx(h,{style:{display:"block",color:i.colorNeutralForeground3,marginTop:2},children:"Three OData actions. Up to 128 MB. UploadBlock is shared with file columns. Commit returns FileSizeInBytes + record id."})]})})]})}),n.kind==="dataverse-messages"&&t.jsxs(u,{label:"Block size (bytes)",hint:"Defaults to 4 MB. BlockData must be ≤ 4 MB before base 64 encoding.",children:[t.jsx(Z,{value:n.blockSize,min:64*1024,max:4*1024*1024,step:1024*1024,onChange:(o,e)=>r({kind:"dataverse-messages",blockSize:Number(e.value??e.displayValue??n.blockSize)})}),t.jsxs(h,{style:{marginTop:4,display:"block",color:i.colorNeutralForeground3},children:["≈ ",K(n.blockSize)," per block."]})]})]})]})}function ht({value:n,onChange:r}){return t.jsxs("div",{children:[t.jsx(S,{icon:L,title:"Download method",sub:"Per attachment-annotation-files — two supported approaches. No ranged download / SAS URL (those are file-column-only).",group:"binary"}),t.jsxs("div",{style:{maxWidth:760,display:"flex",flexDirection:"column",gap:14},children:[t.jsx(u,{label:"Approach",children:t.jsxs(R,{value:n.kind,onChange:(o,e)=>{e.value==="single-request"?r({kind:"single-request"}):r({kind:"dataverse-messages",blockSize:n.kind==="dataverse-messages"?n.blockSize:4*1024*1024})},children:[t.jsx(f,{value:"single-request",label:t.jsxs("span",{children:[t.jsx("strong",{children:"Single request"})," ",t.jsx("code",{style:{fontFamily:i.fontFamilyMonospace,fontSize:11},children:"GET …/(body|documentbody)/$value"}),t.jsx(h,{style:{display:"block",color:i.colorNeutralForeground3,marginTop:2},children:"Returns the binary as base 64 text/plain. No size / filename / mimetype headers — query those via $select on filename / mimetype."})]})}),t.jsx(f,{value:"dataverse-messages",label:t.jsxs("span",{children:[t.jsx("strong",{children:"Dataverse messages"})," ",t.jsx("code",{style:{fontFamily:i.fontFamilyMonospace,fontSize:11},children:"Initialize* / DownloadBlock"}),t.jsx(h,{style:{display:"block",color:i.colorNeutralForeground3,marginTop:2},children:"Returns FileName + FileSizeInBytes + FileContinuationToken on Initialize. Then loop DownloadBlock with Offset stepping by BlockLength."})]})})]})}),n.kind==="dataverse-messages"&&t.jsxs(u,{label:"Block size (bytes)",hint:"Defaults to 4 MB. Can stay constant — final block may be smaller and only those bytes are returned.",children:[t.jsx(Z,{value:n.blockSize,min:64*1024,max:4*1024*1024,step:1024*1024,onChange:(o,e)=>r({kind:"dataverse-messages",blockSize:Number(e.value??e.displayValue??n.blockSize)})}),t.jsxs(h,{style:{marginTop:4,display:"block",color:i.colorNeutralForeground3},children:["≈ ",K(n.blockSize)," per block."]})]})]})]})}export{xt as ManageAttachmentMode};
@@ -0,0 +1 @@
1
+ import{f as ke,bh as je,r,R as Se,U as ve,cj as Fe,ck as we,z as Ce,bj as Be,W as ze,X as Te,u as Me,cl as Ne,bl as Pe,Y as H,Z as Q,_ as Re,aG as Ae,cm as De,j as e,cn as oe,co as Ie,$ as Ue,a0 as Le,cp as ee,cq as ae,a$ as q,b0 as Ee,c0 as He,cr as qe,a7 as $e,a8 as Ge,cs as P,a9 as Oe,ct as We,ab as _e,ad as Ve,cu as Ke,ae as Ye,af as Xe,ag as Ze,ah as Je,cv as Qe,cw as ea,cx as aa,ai as la,cy as le,b8 as oa,M as T,m as M,o as N,ay as $,au as g,az as se,aA as b,t as s,C as u,aB as v,bg as sa,cz as ta,bv as na,b9 as ia,ax as ra,bx as da,aj as ca}from"./index-NW0Z4UWR.js";import{F as ua}from"./BinaryColumnPickers-NAaoPcPt.js";import{B as ha,a as ma}from"./BinaryPipelineCard-CSklRaME.js";import{C as pa}from"./CodeView-C65Y5vXN.js";import"./multipart-Bd_eOd8a.js";const ga=()=>({table:"",recordId:null,fileColumn:"",operation:"upload",uploadMethod:{kind:"chunked-patch",chunkSize:2*1024*1024},downloadMethod:{kind:"single-request"},source:{kind:"file"},fileName:"",fileSize:0,mimeType:"application/octet-stream",bodyBase64:"",bodyUrl:"",headers:ca(),dirty:new Set});function Ca({themeMode:o}){const t=ke("manage-file"),d=je("manage-file",le,ga),[a,i]=r.useState(d.state),{table:f}=Se(a.table||null),[G,R]=r.useState("pipeline"),[F,A]=r.useState("builder"),[O,D]=r.useState(null),[te,W]=r.useState(!1),[ne,ie]=ve("manage-file"),x=r.useMemo(()=>Fe(a),[a,f]),m=r.useMemo(()=>we(a),[a,f]),k=Ce(a.table),j=r.useMemo(()=>(k?.columns??[]).find(l=>l.attributeType==="File"&&l.logicalName===a.fileColumn),[k,a.fileColumn]),re=l=>i(n=>{const h=new Set(n.dirty);return h.add(l),{...n,dirty:h}}),c=(l,n,h)=>{i(E=>({...E,[l]:n})),h&&re(h)},I=m[0]?.method??"PATCH",U=Be([["Record id",a.recordId]],[["File column",a.fileColumn]]),_=ze([{when:!k,id:"file-table",title:"Pick a target table first.",focusNode:"target"},{when:!a.recordId,id:"file-record",title:"Pick a source record.",focusNode:"target"},{when:!a.fileColumn,id:"file-column",title:"Pick a file column.",focusNode:"column"},{when:a.operation==="upload"&&a.source.kind==="file"&&!a.bodyBase64&&!a.fileName,id:"file-upload-source",title:"Choose a file to upload.",focusNode:"source"},{when:a.headers.some(l=>l.enabled&&!l.name),id:"file-header-name",title:"Fix empty header name.",focusNode:"headers"},{when:U,id:"file-url-part",title:U??"",focusNode:U?.startsWith("File column")?"column":"target"}]),de=Te(_),[ce,V]=r.useState(""),ue=async()=>{W(!0);const l=await ia.manageFile(a);D(l),W(!1),A("results"),ie(ra({snapshot:y,modeId:"manage-file",url:x.relativeUrl,method:I,status:l.status,ms:l.ms,rowCount:l.ok?1:0})),i(n=>({...n,dirty:new Set}))},{allEntities:K}=Me(),[w,C]=r.useState(d.lastSavedId),[B,z]=r.useState(d.lastSavedHash),y=r.useMemo(()=>Ne(a),[a]);Pe("manage-file",y,w,B);const he=r.useMemo(()=>H(y),[y]),Y=B===null?!0:he!==B,me=l=>{C(l.id),z(H(l.state))},X=l=>{if(l.modeId!=="manage-file")return;const n=l.state;if(K.length>0&&n.table&&!K.some(h=>h.logicalName===n.table)){oa(`Can't load "${l.name}": entity \`${n.table}\` isn't available in this environment.`);return}i(le(n)),C(l.id),z(H(n)),D(null),V(""),R("pipeline")},pe=l=>{const n=da(l,"manage-file");if(!n)return;const h=w,E=B;X(n),C(h),z(E)},Z=Q(me),J=Q(X);Re(r.useMemo(()=>a.table?{state:y,modeId:"manage-file",dirty:Y,lastSavedId:w,onSaved:Z,onLoadSaved:J}:null,[y,Y,w,a.table,Z,J]));const ge=r.useMemo(()=>Ae()?[De.warn("binary-host-unsupported","header","File operations run externally",e.jsxs("span",{children:["PPTB's ",e.jsx("code",{children:"dataverseAPI"})," doesn't expose file column endpoints. Build the request here, then copy a snippet from the ",e.jsx("strong",{children:"Code"})," tab (fetch / curl / C# / PowerShell) and run it from there. Execute will return ",e.jsx("code",{children:"501 Not Implemented"}),"."]}),"pipeline","https://learn.microsoft.com/en-us/power-apps/developer/data-platform/file-column-data")]:[],[]),S=a.operation==="upload"?"UPLOAD":a.operation==="download"?"DOWNLOAD":"DELETE",be=a.operation==="delete"?"danger":"brand",L=a.operation==="upload"?a.uploadMethod.kind:a.operation==="download"?a.downloadMethod.kind:"simple",fe=[{id:"operation",label:"Operation",meta:S.toLowerCase(),items:[{id:"operation",icon:Ie,iconFilled:oe,label:S.charAt(0)+S.slice(1).toLowerCase(),badge:S,badgeAppearance:"tint",badgeColor:be,dirty:a.dirty.has("operation")}]},{id:"target",label:"Target",meta:k?.displayName??"?",items:[{id:"target",icon:Le,iconFilled:Ue,label:a.recordId?`${k?.displayName??""} (selected)`:"Pick a record",badge:a.recordId?"✓":null,badgeAppearance:"ghost",dirty:a.dirty.has("target")},{id:"column",icon:ae,iconFilled:ee,label:a.fileColumn||"Pick a file column",code:!!a.fileColumn,badge:j?P((j.maxSizeInKB??32768)*1024):null,badgeAppearance:"ghost",dirty:a.dirty.has("column")}]},...a.operation!=="delete"?[{id:"method",label:"Method",meta:L,items:[{id:"method",icon:Ee,iconFilled:q,label:a.operation==="upload"?"Upload method":"Download method",badge:L,badgeAppearance:"ghost",dirty:a.dirty.has("method")}]}]:[],...a.operation==="upload"?[{id:"payload",label:"Payload",meta:a.fileName||"—",items:[{id:"source",icon:ae,iconFilled:ee,label:"Source",badge:a.source.kind,badgeAppearance:"ghost",dirty:a.dirty.has("source")}]}]:[],{id:"pipe",label:"Pipeline",meta:`${m.length} request${m.length===1?"":"s"}`,items:[{id:"pipeline",icon:qe,iconFilled:He,label:"Generated requests",badge:m.length||null,badgeAppearance:"tint",badgeColor:"brand",dirty:a.dirty.has("pipeline")}]},{id:"headers",label:"Headers",meta:`${a.headers.filter(l=>l.enabled).length} active`,items:[{id:"headers",icon:Ge,iconFilled:$e,label:"HTTP headers",badge:a.headers.filter(l=>l.enabled).length||null,dirty:a.dirty.has("headers")}]}];let p;switch(G){case"operation":p=e.jsx(ba,{value:a.operation,onChange:l=>c("operation",l,"operation")});break;case"target":p=e.jsx(_e,{table:a.table,onTableChange:l=>{i(n=>({...n,table:l,recordId:null,fileColumn:null,dirty:new Set(["target","column"])})),D(null),C(void 0),z(null)},recordId:a.recordId,onRecordChange:(l,n)=>{c("recordId",l,"target"),V(n??"")},group:"binary",sub:"Pick the entity + record that holds the file column."});break;case"column":p=e.jsx(ua,{table:a.table,value:a.fileColumn,onChange:l=>c("fileColumn",l,"column")});break;case"method":p=a.operation==="upload"?e.jsx(fa,{value:a.uploadMethod,onChange:l=>c("uploadMethod",l,"method")}):e.jsx(ya,{value:a.downloadMethod,onChange:l=>c("downloadMethod",l,"method")});break;case"source":p=e.jsx(ma,{source:a.source,setSource:l=>c("source",l,"source"),fileName:a.fileName,setFileName:l=>c("fileName",l,"source"),fileSize:a.fileSize,setFileSize:l=>c("fileSize",l,"source"),mimeType:a.mimeType,setMimeType:l=>c("mimeType",l,"source"),bodyBase64:a.bodyBase64,setBodyBase64:l=>c("bodyBase64",l,"source"),bodyUrl:a.bodyUrl,setBodyUrl:l=>c("bodyUrl",l,"source"),group:"binary"});break;case"pipeline":p=e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx(xa,{state:a,fileCol:j}),e.jsx(ha,{steps:m,title:`${S} pipeline — ${L}`,sub:m.length>1?"Each request fires sequentially.":void 0,sizeAdvisory:a.operation==="upload"?We(a.fileSize,j?.maxSizeInKB?j.maxSizeInKB*1024:void 0,"file"):null})]});break;case"headers":p=e.jsx(Oe,{items:a.headers,setItems:l=>c("headers",l,"headers"),group:"binary"});break}const ye=Ve(a.headers,null),xe={method:I,built:x,...Ke(m,ye),entityLogical:x.entityLogical};return e.jsx(Ye,{sidebar:e.jsx(la,{type:t,urlPreview:x.relativeNoBase,sections:fe,activeNode:G,onSelect:l=>{R(l),A("builder")},recents:ne,onRecentClick:pe}),urlBar:e.jsx(Je,{method:I,url:x.relativeUrl,executeVerb:a.operation==="upload"?"Upload":a.operation==="download"?"Download":"Delete",executeIcon:a.operation==="upload"?Qe:a.operation==="download"?ea:aa,disabledReason:de,loading:te,onExecute:ue,advisories:[..._,...ge],onAdvisoryFocus:R}),children:e.jsxs(Xe,{tab:F,onTabChange:A,resultCount:O?.ok?m.length:null,children:[F==="builder"&&p,F==="code"&&e.jsx(pa,{themeMode:o,inputs:xe}),F==="results"&&e.jsx(Ze,{result:O,mode:"single",table:a.table,writeContext:{operation:"manage-file",table:a.table,recordId:a.recordId,recordName:ce||null,fileOperation:a.operation,columnName:a.fileColumn??void 0,fileName:a.fileName||void 0}})]})})}function ba({value:o,onChange:t}){const d=sa(),a=[{id:"upload",label:"Upload",sub:"PATCH or message-based upload pipeline.",tone:"brand"},{id:"download",label:"Download",sub:"GET /$value, ranged GET, message pipeline, or SAS URL.",tone:"brand"},{id:"delete",label:"Delete",sub:"DELETE /<set>(<id>)/<col> · clears the column value.",tone:"danger"}];return e.jsxs("div",{children:[e.jsx($,{icon:oe,title:"Operation",sub:"What to do with the file column — drives the URL bar method + pipeline shape.",group:"binary"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12,maxWidth:960},children:a.map(i=>{const f=o===i.id;return e.jsxs("button",{type:"button",onClick:()=>t(i.id),className:na(d.inlineCard),style:{textAlign:"left",padding:14,cursor:"pointer",background:f?i.tone==="danger"?s.colorPaletteRedBackground2:s.colorBrandBackground2:s.colorNeutralBackground1,border:`1px solid ${f?i.tone==="danger"?s.colorPaletteRedBorderActive:s.colorBrandStroke1:s.colorNeutralStroke2}`,borderRadius:s.borderRadiusMedium},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("strong",{style:{fontSize:13},children:i.label}),f&&e.jsx(ta,{style:{marginLeft:"auto",color:i.tone==="danger"?s.colorPaletteRedForeground1:s.colorBrandForeground1},"aria-label":"Selected"})]}),e.jsx(u,{style:{color:s.colorNeutralForeground2,lineHeight:1.4,marginTop:6,display:"block"},children:i.sub})]},i.id)})})]})}function fa({value:o,onChange:t}){return e.jsxs("div",{children:[e.jsx($,{icon:q,title:"Upload method",sub:"Per file-column-data — three supported approaches.",group:"binary"}),e.jsxs("div",{style:{maxWidth:760,display:"flex",flexDirection:"column",gap:14},children:[e.jsx(g,{label:"Approach",children:e.jsxs(se,{value:o.kind,onChange:(d,a)=>{switch(a.value){case"single-request":t({kind:"single-request"});break;case"chunked-patch":t({kind:"chunked-patch",chunkSize:o.kind==="chunked-patch"?o.chunkSize:2*1024*1024});break;case"dataverse-messages":t({kind:"dataverse-messages",blockSize:o.kind==="dataverse-messages"?o.blockSize:4*1024*1024});break}},children:[e.jsx(b,{value:"single-request",label:e.jsxs("span",{children:[e.jsx("strong",{children:"Single-request PATCH"})," ",e.jsx("code",{style:{fontFamily:s.fontFamilyMonospace,fontSize:11},children:"PATCH /(set)(id)/col"}),e.jsx(u,{style:{display:"block",color:s.colorNeutralForeground3,marginTop:2},children:"Fastest for files up to ~128 MB. Body = raw bytes; x-ms-file-name header. No init/commit ceremony."})]})}),e.jsx(b,{value:"chunked-patch",label:e.jsxs("span",{children:[e.jsx("strong",{children:"Chunked PATCH"})," ",e.jsx("code",{style:{fontFamily:s.fontFamilyMonospace,fontSize:11},children:"x-ms-transfer-mode: chunked"}),e.jsx(u,{style:{display:"block",color:s.colorNeutralForeground3,marginTop:2},children:"Init PATCH returns Location + x-ms-chunk-size. Each chunk = PATCH with Content-Range. Server commits on final chunk."})]})}),e.jsx(b,{value:"dataverse-messages",label:e.jsxs("span",{children:[e.jsx("strong",{children:"Dataverse messages"})," ",e.jsx("code",{style:{fontFamily:s.fontFamilyMonospace,fontSize:11},children:"InitializeFileBlocksUpload / UploadBlock / CommitFileBlocksUpload"}),e.jsx(u,{style:{display:"block",color:s.colorNeutralForeground3,marginTop:2},children:"Three OData actions. Up to 10 GB. Returns FileId on commit. Use for files > 128 MB or when you need parallel block uploads."})]})})]})}),o.kind==="chunked-patch"&&e.jsxs(g,{label:"Chunk size (bytes)",hint:"Defaults to 2 MB. Server may suggest a different size via x-ms-chunk-size on init.",children:[e.jsx(v,{value:o.chunkSize,min:64*1024,max:64*1024*1024,step:1024*1024,onChange:(d,a)=>t({kind:"chunked-patch",chunkSize:Number(a.value??a.displayValue??o.chunkSize)})}),e.jsxs(u,{style:{marginTop:4,display:"block",color:s.colorNeutralForeground3},children:["≈ ",P(o.chunkSize)," per chunk."]})]}),o.kind==="dataverse-messages"&&e.jsxs(g,{label:"Block size (bytes)",hint:"Default = 4 MB. The docs cap each UploadBlock at 4 MB; smaller is fine.",children:[e.jsx(v,{value:o.blockSize,min:64*1024,max:4*1024*1024,step:1024*1024,onChange:(d,a)=>t({kind:"dataverse-messages",blockSize:Number(a.value??a.displayValue??o.blockSize)})}),e.jsxs(u,{style:{marginTop:4,display:"block",color:s.colorNeutralForeground3},children:["≈ ",P(o.blockSize)," per block."]})]})]})]})}function ya({value:o,onChange:t}){return e.jsxs("div",{children:[e.jsx($,{icon:q,title:"Download method",sub:"Per file-column-data + getfilesasurl — four supported approaches.",group:"binary"}),e.jsxs("div",{style:{maxWidth:760,display:"flex",flexDirection:"column",gap:14},children:[e.jsx(g,{label:"Approach",children:e.jsxs(se,{value:o.kind,onChange:(d,a)=>{switch(a.value){case"single-request":t({kind:"single-request"});break;case"ranged":t({kind:"ranged",rangeStart:0,rangeEnd:4*1024*1024-1});break;case"dataverse-messages":t({kind:"dataverse-messages",blockSize:4*1024*1024});break;case"sas-url":t({kind:"sas-url"});break}},children:[e.jsx(b,{value:"single-request",label:e.jsxs("span",{children:[e.jsx("strong",{children:"GET /$value"}),e.jsx(u,{style:{display:"block",color:s.colorNeutralForeground3,marginTop:2},children:"Stream the entire file in one request. Returns raw bytes. Easy but not great for huge files."})]})}),e.jsx(b,{value:"ranged",label:e.jsxs("span",{children:[e.jsx("strong",{children:"Ranged GET"})," ",e.jsx("code",{style:{fontFamily:s.fontFamilyMonospace,fontSize:11},children:"Range: bytes=A-B"}),e.jsx(u,{style:{display:"block",color:s.colorNeutralForeground3,marginTop:2},children:"Partial content — server returns 206. Use for resume / parallel download."})]})}),e.jsx(b,{value:"dataverse-messages",label:e.jsxs("span",{children:[e.jsx("strong",{children:"Dataverse messages"})," ",e.jsx("code",{style:{fontFamily:s.fontFamilyMonospace,fontSize:11},children:"InitializeFileBlocksDownload + DownloadBlock"}),e.jsx(u,{style:{display:"block",color:s.colorNeutralForeground3,marginTop:2},children:"Block-by-block download. Returns FileName + FileSizeInBytes + FileContinuationToken from init."})]})}),e.jsx(b,{value:"sas-url",label:e.jsxs("span",{children:[e.jsx("strong",{children:"GetFileSasUrl"})," ",e.jsx("code",{style:{fontFamily:s.fontFamilyMonospace,fontSize:11},children:"GET /GetFileSasUrl(…)"}),e.jsx(u,{style:{display:"block",color:s.colorNeutralForeground3,marginTop:2},children:"Returns a 1-hour SAS URL that anyone can use to download directly from Azure Storage. Skips Web API roundtrip on the actual download."})]})})]})}),o.kind==="ranged"&&e.jsxs("div",{style:{display:"flex",gap:10,maxWidth:480},children:[e.jsx(g,{label:"Range start (bytes)",children:e.jsx(v,{value:o.rangeStart,min:0,onChange:(d,a)=>t({kind:"ranged",rangeStart:Number(a.value??a.displayValue??0),rangeEnd:o.rangeEnd})})}),e.jsx(g,{label:"Range end (bytes)",children:e.jsx(v,{value:o.rangeEnd,min:0,onChange:(d,a)=>t({kind:"ranged",rangeStart:o.rangeStart,rangeEnd:Number(a.value??a.displayValue??0)})})})]}),o.kind==="dataverse-messages"&&e.jsx(g,{label:"Block size (bytes)",children:e.jsx(v,{value:o.blockSize,min:64*1024,max:4*1024*1024,step:1024*1024,onChange:(d,a)=>t({kind:"dataverse-messages",blockSize:Number(a.value??a.displayValue??o.blockSize)})})}),o.kind==="sas-url"&&e.jsx(T,{layout:"multiline",intent:"info",children:e.jsxs(M,{children:[e.jsx(N,{children:"SAS URL caveats"}),e.jsxs("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.6},children:[e.jsx("li",{children:"Only works for image columns that support full-size images."}),e.jsx("li",{children:"SAS URL valid for 1 hour from generation."}),e.jsx("li",{children:"Does NOT work for environments using BYOK encryption — migrate to CMK first."}),e.jsx("li",{children:"Caller must have access to the record; the resulting URL grants anonymous access for 1 hour."})]})]})})]})]})}function xa({state:o,fileCol:t}){const d=(t?.maxSizeInKB??32768)*1024;if(o.operation==="upload"){const a=o.fileSize>4194304,i=o.fileSize>128*1024*1024;return e.jsx(T,{layout:"multiline",intent:i?"warning":"info",children:e.jsxs(M,{children:[e.jsx(N,{children:"Upload"}),i?e.jsxs(e.Fragment,{children:["File is over ",e.jsx("strong",{children:"128 MB"})," — single-request PATCH won't work. Use the Dataverse messages path which supports up to 10 GB."]}):a?e.jsxs(e.Fragment,{children:["File is over ",e.jsx("strong",{children:"4 MB"})," — chunked PATCH (or Dataverse messages) is recommended; single-request still works up to 128 MB."]}):e.jsxs(e.Fragment,{children:["Small enough for single-request PATCH. Column max: ",P(d),"."]})]})})}return o.operation==="download"?e.jsx(T,{layout:"multiline",intent:"info",children:e.jsxs(M,{children:[e.jsx(N,{children:"Download"}),"Retrieving a file column returns the ",e.jsx("strong",{children:"file id"})," (not bytes) — use the operations below to fetch actual content. GET /$value is the simplest; SAS URL skips the Web API roundtrip when an anonymous browser-side download is fine."]})}):e.jsx(T,{layout:"multiline",intent:"warning",children:e.jsxs(M,{children:[e.jsx(N,{children:"Delete"}),"Clears the file column value + the ",e.jsx("code",{children:"_name"})," companion. The underlying file is removed by Dataverse. Alternative equivalent paths: PATCH the column to null, or call the"," ",e.jsx("code",{children:"DeleteFile"})," action with the column's current FileId."]})})}export{Ca as ManageFileMode};
@@ -0,0 +1 @@
1
+ import{f as ze,bh as Ce,r as s,R as Be,U as ke,cA as Pe,cB as Re,z as Me,bj as Ue,W as Ae,X as Le,u as Ee,cC as De,bl as $e,Y as _,Z as oe,_ as He,aG as Oe,cm as We,j as e,cD as _e,bD as qe,cn as se,co as Ge,$ as Ke,a0 as Ve,cE as K,cF as I,a$ as de,b0 as Xe,c0 as Ye,cr as Ze,a7 as Je,a8 as Qe,a9 as ea,ct as le,ab as aa,ad as oa,cu as la,ae as ia,af as na,ag as ra,ah as ta,cv as sa,cw as da,cx as ca,ai as ua,cG as ie,b8 as ma,M as P,m as R,o as q,bg as ce,t as n,B as G,C as N,bv as ue,ay as me,au as ga,az as pa,aA as ne,b9 as ha,ax as ba,bx as ya,aj as fa}from"./index-NW0Z4UWR.js";import{I as xa}from"./BinaryColumnPickers-NAaoPcPt.js";import{B as re,a as ge}from"./BinaryPipelineCard-CSklRaME.js";import{C as Sa}from"./CodeView-C65Y5vXN.js";import"./multipart-Bd_eOd8a.js";function ja(l){const i=l.normalize("NFC").split(/\s+/).map(r=>/[\p{L}\p{N}]\p{M}*/u.exec(r)?.[0]).filter(r=>!!r).map(r=>r.toUpperCase().length===r.length?r.toUpperCase():r);return i.length===0?"?":i.length===1?i[0]:i[0]+i[i.length-1]}const va=5*1024*1024;function te(l){if(!l)return 0;const i=l.endsWith("==")?2:l.endsWith("=")?1:0;return Math.max(0,Math.floor(l.length*3/4)-i)}const wa=()=>({table:"",recordId:null,imageColumn:"",operation:"upload",downloadSize:"thumbnail",source:{kind:"file"},fileName:"",fileSize:0,bodyBase64:"",bodyUrl:"",mimeType:"image/png",headers:fa(),dirty:new Set});function Ma({themeMode:l}){const i=ze("manage-image"),r=Ce("manage-image",ie,wa),[a,d]=s.useState(r.state),[h,M]=s.useState(null),m=s.useRef(null),j=s.useCallback(o=>{m.current&&URL.revokeObjectURL(m.current),m.current=o&&o.type.startsWith("image/")&&o.size<=va?URL.createObjectURL(o):null,M(m.current&&o?{url:m.current,name:o.name}:null)},[]),U=h&&h.name===a.fileName?h.url:null;s.useEffect(()=>()=>{m.current&&URL.revokeObjectURL(m.current)},[]);const{table:T}=Be(a.table||null),[b,v]=s.useState("preview"),[f,A]=s.useState("builder"),[V,L]=s.useState(null),[pe,X]=s.useState(!1),[he,be]=ke("manage-image"),w=s.useMemo(()=>Pe(a),[a,T]),y=s.useMemo(()=>Re(a),[a,T]),F=Me(a.table),u=s.useMemo(()=>(F?.columns??[]).find(o=>o.attributeType==="Image"&&o.logicalName===a.imageColumn),[F,a.imageColumn]),ye=o=>d(t=>{const p=new Set(t.dirty);return p.add(o),{...t,dirty:p}}),c=(o,t,p)=>{d(W=>({...W,[o]:t})),p&&ye(p)},E=y[0]?.method??"PATCH",D=Ue([["Record id",a.recordId]],[["Image column",a.imageColumn]]),Y=Ae([{when:!F,id:"image-table",title:"Pick a target table first.",focusNode:"target"},{when:!a.recordId,id:"image-record",title:"Pick a source record.",focusNode:"target"},{when:!a.imageColumn,id:"image-column",title:"Pick an image column.",focusNode:"column"},{when:a.operation==="upload"&&a.source.kind==="file"&&!a.fileName,id:"image-upload-source",title:"Pick an image file.",focusNode:"source"},{when:a.operation==="download"&&a.downloadSize==="full"&&!u?.canStoreFullImage,id:"image-full-size",title:`${a.imageColumn} doesn't store full-size images (canStoreFullImage = false).`,focusNode:"options"},{when:a.headers.some(o=>o.enabled&&!o.name),id:"image-header-name",title:"Fix empty header name.",focusNode:"headers"},{when:D,id:"image-url-part",title:D??"",focusNode:D?.startsWith("Image column")?"column":"target"}]),fe=Le(Y),[$,H]=s.useState(""),xe=async()=>{X(!0);const o=await ha.manageImage(a);L(o),X(!1),A("results"),be(ba({snapshot:x,modeId:"manage-image",url:w.relativeUrl,method:E,status:o.status,ms:o.ms,rowCount:o.ok?1:0})),d(t=>({...t,dirty:new Set}))},{allEntities:Z}=Ee(),[z,C]=s.useState(r.lastSavedId),[B,k]=s.useState(r.lastSavedHash),x=s.useMemo(()=>De(a),[a]);$e("manage-image",x,z,B);const Se=s.useMemo(()=>_(x),[x]),J=B===null?!0:Se!==B,je=o=>{C(o.id),k(_(o.state))},Q=o=>{if(o.modeId!=="manage-image")return;const t=o.state;if(Z.length>0&&t.table&&!Z.some(p=>p.logicalName===t.table)){ma(`Can't load "${o.name}": entity \`${t.table}\` isn't available in this environment.`);return}d(ie(t)),j(null),C(o.id),k(_(t)),L(null),H(""),v("preview")},ve=o=>{const t=ya(o,"manage-image");if(!t)return;const p=z,W=B;Q(t),C(p),k(W)},ee=oe(je),ae=oe(Q);He(s.useMemo(()=>a.table?{state:x,modeId:"manage-image",dirty:J,lastSavedId:z,onSaved:ee,onLoadSaved:ae}:null,[x,J,z,a.table,ee,ae]));const we=s.useMemo(()=>Oe()?[We.warn("binary-host-unsupported","header","Image operations run externally",e.jsxs("span",{children:["PPTB's ",e.jsx("code",{children:"dataverseAPI"})," doesn't expose image column endpoints. Build the request here, then copy a snippet from the ",e.jsx("strong",{children:"Code"})," tab (fetch / curl / C# / PowerShell) and run it from there. Execute will return ",e.jsx("code",{children:"501 Not Implemented"}),"."]}),"preview","https://learn.microsoft.com/en-us/power-apps/developer/data-platform/image-column-data")]:[],[]),S=a.operation==="upload"?"UPLOAD":a.operation==="download"?"DOWNLOAD":"DELETE",Fe=a.operation==="delete"?"danger":"brand",O=ja($),Ie=[{id:"preview",label:"Preview",items:[{id:"preview",icon:qe,iconFilled:_e,label:$.trim()||"Image preview",badge:O==="?"?null:O,badgeAppearance:"ghost"}]},{id:"operation",label:"Operation",meta:S.toLowerCase(),items:[{id:"operation",icon:Ge,iconFilled:se,label:S.charAt(0)+S.slice(1).toLowerCase(),badge:S,badgeAppearance:"tint",badgeColor:Fe,dirty:a.dirty.has("operation")}]},{id:"target",label:"Target",meta:F?.displayName??"?",items:[{id:"target",icon:Ve,iconFilled:Ke,label:a.recordId?`${F?.displayName??""} (selected)`:"Pick a record",badge:a.recordId?"✓":null,badgeAppearance:"ghost",dirty:a.dirty.has("target")},{id:"column",icon:I,iconFilled:K,label:a.imageColumn||"Pick an image column",code:!!a.imageColumn,badge:u?.isPrimaryImage?"primary":u?.canStoreFullImage?"full":"thumb",badgeAppearance:"tint",badgeColor:u?.canStoreFullImage?"success":"brand",dirty:a.dirty.has("column")}]},...u?[{id:"deriv",label:"Derivatives",meta:"3 companion columns",items:[{id:"d1",icon:I,label:`${u.logicalName}id`,code:!0,badge:"guid",badgeAppearance:"ghost"},{id:"d2",icon:I,label:`${u.logicalName}_Timestamp`,code:!0,badge:"bigint",badgeAppearance:"ghost"},{id:"d3",icon:I,label:`${u.logicalName}_URL`,code:!0,badge:"url",badgeAppearance:"ghost"}]}]:[],...a.operation==="upload"?[{id:"payload",label:"Payload",meta:a.fileName||"—",items:[{id:"source",icon:I,iconFilled:K,label:"Source",badge:a.source.kind,badgeAppearance:"ghost",dirty:a.dirty.has("source")}]}]:[],...a.operation==="download"?[{id:"options",label:"Options",meta:a.downloadSize,items:[{id:"options",icon:Xe,iconFilled:de,label:"Download size",badge:a.downloadSize,badgeAppearance:"tint",badgeColor:"brand",dirty:a.dirty.has("options")}]}]:[],{id:"pipe",label:"Pipeline",meta:`${y.length} request${y.length===1?"":"s"}`,items:[{id:"pipeline",icon:Ze,iconFilled:Ye,label:"Generated requests",badge:y.length||null,badgeAppearance:"tint",badgeColor:"brand",dirty:a.dirty.has("pipeline")}]},{id:"headers",label:"Headers",meta:`${a.headers.filter(o=>o.enabled).length} active`,items:[{id:"headers",icon:Qe,iconFilled:Je,label:"HTTP headers",badge:a.headers.filter(o=>o.enabled).length||null,dirty:a.dirty.has("headers")}]}];let g;switch(b){case"operation":g=e.jsx(Ia,{value:a.operation,onChange:o=>c("operation",o,"operation")});break;case"target":g=e.jsx(aa,{table:a.table,onTableChange:o=>{d(t=>({...t,table:o,recordId:null,imageColumn:null,dirty:new Set(["target","column"])})),H(""),L(null),C(void 0),k(null)},recordId:a.recordId,onRecordChange:(o,t)=>{c("recordId",o,"target"),H(t??"")},group:"binary",sub:"Pick the entity + record that holds the image column."});break;case"column":g=e.jsx(xa,{table:a.table,value:a.imageColumn,onChange:o=>c("imageColumn",o,"column")});break;case"source":g=e.jsx(ge,{source:a.source,setSource:o=>c("source",o,"source"),fileName:a.fileName,setFileName:o=>c("fileName",o,"source"),fileSize:a.fileSize??0,setFileSize:o=>c("fileSize",o,"source"),mimeType:a.mimeType,setMimeType:o=>c("mimeType",o,"source"),bodyBase64:a.bodyBase64,setBodyBase64:o=>c("bodyBase64",o,"source"),bodyUrl:a.bodyUrl,setBodyUrl:o=>c("bodyUrl",o,"source"),accept:"image/png,image/jpeg,image/gif,image/bmp,image/tiff",group:"binary",onFile:j});break;case"options":g=e.jsx(Na,{downloadSize:a.downloadSize,setDownloadSize:o=>c("downloadSize",o,"options"),canStoreFullImage:u?.canStoreFullImage??!1});break;case"preview":g=e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsx(Ta,{state:a,imageCol:u}),e.jsx(Fa,{state:a,imageCol:u,initials:O,setSource:o=>c("source",o,"source"),setBodyBase64:o=>c("bodyBase64",o,"source"),setFileName:o=>c("fileName",o,"source"),setFileSize:o=>c("fileSize",o,"source"),setMimeType:o=>c("mimeType",o,"source"),previewUrl:U,onFile:j}),e.jsx(re,{steps:y,title:`${S} pipeline`,sizeAdvisory:a.operation==="upload"?le(a.fileSize||te(a.bodyBase64),u?.maxSizeInKB?u.maxSizeInKB*1024:void 0,"image"):null})]});break;case"pipeline":g=e.jsx(re,{steps:y,title:`${S} pipeline`,sizeAdvisory:a.operation==="upload"?le(a.fileSize||te(a.bodyBase64),u?.maxSizeInKB?u.maxSizeInKB*1024:void 0,"image"):null});break;case"headers":g=e.jsx(ea,{items:a.headers,setItems:o=>c("headers",o,"headers"),group:"binary"});break}const Ne=oa(a.headers,null),Te={method:E,built:w,...la(y,Ne),entityLogical:w.entityLogical};return e.jsx(ia,{sidebar:e.jsx(ua,{type:i,urlPreview:w.relativeNoBase,sections:Ie,activeNode:b,onSelect:o=>{v(o),A("builder")},recents:he,onRecentClick:ve}),urlBar:e.jsx(ta,{method:E,url:w.relativeUrl,executeVerb:a.operation==="upload"?"Upload":a.operation==="download"?"Download":"Delete",executeIcon:a.operation==="upload"?sa:a.operation==="download"?da:ca,disabledReason:fe,loading:pe,onExecute:xe,advisories:[...Y,...we],onAdvisoryFocus:v}),children:e.jsxs(na,{tab:f,onTabChange:A,resultCount:V?.ok?1:null,children:[f==="builder"&&g,f==="code"&&e.jsx(Sa,{themeMode:l,inputs:Te}),f==="results"&&e.jsx(ra,{result:V,mode:"single",table:a.table,writeContext:{operation:"manage-image",table:a.table,recordId:a.recordId,recordName:$||null,fileOperation:a.operation,columnName:a.imageColumn??void 0,fileName:a.fileName||void 0}})]})})}function Fa({state:l,imageCol:i,initials:r,setSource:a,setBodyBase64:d,setFileName:h,setFileSize:M,setMimeType:m,previewUrl:j,onFile:U}){const T=ce(),b=l.source.kind==="file"?j:l.source.kind==="base64"&&l.bodyBase64?`data:${l.mimeType};base64,${l.bodyBase64}`:null,v=i?.isPrimaryImage&&!i?.canStoreFullImage;return e.jsxs("div",{className:ue(T.inlineCard),style:{padding:14,maxWidth:880},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx(K,{style:{color:n.colorBrandForeground1}}),e.jsx("strong",{style:{fontSize:13},children:"Preview · Source"}),e.jsx(G,{appearance:"tint",color:"brand",children:i?.isPrimaryImage?"primary image":"custom image column"}),v&&e.jsx(G,{appearance:"ghost",children:"144×144 only"}),i?.canStoreFullImage&&e.jsx(G,{appearance:"tint",color:"success",children:"full-size enabled"})]}),e.jsxs("div",{style:{display:"flex",gap:20,alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsxs(N,{style:{color:n.colorNeutralForeground3,display:"block",marginBottom:4},children:[l.operation==="upload"?"Preview":l.downloadSize==="full"?"Full-size":"Thumbnail"," ","· 144×144"]}),e.jsx("div",{style:{width:144,height:144,background:b?`url("${b}") center/cover`:n.colorNeutralBackground3,borderRadius:n.borderRadiusMedium,display:"flex",alignItems:"center",justifyContent:"center",color:b?"#fff":n.colorNeutralForeground3,fontWeight:700,fontSize:40,border:`1px solid ${n.colorNeutralStroke2}`},children:!b&&r}),(b||l.source.kind==="file"&&l.fileName)&&e.jsxs(N,{style:{color:n.colorNeutralForeground3,display:"block",marginTop:4},children:[l.fileName," · ",l.mimeType]})]}),l.operation==="upload"&&e.jsx("div",{style:{flex:1},children:e.jsx(ge,{source:l.source,setSource:a,fileName:l.fileName,setFileName:h,fileSize:l.fileSize??0,setFileSize:M,mimeType:l.mimeType,setMimeType:f=>m(f),bodyBase64:l.bodyBase64,setBodyBase64:d,bodyUrl:l.bodyUrl,setBodyUrl:()=>{},accept:"image/png,image/jpeg,image/gif,image/bmp,image/tiff",group:"binary",onFile:U})}),l.operation!=="upload"&&e.jsxs("div",{style:{flex:1,fontSize:11,color:n.colorNeutralForeground3,lineHeight:1.6},children:[l.operation==="download"&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{style:{color:n.colorNeutralForeground2},children:"Download:"})," server returns the"," ",l.downloadSize==="full"?"original full-size":"auto-cropped 144×144 thumbnail"," ","as raw bytes. The Content-Type matches the stored image's MIME type (one of image/png · image/jpeg · image/gif · image/bmp · image/tiff)."]}),l.operation==="delete"&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{style:{color:n.colorNeutralForeground2},children:"Delete:"})," clears the image data + companion columns (",e.jsxs("code",{style:{fontFamily:n.fontFamilyMonospace},children:[i?.logicalName,"id"]}),", ",e.jsx("code",{style:{fontFamily:n.fontFamilyMonospace},children:"_Timestamp"}),","," ",e.jsx("code",{style:{fontFamily:n.fontFamilyMonospace},children:"_URL"}),"). Equivalent forms: PATCH set null, PUT /col with body ",e.jsx("code",{children:'{"value":null}'}),", or DELETE /col (shown)."]})]})]})]})}function Ia({value:l,onChange:i}){const r=ce(),a=[{id:"upload",label:"Upload",sub:"PATCH /<set>(<id>) with body {col: <base64>}.",tone:"brand"},{id:"download",label:"Download",sub:"GET /<set>(<id>)/<col>/$value (?size=full for full).",tone:"brand"},{id:"delete",label:"Delete",sub:"DELETE / PATCH null / PUT /col body=null — three equivalents.",tone:"danger"}];return e.jsxs("div",{children:[e.jsx(me,{icon:se,title:"Operation",group:"binary"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12,maxWidth:960},children:a.map(d=>{const h=l===d.id;return e.jsxs("button",{type:"button",onClick:()=>i(d.id),className:ue(r.inlineCard),style:{textAlign:"left",padding:14,cursor:"pointer",background:h?d.tone==="danger"?n.colorPaletteRedBackground2:n.colorBrandBackground2:n.colorNeutralBackground1,border:`1px solid ${h?d.tone==="danger"?n.colorPaletteRedBorderActive:n.colorBrandStroke1:n.colorNeutralStroke2}`,borderRadius:n.borderRadiusMedium},children:[e.jsx("strong",{style:{fontSize:13,display:"block"},children:d.label}),e.jsx(N,{style:{color:n.colorNeutralForeground2,lineHeight:1.4,marginTop:6,display:"block"},children:d.sub})]},d.id)})})]})}function Na({downloadSize:l,setDownloadSize:i,canStoreFullImage:r}){return e.jsxs("div",{children:[e.jsx(me,{icon:de,title:"Download options",sub:"Image columns can store both thumbnail + full-size when CanStoreFullImage is true.",group:"binary"}),e.jsx("div",{style:{maxWidth:720},children:e.jsx(ga,{label:"Size",children:e.jsxs(pa,{value:l,onChange:(a,d)=>i(d.value),children:[e.jsx(ne,{value:"thumbnail",label:e.jsxs("span",{children:[e.jsx("strong",{children:"Thumbnail (144×144)"}),e.jsx(N,{style:{display:"block",color:n.colorNeutralForeground3,marginTop:2},children:"Default for all image columns. Center-cropped square."})]})}),e.jsx(ne,{value:"full",disabled:!r,label:e.jsxs("span",{children:[e.jsx("strong",{children:"Full-size"})," ",e.jsx("code",{style:{fontFamily:n.fontFamilyMonospace,fontSize:11},children:"?size=full"}),e.jsxs(N,{style:{display:"block",color:n.colorNeutralForeground3,marginTop:2},children:["Only available when the column has CanStoreFullImage = true. Server returns 204 if not configured.",!r&&e.jsxs(e.Fragment,{children:[" ","·"," ",e.jsx("span",{style:{color:n.colorPaletteRedForeground1},children:"this column doesn't support full-size"})]})]})]})})]})})})]})}function Ta({state:l,imageCol:i}){return i?l.operation==="upload"?e.jsx(P,{layout:"multiline",intent:"info",children:e.jsxs(R,{children:[e.jsx(q,{children:i.isPrimaryImage?"Primary image — thumbnail only":"Custom image column"}),i.isPrimaryImage?e.jsxs(e.Fragment,{children:[e.jsx("code",{children:i.logicalName})," is the table's primary image (auto-cropped 144×144). Full-size data is discarded. To store full-resolution images, create a custom image column with ",e.jsx("code",{children:"CanStoreFullImage = true"}),"."]}):i.canStoreFullImage?e.jsxs(e.Fragment,{children:[e.jsx("code",{children:i.logicalName})," supports full-size (max"," ",((i.maxSizeInKB??10240)/1024).toFixed(0)," MB). Upload via PATCH; for files > 4 MB use the file-column chunked upload path on the underlying file storage."]}):e.jsxs(e.Fragment,{children:[e.jsx("code",{children:i.logicalName})," stores thumbnail only (CanStoreFullImage = false). Full-size won't be retained."]})]})}):l.operation==="download"?e.jsx(P,{layout:"multiline",intent:"info",children:e.jsxs(R,{children:[e.jsx(q,{children:"Download"}),"GET /$value returns the"," ",l.downloadSize==="full"?"full-size original":"144×144 thumbnail",". Image companion columns (",e.jsxs("code",{children:[i.logicalName,"_URL"]})," etc.) let you compose a download URL for browser-side use."]})}):e.jsx(P,{layout:"multiline",intent:"warning",children:e.jsxs(R,{children:[e.jsx(q,{children:"Delete"}),"Clears ",e.jsx("code",{children:i.logicalName})," + its companion columns (id / _Timestamp / _URL). Three equivalent paths per docs: DELETE /col (shown), PATCH set null, or PUT /col with body"," ",e.jsx("code",{children:'{"value":null}'}),"."]})}):e.jsx(P,{layout:"multiline",intent:"info",children:e.jsx(R,{children:"Pick an image column on the left to see operation-specific guidance."})})}export{Ma as ManageImageMode};