apitestcenter 0.16.0 → 0.17.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.
- package/dist/THIRD-PARTY-NOTICES-UI.txt +1 -1
- package/dist/THIRD-PARTY-NOTICES.txt +1 -1
- package/dist/cli.mjs +398 -383
- package/dist/ui/404/index.html +1 -1
- package/dist/ui/404.html +1 -1
- package/dist/ui/__next.__PAGE__.txt +11 -11
- package/dist/ui/__next._full.txt +12 -12
- package/dist/ui/__next._tree.txt +2 -2
- package/dist/ui/_next/static/chunks/036rg3itpc5ge.js +50 -0
- package/dist/ui/_next/static/chunks/0e8f1i6w6dqos.js +50 -0
- package/dist/ui/_next/static/chunks/0hvubzjy33qo9.js +2 -0
- package/dist/ui/_next/static/chunks/0wrod6xlhsv0m.js +3 -0
- package/dist/ui/_next/static/chunks/{2-fk7_1yukwm4.js → 1519k06vxy4mr.js} +1 -1
- package/dist/ui/_next/static/chunks/{3oetlmylrxpce.js → 23_x0u07xh89v.js} +5 -5
- package/dist/ui/_next/static/chunks/29z9g1tvzqfn4.css +3 -0
- package/dist/ui/_next/static/chunks/2aifruy-vhchn.js +50 -0
- package/dist/ui/_next/static/chunks/{3o926vjke_xbm.js → 2b31vf5n6d6th.js} +199 -88
- package/dist/ui/_next/static/chunks/2wj5vjpg6np93.js +27 -0
- package/dist/ui/_next/static/chunks/33kvaxr7qvnue.js +50 -0
- package/dist/ui/_next/static/chunks/36wzwezwmtzq7.js +51 -0
- package/dist/ui/_next/static/chunks/3b26__7yusttj.js +1 -0
- package/dist/ui/_next/static/chunks/3n2xlaj16gyb-.js +2 -0
- package/dist/ui/_next/static/chunks/3vso5wrs90xx-.js +50 -0
- package/dist/ui/_not-found/__next._full.txt +11 -11
- package/dist/ui/_not-found/__next._not-found.__PAGE__.txt +10 -10
- package/dist/ui/_not-found/__next._tree.txt +2 -2
- package/dist/ui/_not-found/index.html +1 -1
- package/dist/ui/_not-found/index.txt +11 -11
- package/dist/ui/compare/__next._full.txt +12 -12
- package/dist/ui/compare/__next._tree.txt +2 -2
- package/dist/ui/compare/__next.compare.__PAGE__.txt +11 -11
- package/dist/ui/compare/index.html +1 -1
- package/dist/ui/compare/index.txt +12 -12
- package/dist/ui/connections/__next._full.txt +12 -12
- package/dist/ui/connections/__next._tree.txt +2 -2
- package/dist/ui/connections/__next.connections.__PAGE__.txt +11 -11
- package/dist/ui/connections/index.html +2 -2
- package/dist/ui/connections/index.txt +12 -12
- package/dist/ui/history/__next._full.txt +13 -13
- package/dist/ui/history/__next._tree.txt +2 -2
- package/dist/ui/history/__next.history.__PAGE__.txt +12 -12
- package/dist/ui/history/index.html +1 -1
- package/dist/ui/history/index.txt +13 -13
- package/dist/ui/home/__next._full.txt +12 -12
- package/dist/ui/home/__next._tree.txt +2 -2
- package/dist/ui/home/__next.home.__PAGE__.txt +11 -11
- package/dist/ui/home/index.html +1 -1
- package/dist/ui/home/index.txt +12 -12
- package/dist/ui/index.html +1 -1
- package/dist/ui/index.txt +12 -12
- package/dist/ui/preview/__next._full.txt +13 -13
- package/dist/ui/preview/__next._tree.txt +2 -2
- package/dist/ui/preview/__next.preview.__PAGE__.txt +12 -12
- package/dist/ui/preview/index.html +1 -1
- package/dist/ui/preview/index.txt +13 -13
- package/dist/ui/suite/__next._full.txt +12 -12
- package/dist/ui/suite/__next._tree.txt +2 -2
- package/dist/ui/suite/__next.suite.__PAGE__.txt +11 -11
- package/dist/ui/suite/index.html +1 -1
- package/dist/ui/suite/index.txt +12 -12
- package/dist/ui/tests/__next._full.txt +11 -11
- package/dist/ui/tests/__next._tree.txt +2 -2
- package/dist/ui/tests/__next.tests.__PAGE__.txt +10 -10
- package/dist/ui/tests/index.html +1 -1
- package/dist/ui/tests/index.txt +11 -11
- package/package.json +1 -1
- package/dist/ui/_next/static/chunks/0z965ndwtjbm_.js +0 -51
- package/dist/ui/_next/static/chunks/11ttwsn_q1n9e.js +0 -50
- package/dist/ui/_next/static/chunks/1dblkl6d18f29.js +0 -50
- package/dist/ui/_next/static/chunks/1g6q7zaut7pts.js +0 -50
- package/dist/ui/_next/static/chunks/1mj3_49yxxkvu.js +0 -3
- package/dist/ui/_next/static/chunks/22z3xj74zl8o3.js +0 -1
- package/dist/ui/_next/static/chunks/24xh2ng9tdid9.js +0 -50
- package/dist/ui/_next/static/chunks/2844deqm9c797.js +0 -50
- package/dist/ui/_next/static/chunks/2p2xxbfeii3so.css +0 -3
- package/dist/ui/_next/static/chunks/37fbrlydrkdac.js +0 -10
- package/dist/ui/_next/static/chunks/3ddcv0i2wy657.js +0 -2
- package/dist/ui/_next/static/chunks/41xixugzzb47w.js +0 -27
- /package/dist/ui/_next/static/{emu38N9csb28KU3jv4SH4 → DG7f21AItcQXQY2TGN7rY}/_buildManifest.js +0 -0
- /package/dist/ui/_next/static/{emu38N9csb28KU3jv4SH4 → DG7f21AItcQXQY2TGN7rY}/_clientMiddlewareManifest.js +0 -0
- /package/dist/ui/_next/static/{emu38N9csb28KU3jv4SH4 → DG7f21AItcQXQY2TGN7rY}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,87946,e=>{"use strict";var t=e.i(14368),s=e.i(32610),n=e.i(62766);e.i(24856);var a=e.i(84201);let l="services/rest/query/v1/suiteql",i=e=>e.trim().toUpperCase().replace(/-/g,"_");function r(e){let t=`${e}_name`;if(t.length<=30)return t;let s=0;for(let t of e)s=31*s+t.charCodeAt(0)>>>0;return`${e.slice(0,20)}_${(s%65535).toString(16).padStart(4,"0")}_name`}function o(e,t){let s=e.trim(),n=t?.type.split(":")[1]??"string";return/^null$/i.test(s)?"NULL":"boolean"===n?/^(true|t|yes|1)$/i.test(s)?"'T'":"'F'":("integer"===n||"number"===n||"reference"===n)&&/^-?\d+(\.\d+)?$/.test(s)?s:("date"===n||"datetime"===n)&&/^\d{4}-\d\d-\d\d$/.test(s)?`TO_DATE('${s}', 'YYYY-MM-DD')`:`'${e.replace(/'/g,"''")}'`}let c={eq:"=",ne:"<>",gt:">",ge:">=",lt:"<",le:"<="};function d(e,t){return e.filter(e=>e.field).map(e=>{let s=t.find(t=>t.name===e.field),n=!!(e.byName&&s?.ref),a=n?`BUILTIN.DF(${e.field})`:e.field;return"contains"===e.op?`${a} LIKE '%${e.value.replace(/'/g,"''")}%'`:"startswith"===e.op?`${a} LIKE '${e.value.replace(/'/g,"''")}%'`:"endswith"===e.op?`${a} LIKE '%${e.value.replace(/'/g,"''")}'`:/^null$/i.test(e.value.trim())&&("eq"===e.op||"ne"===e.op)?`${a} IS ${"ne"===e.op?"NOT ":""}NULL`:`${a} ${c[e.op]??"="} ${n?o(e.value):o(e.value,s)}`}).join(" AND ")}function u(e,t={}){let s=Math.min(t.top??1e3,1e3);return`${l}?limit=${s}&offset=${t.skip??0}&q=${encodeURIComponent(e)}`}function m(e){let t=e??{},s=Array.isArray(t.items)?t.items.map(e=>Object.fromEntries(Object.entries(e).filter(([e])=>"links"!==e))):[],n=Number(t.totalResults);return{rows:s,...Number.isFinite(n)&&void 0!==t.totalResults?{count:n}:{}}}var p=e.i(99522);let x=(0,p.default)("building-2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);var h=e.i(60961);let f=(0,p.default)("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);var b=e.i(80190),g=e.i(84355),y=e.i(27813),j=e.i(81538),v=e.i(13163),N=e.i(5769),k=e.i(71189),w=e.i(458),$=e.i(88293),S=e.i(96659),C=e.i(36994),E=e.i(99181),L=e.i(78451);let A=(0,p.default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var R=e.i(17118);let T=(0,p.default)("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);var O=e.i(31035),I=e.i(87283),D=e.i(27122),U=e.i(41997),F=e.i(36e3),q=e.i(13318),M=e.i(70746),P=e.i(20054),B=e.i(6278),z=e.i(60889);function _(e){let t=(0,L.emptyFolderSettings)();return{...t,auth:{...t.auth,authMode:"none",...e}}}let W=[{id:"successfactors",label:"SAP SuccessFactors",note:"Its OData API — browse objects and fields",icon:x},{id:"salesforce",label:"Salesforce",note:"Sign in with OAuth, browse objects and fields, query with SOQL",icon:T},{id:"netsuite",label:"NetSuite",note:"Token-based sign-in or OAuth 2.0, browse record types, query with SuiteQL",icon:f},{id:"odata",label:"OData service",note:"SAP Gateway, Dynamics, any OData v2 or v4 API",icon:f},{id:"api",label:"REST API",note:"Any HTTP API: a base URL and its sign-in, reused by your requests",icon:O.Globe},{id:"practice",label:"Practice company",note:"A pretend OData company built into the app — try it now",icon:g.FlaskConical},{id:"practice-salesforce",label:"Practice Salesforce org",note:"A pretend org built into the app: Accounts, Contacts, Users",icon:g.FlaskConical},{id:"practice-netsuite",label:"Practice NetSuite account",note:"A pretend account built into the app: customers, employees, items",icon:g.FlaskConical}],K=["Oracle EBS","PostgreSQL"];function H(e,t){if(t){let e=_({authMode:"oauth2"});return{...e,auth:{...e.auth,oauth:{...e.auth.oauth,grant:"client_credentials",tokenUrl:`${t.base}/services/rest/auth/oauth2/v1/token`,clientId:t.clientId,clientSecret:t.clientSecret,scope:"",clientAuth:"body"}}}}let s=_({authMode:"oauth1"});return{...s,auth:{...s.auth,oauth1:{...s.auth.oauth1,signatureMethod:"HMAC-SHA256",realm:e?i(e):"",addTo:"header"}}}}let V=e=>{let t=/^https:\/\/([^.]+)\.suitetalk\.api\.netsuite\.com/i.exec(e.trim());return t?i(t[1]):""},Z=e=>`${e.trim().replace(/\/+$/,"")}/services/oauth2/authorize`,Q=e=>`${e.trim().replace(/\/+$/,"")}/services/oauth2/token`;function Y(e,t,s="",n=""){let a=_({authMode:"oauth2"}),l={...a.auth.oauth,grant:t,authUrl:e?Z(e):"",tokenUrl:e?Q(e):"",clientId:s,clientSecret:n,scope:"",pkce:!0,clientAuth:"body"};return{...a,auth:{...a.auth,oauth:l}}}let G=["successfactors","salesforce","netsuite"];function J({editing:e,existing:s,onClose:n,onSaved:l}){let{demoApi:i}=(0,P.useEngineHealth)(),{vars:r}=(0,B.useWorkspace)(),[o,c]=(0,E.useState)(e?"details":"type"),[d,u]=(0,E.useState)(()=>e?{kind:e.kind,name:e.name,variable:e.variable,variableEdited:!0,baseUrl:e.baseUrl,settings:e.settings}:{kind:"api",name:"",variable:"",variableEdited:!1,baseUrl:"",settings:_({})}),[m,p]=(0,E.useState)("auth"),[x,h]=(0,E.useState)(!1),[f,b]=(0,E.useState)(!1),[g,j]=(0,E.useState)(null),[v,k]=(0,E.useState)(null),w=s.filter(t=>t.id!==e?.id).map(e=>e.variable),$=e=>{u(t=>{let s={...t,...e};if(void 0===e.name||s.variableEdited||(s.variable=(0,a.connectionVariableName)(s.name||X[s.kind],w)),void 0!==e.baseUrl&&"netsuite"===s.kind&&"oauth1"===s.settings.auth.authMode){let t=V(e.baseUrl);t&&(s.settings={...s.settings,auth:{...s.settings.auth,oauth1:{...s.settings.auth.oauth1,realm:t}}})}if(void 0!==e.baseUrl&&"salesforce"===s.kind&&"oauth2"===s.settings.auth.authMode){let n=s.settings.auth.oauth,a=t.baseUrl.trim()?Z(t.baseUrl):"",l=t.baseUrl.trim()?Q(t.baseUrl):"",i=e.baseUrl.trim(),r=n.authUrl&&n.authUrl!==a?n.authUrl:i?Z(i):"",o=n.tokenUrl&&n.tokenUrl!==l?n.tokenUrl:i?Q(i):"";s.settings={...s.settings,auth:{...s.settings.auth,oauth:{...n,authUrl:r,tokenUrl:o}}}}return s}),j(null)};(0,E.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(e.stopPropagation(),n())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[n]);let S=()=>({name:d.name.trim()||X[d.kind],kind:d.kind,variable:d.variable.trim(),baseUrl:d.baseUrl.trim(),settings:d.settings}),C=/^[A-Za-z_]\w{0,39}$/.test(d.variable.trim())&&!w.includes(d.variable.trim()),L=!!d.baseUrl.trim()&&C;async function T(){h(!0),k(null);try{j(await M.connectionsApi.test({...S(),...e?{id:e.id}:{}},r))}catch(e){k(e instanceof Error?e.message:"Could not test")}finally{h(!1)}}let O=(0,z.usePlanGate)();async function ee(){let t=e=>G.includes(e.kind)&&!e.baseUrl.includes("/demo-api");if(!(!e&&t(d))||await O("connections.enterprise",s.filter(t).length+1)){b(!0),k(null);try{l(e?await M.connectionsApi.update(e.id,S()):await M.connectionsApi.create(S()))}catch(e){k(e instanceof Error?e.message:"Could not save"),b(!1)}}}let et="block space-y-1 text-sm",es="text-xs text-mute",en=e?`Edit ${e.name}`:"type"===o?"Add a connection":`Connect ${"successfactors"===d.kind?"SAP SuccessFactors":"salesforce"===d.kind?"Salesforce":"netsuite"===d.kind?"NetSuite":"odata"===d.kind?"an OData service":"a REST API"}`;return(0,t.jsx)("div",{className:"fixed inset-0 z-[66] flex items-center-safe justify-center overflow-y-auto bg-black/50 p-4 sm:p-10",role:"presentation",onMouseDown:e=>e.target===e.currentTarget&&n(),children:(0,t.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"add-connection-title",className:"w-full max-w-2xl rounded-xl border border-line bg-panel shadow-2xl",children:[(0,t.jsxs)("header",{className:"flex items-center gap-2 border-b border-line px-5 py-4",children:["details"!==o||e?(0,t.jsx)(N.Plug,{size:16,className:"text-accent","aria-hidden":!0}):(0,t.jsx)("button",{type:"button","aria-label":"Back",onClick:()=>c("type"),className:"rounded p-1 text-mute hover:text-ink",children:(0,t.jsx)(A,{size:16})}),(0,t.jsx)("h2",{id:"add-connection-title",className:"flex-1 text-base font-medium text-ink",children:en}),(0,t.jsx)("button",{type:"button",onClick:n,"aria-label":"Close",className:"rounded p-1 text-mute hover:text-ink",children:(0,t.jsx)(I.X,{size:16})})]}),"type"===o?(0,t.jsxs)("div",{className:"space-y-4 px-5 py-5",children:[(0,t.jsx)("p",{className:"text-sm text-mute",children:"Set a system up once — its address and sign-in — and every request that starts with its variable uses it. No sign-in to repeat per request."}),(0,t.jsx)("h3",{className:"text-xs font-medium text-mute",children:"Choose a connector"}),(0,t.jsx)("div",{className:"-mt-2 grid gap-2 sm:grid-cols-2",children:W.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>(function(e){let t="practice"===e?"Practice company":"practice-salesforce"===e?"Practice org":"practice-netsuite"===e?"Practice account":X[e],s={kind:"practice"===e?"odata":"practice-salesforce"===e?"salesforce":"practice-netsuite"===e?"netsuite":e,name:t,variable:(0,a.connectionVariableName)(t,w),variableEdited:!1,baseUrl:"",settings:_({})};if("salesforce"===e&&(s.settings=Y("","authorization_code")),"practice-salesforce"===e){let e=i?`${i}/salesforce`:"";Object.assign(s,{variable:(0,a.connectionVariableName)("practiceOrg",w),variableEdited:!0,baseUrl:e,settings:Y(e,"client_credentials","practice","demo")})}if("practice"===e&&Object.assign(s,{variable:(0,a.connectionVariableName)("practice",w),variableEdited:!0,baseUrl:i?`${i}/odata/v2`:"",settings:_({authMode:"basic",username:"practice",password:"demo"})}),"successfactors"===e&&(s.settings=_({authMode:"basic"})),"netsuite"===e&&(s.settings=H("")),"practice-netsuite"===e){let e=i?`${i}/netsuite`:"";Object.assign(s,{variable:(0,a.connectionVariableName)("practiceAccount",w),variableEdited:!0,baseUrl:e,settings:H("",{base:e,clientId:"practice",clientSecret:"demo"})})}u(s),j(null),c("details")})(e.id),className:"flex items-start gap-3 rounded-lg border border-line p-3 text-left hover:border-accent",children:[(0,t.jsx)(e.icon,{size:18,className:"mt-0.5 shrink-0 text-accent","aria-hidden":!0}),(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-ink",children:e.label}),(0,t.jsx)("span",{className:"mt-0.5 block text-xs leading-snug text-mute",children:e.note})]})]},e.id))}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-mute",children:"Coming next"}),(0,t.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:K.map(e=>(0,t.jsx)("span",{className:"rounded-full border border-line px-2.5 py-0.5 text-xs text-mute",children:e},e))})]})]}):(0,t.jsxs)("div",{className:"space-y-4 px-5 py-5",children:[(0,t.jsxs)("div",{className:"grid gap-4 sm:grid-cols-[minmax(0,3fr)_minmax(0,2fr)]",children:[(0,t.jsxs)("label",{className:et,children:[(0,t.jsx)("span",{className:"text-ink",children:"Name"}),(0,t.jsx)("input",{className:"input",value:d.name,onChange:e=>$({name:e.target.value}),placeholder:X[d.kind]})]}),(0,t.jsxs)("label",{className:et,children:[(0,t.jsx)("span",{className:"text-ink",children:"Variable"}),(0,t.jsxs)("span",{className:"flex items-center rounded-md border border-line bg-panel-2 font-mono text-[13px] focus-within:border-accent",children:[(0,t.jsx)("span",{className:"pl-2.5 text-mute",children:"{{"}),(0,t.jsx)("input",{"aria-label":"Variable",className:"min-w-0 flex-1 bg-transparent px-0.5 py-1.5 text-ink outline-none",value:d.variable,onChange:e=>$({variable:e.target.value,variableEdited:!0}),spellCheck:!1}),(0,t.jsx)("span",{className:"pr-2.5 text-mute",children:"}}"})]})]})]}),!C&&d.variable?(0,t.jsx)("p",{className:"-mt-2 text-xs text-bad",children:w.includes(d.variable.trim())?"Another connection uses this variable.":"Letters, digits and _, starting with a letter."}):null,"netsuite"===d.kind?(0,t.jsxs)("label",{className:et,children:[(0,t.jsx)("span",{className:"text-ink",children:"Account ID"}),(0,t.jsx)("input",{className:"input font-mono text-[13px]","aria-label":"Account ID",value:V(d.baseUrl),onChange:e=>{var t;return $({baseUrl:e.target.value.trim()?(t=e.target.value,`https://${t.trim().toLowerCase().replace(/_/g,"-")}.suitetalk.api.netsuite.com`):""})},placeholder:"1234567 or 1234567_SB1",spellCheck:!1}),(0,t.jsx)("span",{className:es,children:"Setup → Company → Company Information. A sandbox's ends in _SB1, _SB2… The base URL follows."})]}):null,(0,t.jsxs)("label",{className:et,children:[(0,t.jsx)("span",{className:"text-ink",children:"Base URL"}),(0,t.jsx)("input",{className:"input font-mono text-[13px]",value:d.baseUrl,onChange:e=>$({baseUrl:e.target.value}),placeholder:"api"===d.kind?"https://api.example.com/v1":"salesforce"===d.kind?"https://yourcompany.my.salesforce.com":"netsuite"===d.kind?"https://1234567.suitetalk.api.netsuite.com":"https://api.example.com/odata/v2",spellCheck:!1}),(0,t.jsxs)("span",{className:es,children:["successfactors"===d.kind?"Your data center's API server with /odata/v2 — from SAP's list of API servers, or your admin.":"salesforce"===d.kind?"Your org's address (My Domain) — a sandbox's ends in .sandbox.my.salesforce.com.":"netsuite"===d.kind?"The account's REST address — filled in from the account ID.":"odata"===d.kind?"The service root — the part before /$metadata.":"The part every address of this API starts with."," ","Requests write ",(0,t.jsx)("span",{className:"font-mono text-ink",children:`{{${d.variable||"name"}}}/…`}),"."]})]}),(0,t.jsxs)("div",{className:"rounded-lg border border-line",children:[(0,t.jsx)(q.Tabs,{id:"connection-settings",label:"Connection settings",value:m,onChange:p,className:"px-3",items:[{id:"auth",label:"Sign-in"},{id:"headers",label:"Headers",badge:d.settings.headers.filter(e=>e.key.trim()).length||void 0}]}),(0,t.jsx)("div",{...(0,q.tabPanelProps)("connection-settings",m),className:"p-3",children:"auth"===m?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(U.AuthFields,{value:d.settings.auth,onChange:e=>$({settings:{...d.settings,auth:{...d.settings.auth,...e}}}),noInherit:!0,inheritNote:null,defaults:r,secretNote:"Use {{name}} to take it from the environment, or type it — it's kept encrypted on this computer."}),"netsuite"===d.kind?(0,t.jsxs)("p",{className:es,children:[(0,t.jsx)("span",{className:"text-ink",children:"Token-based"})," (OAuth 1.0, HMAC-SHA256): in NetSuite, enable Token-Based Authentication and REST Web Services (Setup → Company → Enable Features → SuiteCloud), create an ",(0,t.jsx)("span",{className:"text-ink",children:"Integration"})," record (its consumer key and secret) and an ",(0,t.jsx)("span",{className:"text-ink",children:"Access Token"})," for a user and role (its token ID and secret). The realm is the account ID. Or pick ",(0,t.jsx)("span",{className:"text-ink",children:"OAuth 2.0"}),". The guide has every step."]}):null,"salesforce"===d.kind?(0,t.jsxs)("p",{className:es,children:["In Salesforce Setup, create an ",(0,t.jsx)("span",{className:"text-ink",children:"External Client App"})," with OAuth on: callback URL ",(0,t.jsx)("span",{className:"font-mono text-ink",children:d.settings.auth.oauth.redirectUri}),", scopes ",(0,t.jsx)("span",{className:"text-ink",children:"api"})," and"," ",(0,t.jsx)("span",{className:"text-ink",children:"refresh_token"}),", PKCE on. Paste its consumer key and secret above, leave Scope empty (Salesforce uses the app's scopes), then sign in. For a server-to-server login, pick the client credentials grant and set a run-as user in the app. The guide has every step."]}):null,"successfactors"===d.kind?(0,t.jsxs)("p",{className:es,children:["Basic: the user name is ",(0,t.jsx)("span",{className:"font-mono text-ink",children:"user@companyID"}),". For OAuth, pick ",(0,t.jsx)("span",{className:"text-ink",children:"OAuth 2.0 → SAML 2.0 bearer"}),", which signs in with the company ID and a private key."]}):null]}):(0,t.jsx)(F.KeyValueEditor,{rows:d.settings.headers,onChange:e=>$({settings:{...d.settings,headers:e}}),keyPlaceholder:"Header",valuePlaceholder:"Value",noun:"header"})})]}),g?(0,t.jsxs)("div",{role:"status",className:`flex items-start gap-2 rounded-md border px-3 py-2 text-sm ${g.ok?"border-ok/40 bg-ok/10":"border-bad/40 bg-bad/10"}`,children:[g.ok?(0,t.jsx)(R.CheckCircle2,{size:16,className:"mt-0.5 shrink-0 text-ok","aria-hidden":!0}):(0,t.jsx)(D.XCircle,{size:16,className:"mt-0.5 shrink-0 text-bad","aria-hidden":!0}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-ink",children:g.ok?g.version?`Connected — ${g.version}, ${g.entitySets} objects, ${g.ms} ms`:`Connected — the server answered ${g.status}, ${g.ms} ms`:g.error}),g.hint?(0,t.jsx)("p",{className:"mt-0.5 text-xs text-mute",children:g.hint}):null]})]}):null,v?(0,t.jsx)("p",{role:"alert",className:"text-sm text-bad",children:v}):null]}),"details"===o?(0,t.jsxs)("footer",{className:"flex items-center justify-end gap-2 border-t border-line px-5 py-3",children:[(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1.5 text-sm",onClick:()=>void T(),disabled:!L||x,children:[x?(0,t.jsx)(y.Loader2,{size:14,className:"animate-spin"}):null,"Test connection"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-primary py-1.5 text-sm",onClick:()=>void ee(),disabled:!L||f,children:[f?(0,t.jsx)(y.Loader2,{size:14,className:"animate-spin"}):null,!g||g.ok||e?"Save":"Save anyway"]})]}):null]})})}let X={successfactors:"SuccessFactors",salesforce:"Salesforce",netsuite:"NetSuite",odata:"OData service",api:"My API"},ee=/^Edm\.(Int16|Int32|Int64|Byte|SByte|Decimal|Double|Single)$/;function et(e,t,s){return e.filter(e=>e.field).map(e=>{let n=t.find(t=>t.name===e.field)?.type??"Edm.String";if("contains"===e.op||"startswith"===e.op||"endswith"===e.op){let t=`'${e.value.replace(/'/g,"''")}'`;return"contains"===e.op&&"2.0"===s?`substringof(${t},${e.field})`:`${e.op}(${e.field},${t})`}return`${e.field} ${e.op} ${function(e,t,s){let n=e.trim();if(/^null$/i.test(n))return"null";if(ee.test(t)&&/^-?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(n))return"2.0"===s&&"Edm.Int64"===t?`${n}L`:"2.0"===s&&"Edm.Decimal"===t?`${n}M`:n;if("Edm.Boolean"===t&&/^(true|false)$/i.test(n))return n.toLowerCase();if("Edm.Guid"===t)return"2.0"===s?`guid'${n}'`:n;if("Edm.DateTime"===t)return`datetime'${n.replace(/Z$/,"").replace(/^(\d{4}-\d\d-\d\d)$/,"$1T00:00:00")}'`;if("Edm.DateTimeOffset"===t){let e=/^\d{4}-\d\d-\d\d$/.test(n)?`${n}T00:00:00Z`:n;return"2.0"===s?`datetimeoffset'${e}'`:e}return"Edm.Date"===t&&"4.0"===s?n:`'${e.replace(/'/g,"''")}'`}(e.value,n,s)}`}).join(" and ")}function es(e,t){let s=[],n=0,a=!1,l=0,i=e.toLowerCase();for(let r=0;r<e.length;r++){let o=e[r];"'"===o?a=!a:a||"("!==o?a||")"!==o?!a&&0===n&&i.startsWith(t,r)&&(s.push(e.slice(l,r)),l=r+t.length,r+=t.length-1):n--:n++}return s.push(e.slice(l)),s.map(e=>e.trim()).filter(Boolean)}let en=e=>{let t={};for(let[s,n]of Object.entries(e))!("__metadata"===s||s.startsWith("@odata.")||s.includes("@odata."))&&(n&&"object"==typeof n&&"__deferred"in n||(n&&"object"==typeof n&&Array.isArray(n.results)?t[s]=n.results.map(en):n&&"object"==typeof n&&!Array.isArray(n)?t[s]=en(n):t[s]=n));return t};function ea(e){if(!e||"object"!=typeof e)return{rows:[]};if("d"in e){let t=e.d;if(Array.isArray(t))return{rows:t.map(en)};let s=t??{};if(Array.isArray(s.results)){let e=Number(s.__count);return{rows:s.results.map(en),...Number.isFinite(e)&&void 0!==s.__count?{count:e}:{},..."string"==typeof s.__next?{next:s.__next}:{}}}return{rows:[en(s)]}}if(Array.isArray(e.value)){let t=Number(e["@odata.count"]);return{rows:e.value.map(en),...void 0!==e["@odata.count"]&&Number.isFinite(t)?{count:t}:{},..."string"==typeof e["@odata.nextLink"]?{next:e["@odata.nextLink"]}:{}}}return{rows:[en(e)]}}function el(e){if(null==e)return"";if("string"==typeof e){let t=/^\/Date\((-?\d+)([+-]\d{4})?\)\/$/.exec(e);if(!t)return e;let s=new Date(Number(t[1])).toISOString();return s.endsWith("T00:00:00.000Z")?s.slice(0,10):s.replace(".000Z","Z")}return"object"==typeof e?JSON.stringify(e):String(e)}let ei=(0,p.default)("arrow-down-a-z",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]),er=(0,p.default)("arrow-up-a-z",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);var eo=e.i(68204),ec=e.i(95211),ed=e.i(89932),eu=e.i(75117),em=e.i(19286),ep=e.i(3792),ex=e.i(95927),eh=e.i(69578),ef=e.i(37837),eb=e.i(28867),eg=e.i(80707),ey=e.i(56396);let ej=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/%/g,"\\%").replace(/_/g,"\\_"),ev={eq:"=",ne:"!=",gt:">",ge:">=",lt:"<",le:"<="},eN=e=>e.replace(/\//g,".");function ek(e,t){return e.filter(e=>e.field).map(e=>{var s;let n,a,l=t.find(t=>t.name===e.field);return"contains"===e.op?`${eN(e.field)} LIKE '%${ej(e.value)}%'`:"startswith"===e.op?`${eN(e.field)} LIKE '${ej(e.value)}%'`:"endswith"===e.op?`${eN(e.field)} LIKE '%${ej(e.value)}'`:`${eN(e.field)} ${ev[e.op]??"="} ${s=e.value,n=s.trim(),a=l?.type.split(":")[1]??"string",/^null$/i.test(n)?"null":"boolean"===a&&/^(true|false)$/i.test(n)?n.toLowerCase():["int","long","double","currency","percent"].includes(a)&&/^-?\d+(\.\d+)?$/.test(n)||"date"===a&&/^\d{4}-\d\d-\d\d$/.test(n)?n:"datetime"===a&&/^\d{4}-\d\d-\d\d/.test(n)?/^\d{4}-\d\d-\d\d$/.test(n)?`${n}T00:00:00Z`:n:`'${s.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`}`}).join(" AND ")}function ew(e,t,s={}){let n=t.entitySets.find(t=>t.name===e.entitySet),a=e.select?.length?e.select.map(eN):n?.properties.length?n.properties.map(e=>e.name):["Id"],l=e.filterText?.trim()||ek(e.filters??[],n?.properties??[]),i=[`SELECT ${s.countOnly?"COUNT()":a.join(", ")} FROM ${e.entitySet}`];return l&&i.push(`WHERE ${l}`),s.countOnly||(e.orderBy?.field&&i.push(`ORDER BY ${eN(e.orderBy.field)}${e.orderBy.desc?" DESC":" ASC"}`),void 0!==e.top&&i.push(`LIMIT ${e.top}`),e.skip&&i.push(`OFFSET ${e.skip}`)),i.join(" ")}function e$(e,t){return`services/data/${t.soql?.apiVersion??"v62.0"}/query?q=${encodeURIComponent(e)}`}let eS=e=>{let t={};for(let[s,n]of Object.entries(e))"attributes"!==s&&(n&&"object"==typeof n&&Array.isArray(n.records)?t[s]=n.records.map(eS):n&&"object"==typeof n&&!Array.isArray(n)?t[s]=eS(n):t[s]=n);return t};function eC(e){let t=e??{};return{rows:Array.isArray(t.records)?t.records.map(eS):[],..."string"==typeof t.nextRecordsUrl?{next:t.nextRecordsUrl}:{}}}function eE(e){return e.suiteql?{soql:!0,language:"SuiteQL",path:t=>{let s,n;return s=e.entitySets.find(e=>e.name===t.entitySet),n=t.filterText?.trim()||d(t.filters??[],s?.properties??[]),u(function(e,t=[]){let s=new Set(t.filter(t=>t.ref&&!e.noNames?.includes(t.name)).map(e=>e.name)),n=!!(e.names&&s.size),a=e.select?.length?e.select:n?t.map(e=>e.name):[],l=a.length?a.flatMap(e=>n&&s.has(e)?[e,`BUILTIN.DF(${e}) AS ${r(e)}`]:[e]).join(", "):"*",i=e.filterText?.trim()||"",o=[`SELECT ${l} FROM ${e.entitySet}`];return i&&o.push(`WHERE ${i}`),e.orderBy?.field&&o.push(`ORDER BY ${e.orderBy.field}${e.orderBy.desc?" DESC":" ASC"}`),o.join(" ")}({...t,filterText:n},s?.properties??[]),t)},pathForText:(e,t)=>{let s=Number(/[?&]limit=(\d+)/.exec(t)?.[1]);return u(e,Number.isFinite(s)?{top:s}:{})},pageSize:1e3,rows:m,filter:(e,t)=>d(e,t),parse:t=>(function(e,t){let s,n=e.trim(),a=/[?&]q=([^&]*)/.exec(n);if(a){let e=/[?&]limit=(\d+)/.exec(n);e&&(s=Number(e[1]));try{n=decodeURIComponent(a[1].replace(/\+/g," "))}catch{n=a[1]}}let l=/^SELECT\s+(.+?)\s+FROM\s+(\w+)(?:\s+WHERE\s+(.+?))?(?:\s+ORDER\s+BY\s+(\w+)(?:\s+(ASC|DESC))?)?\s*$/is.exec(n);if(!l)return null;let i=t.entitySets.find(e=>e.name.toLowerCase()===l[2].toLowerCase());if(!i)return null;let r={entitySet:i.name};if("*"!==l[1].trim()){let e=l[1].split(",").map(e=>e.trim()).filter(Boolean),t=e.filter(e=>!/^BUILTIN\.DF\(\w+\)(\s+AS\s+\w+)?$/i.test(e));t.length<e.length&&(r.names=!0);let s=i.properties.map(e=>e.name);r.names&&t.length===s.length&&s.every(e=>t.includes(e))||(r.select=t)}if(l[3]){let e=function(e){if(/\bOR\b|\(/i.test(e.replace(/'(?:[^']|'')*'/g,"''").replace(/BUILTIN\.DF\(\w+\)/gi,"df")))return null;let t=[];for(let s of e.split(/\s+AND\s+(?=(?:[^']*'[^']*')*[^']*$)/i)){let e,n=s.trim(),a=e=>e.replace(/''/g,"'"),l=String.raw`(?:BUILTIN\.DF\((\w+)\)|(\w+))`;if(e=RegExp(`^${l}\\s+LIKE\\s+'((?:[^']|'')*)'$`,"i").exec(n)){let s=e[3],n=s.startsWith("%"),l=s.endsWith("%");t.push({field:e[1]??e[2],op:n&&l?"contains":l?"startswith":n?"endswith":"eq",value:a(s.slice(+!!n,l?-1:void 0)),...e[1]?{byName:!0}:{}})}else if(e=RegExp(`^${l}\\s+IS\\s+(NOT\\s+)?NULL$`,"i").exec(n))t.push({field:e[1]??e[2],op:e[3]?"ne":"eq",value:"null",...e[1]?{byName:!0}:{}});else{if(!(e=RegExp(`^${l}\\s*(=|<>|!=|>=|<=|>|<)\\s*(.+)$`,"i").exec(n)))return null;let s={"=":"eq","<>":"ne","!=":"ne",">":"gt",">=":"ge","<":"lt","<=":"le"}[e[3]],i=e[4].trim(),r=/^'((?:[^']|'')*)'$/.exec(i),o=/^TO_DATE\('([^']*)'/i.exec(i);t.push({field:e[1]??e[2],op:s,value:r?"T"===r[1]?"true":"F"===r[1]?"false":a(r[1]):o?o[1]:i,...e[1]?{byName:!0}:{}})}}return t}(l[3]);e?r.filters=e:r.filterText=l[3]}return l[4]&&(r.orderBy={field:l[4],desc:l[5]?.toUpperCase()==="DESC"}),void 0!==s&&(r.top=s),r})(t,e),filterLabel:"WHERE"}:e.soql?{soql:!0,language:"SOQL",pathForText:t=>e$(t,e),path:t=>e$(ew(t,e),e),countPath:t=>e$(ew(t,e,{countOnly:!0}),e),rows:eC,filter:(e,t)=>ek(e,t),parse:t=>(function(e,t){let s=e.trim(),n=/[?&]q=([^&]*)/.exec(s);if(n)try{s=decodeURIComponent(n[1].replace(/\+/g," "))}catch{s=n[1]}let a=/^SELECT\s+(.+?)\s+FROM\s+(\w+)(?:\s+WHERE\s+(.+?))?(?:\s+ORDER\s+BY\s+([\w.]+)(?:\s+(ASC|DESC))?(?:\s+NULLS\s+(?:FIRST|LAST))?)?(?:\s+LIMIT\s+(\d+))?(?:\s+OFFSET\s+\d+)?\s*$/is.exec(s);if(!a)return null;let l=t.entitySets.find(e=>e.name.toLowerCase()===a[2].toLowerCase());if(!l)return null;let i={entitySet:l.name},r=a[1].split(",").map(e=>e.trim()).filter(Boolean);if(1===r.length&&/^COUNT\(\)$/i.test(r[0])||(i.select=r.map(e=>e.replace(/\./g,"/"))),a[3]){let e=function(e){if(/\bOR\b|\(/i.test(e.replace(/'(?:[^'\\]|\\.)*'/g,"''")))return null;let t=[];for(let s of e.split(/\s+AND\s+(?=(?:[^']*'[^']*')*[^']*$)/i)){let e,n=s.trim(),a=e=>e.replace(/\\(.)/g,"$1");if(e=/^([\w.]+)\s+LIKE\s+'((?:[^'\\]|\\.)*)'$/i.exec(n)){let s=e[2],n=s.startsWith("%"),l=s.endsWith("%")&&!s.endsWith("\\%"),i=a(s.slice(+!!n,l?-1:void 0));t.push({field:e[1].replace(/\./g,"/"),op:n&&l?"contains":l?"startswith":n?"endswith":"eq",value:i})}else{if(!(e=/^([\w.]+)\s*(=|!=|<>|>=|<=|>|<)\s*(.+)$/.exec(n)))return null;let s={"=":"eq","!=":"ne","<>":"ne",">":"gt",">=":"ge","<":"lt","<=":"le"}[e[2]],l=e[3].trim(),i=/^'((?:[^'\\]|\\.)*)'$/.exec(l);t.push({field:e[1].replace(/\./g,"/"),op:s,value:i?a(i[1]):l.replace(/T00:00:00(\.0+)?Z$/,"")})}}return t}(a[3]);e?i.filters=e:i.filterText=a[3]}return a[4]&&(i.orderBy={field:a[4].replace(/\./g,"/"),desc:a[5]?.toUpperCase()==="DESC"}),a[6]&&(i.top=Number(a[6])),i})(t,e),filterLabel:"WHERE"}:{soql:!1,language:null,path:t=>(function(e,t){let s=t.entitySets.find(t=>t.name===e.entitySet),n=[],a=(e.select??[]).filter(e=>!e.includes("/")),l=new Map;for(let t of e.expand??[])l.set(t,[]);for(let t of e.select??[]){let e=t.indexOf("/");e>0&&l.set(t.slice(0,e),[...l.get(t.slice(0,e))??[],t.slice(e+1)])}"2.0"===t.version?e.select?.length&&n.push(["$select",e.select.join(",")]):a.length&&n.push(["$select",a.join(",")]);let i=e.filterText?.trim()||et(e.filters??[],s?.properties??[],t.version);return i&&n.push(["$filter",i]),l.size&&n.push(["$expand",[...l].map(([e,s])=>"4.0"===t.version&&s.length?`${e}($select=${s.join(",")})`:e).join(",")]),e.orderBy?.field&&n.push(["$orderby",`${e.orderBy.field}${e.orderBy.desc?" desc":""}`]),void 0!==e.top&&n.push(["$top",String(e.top)]),e.skip&&n.push(["$skip",String(e.skip)]),e.count&&n.push("2.0"===t.version?["$inlinecount","allpages"]:["$count","true"]),"2.0"===t.version&&n.push(["$format","json"]),n.length?`${e.entitySet}?${n.map(([e,t])=>`${e}=${encodeURIComponent(t).replace(/%3D/g,"=").replace(/%3B/g,";").replace(/%2C/g,",").replace(/%2F/g,"/").replace(/%3A/g,":").replace(/%24/g,"$")}`).join("&")}`:e.entitySet})(t,e),rows:ea,filter:(t,s)=>et(t,s,e.version),parse:(t,s)=>(function(e,t,s=""){let n=e.trim(),a=s.replace(/\/+$/,"");a&&n.startsWith(a)&&(n=n.slice(a.length));let l=(n=n.replace(/^\{\{[^}]*\}\}/,"").replace(/^\/+/,"")).indexOf("?"),i=((l<0?n:n.slice(0,l)).split("/").filter(Boolean).pop()??"").replace(/\(.*\)$/,""),r=t.entitySets.find(e=>e.name===i)??t.entitySets.find(e=>e.name.toLowerCase()===i.toLowerCase());if(!r)return null;let o=new Map;for(let e of(l<0?"":n.slice(l+1)).split("&").filter(Boolean)){let t=e.indexOf("="),s=e=>{try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}};o.set(s(t<0?e:e.slice(0,t)).toLowerCase(),s(t<0?"":e.slice(t+1)))}let c={entitySet:r.name},d=(o.get("$select")??"").split(",").map(e=>e.trim()).filter(Boolean),u=[];for(let e of es(o.get("$expand")??"",",")){let t=/^([\w/]+)(?:\((.*)\))?$/.exec(e);if(!t)continue;u.push(t[1]);let s=/\$select=([^;)]*)/i.exec(t[2]??"")?.[1];if(s)for(let e of s.split(",").map(e=>e.trim()).filter(Boolean))d.push(`${t[1]}/${e}`)}d.length&&(c.select=d);let m=new Set(d.filter(e=>e.includes("/")).map(e=>e.slice(0,e.indexOf("/")))),p=u.filter(e=>!m.has(e));p.length&&(c.expand=p);let x=o.get("$filter")?.trim();if(x){let e=function(e){if(es(e," or ").length>1)return null;let t=[];for(let s of es(e," and ")){let e;if(e=/^substringof\(\s*'((?:[^']|'')*)'\s*,\s*([\w/]+)\s*\)$/i.exec(s))t.push({field:e[2],op:"contains",value:e[1].replace(/''/g,"'")});else if(e=/^(contains|startswith|endswith)\(\s*([\w/]+)\s*,\s*'((?:[^']|'')*)'\s*\)$/i.exec(s))t.push({field:e[2],op:e[1].toLowerCase(),value:e[3].replace(/''/g,"'")});else{if(!(e=/^([\w/]+)\s+(eq|ne|gt|ge|lt|le)\s+(.+)$/i.exec(s)))return null;let n=function(e){let t,s=e.trim();return(t=/^'((?:[^']|'')*)'$/.exec(s))?t[1].replace(/''/g,"'"):(t=/^(?:datetime|datetimeoffset|guid)'([^']*)'$/i.exec(s))?t[1].replace(/T00:00:00(\.0+)?Z?$/,""):(t=/^(-?\d+(?:\.\d+)?)[LMDdmf]?$/.exec(s))?t[1]:/^(true|false|null)$/i.test(s)?s.toLowerCase():/^\d{4}-\d\d-\d\d/.test(s)?s.replace(/T00:00:00(\.0+)?Z?$/,""):null}(e[3]);if(null===n)return null;t.push({field:e[1],op:e[2].toLowerCase(),value:n})}}return t}(x);e?c.filters=e:c.filterText=x}let h=o.get("$orderby")?.split(",")[0]?.trim().split(/\s+/);h?.[0]&&(c.orderBy={field:h[0],desc:h[1]?.toLowerCase()==="desc"});let f=Number(o.get("$top"));return o.has("$top")&&Number.isFinite(f)&&(c.top=f),c.count="allpages"===o.get("$inlinecount")||"true"===o.get("$count"),c})(t,e,s),filterLabel:"$filter"}}let eL=e=>e.type.includes(":")?e.type.split(":")[1]:e.type.replace(/^Edm\./,"");var eA=e.i(61230),eR=e.i(28950),eT=e.i(15060),eO=e.i(30617);function eI(e,t,s){sessionStorage.setItem(eh.OPEN_DRAFT_KEY,JSON.stringify(eD(e,t))),s.push("/")}function eD(e,t){let s=e.baseUrl.replace(/\/+$/,""),n=t.startsWith(s)?t.slice(s.length).replace(/^\/+/,""):/^https?:\/\//i.test(t)?null:t.replace(/^\/+/,""),l="netsuite"===e.kind&&null!==n?function(e){let t=e.indexOf("?");if(t<0||!e.slice(0,t).endsWith("query/v1/suiteql"))return null;let s=new URLSearchParams(e.slice(t+1)),n=s.get("q");if(!n)return null;s.delete("q");let a=s.toString();return{path:a?`${e.slice(0,t)}?${a}`:e.slice(0,t),q:n}}(n):null;return l?{method:"POST",url:`{{${e.variable}}}/${l.path}`,headers:[{key:"Accept",value:"application/json"},{key:"Prefer",value:"transient"}],bodyMode:"json",bodyText:JSON.stringify({q:l.q},null,2),authMode:"inherit"}:{method:"GET",url:null===n?t:`{{${e.variable}}}/${(0,eA.readableUrl)(n)}`,headers:a.BROWSABLE_KINDS.includes(e.kind)?[{key:"Accept",value:"application/json"}]:[],authMode:"inherit"}}function eU({connection:e,path:s,name:n}){let a=(0,ey.useToast)(),{index:l,refresh:i}=(0,B.useWorkspace)(),[r,o]=(0,E.useState)(!1),[c,d]=(0,E.useState)(n),[u,m]=(0,E.useState)(""),[p,x]=(0,E.useState)(!1),h=(0,E.useRef)(null),f=(l?.folders??[]).map(e=>e.path);async function b(){if(!p&&c.trim()){x(!0);try{await B.workspaceApi.create({name:c.trim(),collection:u,request:eD(e,s)}),await i(),o(!1),a(`Saved “${c.trim()}”${u?` in ${u}`:""} — find it in Saved requests on Test API`,"success")}catch(e){a(e instanceof Error?e.message:"Could not save","error")}finally{x(!1)}}}return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{ref:h,type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>(d(n),o(!0)),title:"Keep this query as a saved request — for collection runs, performance tests and CI",children:[(0,t.jsx)(ex.Save,{size:13}),"Save as request"]}),(0,t.jsx)(ef.Popover,{anchor:h,open:r,onClose:()=>o(!1),label:"Save as request",width:340,children:(0,t.jsxs)("form",{className:"space-y-2.5 p-3",onSubmit:e=>{e.preventDefault(),b()},children:[(0,t.jsxs)("label",{className:"block space-y-1 text-xs text-mute",children:["Name",(0,t.jsx)("input",{autoFocus:!0,value:c,onChange:e=>d(e.target.value.slice(0,120)),"aria-label":"Request name",className:"input py-1.5 text-sm"})]}),(0,t.jsxs)("div",{className:"space-y-1 text-xs text-mute",children:[(0,t.jsx)("span",{children:"Folder"}),(0,t.jsx)(eg.Select,{label:"Folder",value:u,onChange:m,className:"w-full rounded-md border border-line bg-panel-2 px-2.5 py-1.5 text-sm text-ink",options:[{value:"",label:"No folder"},...f.map(e=>({value:e,label:e}))]})]}),(0,t.jsx)("p",{className:"text-xs text-mute",children:"Signed in by the connection — no secret is copied into the request."}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>o(!1),children:"Cancel"}),(0,t.jsxs)("button",{type:"submit",className:"btn btn-primary py-1 text-xs",disabled:p||!c.trim(),children:[p?(0,t.jsx)(y.Loader2,{size:13,className:"animate-spin"}):null,"Save"]})]})]})})]})}function eF({connection:e,schema:s,set:n,initial:a,onOpenObject:l,onNeed:i,memoryKey:r}){let[o,c]=(0,eR.useRemembered)(`${r}:view`,"records"),[d,u]=(0,eR.useRemembered)(`${r}:visited`,()=>new Set(["records"])),[m,p]=(0,eR.useRemembered)(`${r}:path`,()=>eE(s).path({entitySet:n.name,top:50,count:!0})),x=(0,C.useRouter)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-line px-4 pt-3 lg:px-6",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-medium text-ink",children:n.label??n.name}),(0,t.jsxs)("p",{className:"truncate font-mono text-xs text-mute",children:[n.name," · ",n.properties.length," fields",n.navigation.length?` \xb7 ${n.navigation.length} ${1===n.navigation.length?"link":"links"}`:""]})]}),(0,t.jsx)(eq,{connection:e,schema:s,onOpenObject:l}),(0,t.jsx)(eU,{connection:e,path:m,name:n.label??n.name}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>eI(e,m,x),title:"A GET with this query, signed in — to test, save or load-test",children:[(0,t.jsx)(b.ExternalLink,{size:13}),"Open as request"]}),(0,t.jsx)(q.Tabs,{id:"object-view",label:"Object",value:o,onChange:e=>{c(e),u(t=>t.has(e)?t:new Set([...t,e]))},className:"w-full",items:[{id:"records",label:"Records"},{id:"fields",label:"Fields",badge:n.properties.length},{id:"query",label:"Query"}]})]}),["records","fields","query"].map(c=>d.has(c)?(0,t.jsx)("div",{...(0,q.tabPanelProps)("object-view",c),className:o===c?"flex min-h-0 flex-1 flex-col":"hidden",children:"records"===c?(0,t.jsx)(eQ,{connection:e,schema:s,set:n,initial:a,onPath:p,onNeed:i,memoryKey:`${r}:records`}):"fields"===c?(0,t.jsx)(e5,{schema:s,set:n,onOpenObject:l,onNeed:i}):(0,t.jsx)(e6,{connection:e,schema:s,path:m,onPath:p,onOpenObject:l,memoryKey:`${r}:query`})},c):null)]})}function eq({connection:e,schema:s,onOpenObject:n}){let[a,l]=(0,E.useState)(!1),[i,r]=(0,E.useState)(""),[o,c]=(0,E.useState)(null),d=(0,E.useRef)(null);function u(){let t=eE(s).parse(i,e.baseUrl);if(!t)return c(s.suiteql?"That isn't SuiteQL for a record type of this account.":s.soql?"That isn't SOQL (or an address with ?q=SOQL) for an object of this org.":"That address doesn't name an object of this connection.");l(!1),r(""),c(null),n(t.entitySet,t)}return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{ref:d,type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>l(!0),title:"Fill the builder from an OData address",children:[(0,t.jsx)(eo.ClipboardPaste,{size:13}),"Paste URL"]}),(0,t.jsx)(ef.Popover,{anchor:d,open:a,onClose:()=>l(!1),label:"Paste an OData URL",width:460,children:(0,t.jsxs)("form",{className:"space-y-2 p-3",onSubmit:e=>{e.preventDefault(),u()},children:[(0,t.jsxs)("label",{className:"block text-xs text-mute",children:[s.suiteql?"SuiteQL — from Postman, a SuiteQL tool or a colleague.":s.soql?"SOQL, or an address with ?q=SOQL — from Postman, the Developer Console or a colleague.":"An address of this service — from Postman, a browser or a colleague."," Its object, fields, conditions, links, order and rows fill the builder.",(0,t.jsx)("textarea",{autoFocus:!0,value:i,onChange:e=>(r(e.target.value),c(null)),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),u())},rows:3,"aria-label":"OData URL",spellCheck:!1,placeholder:`${e.baseUrl}/Object?$select=…&$filter=…`,className:"input mt-1.5 font-mono text-xs"})]}),o?(0,t.jsx)("p",{className:"text-xs text-bad",children:o}):null,(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)("button",{type:"submit",className:"btn btn-primary py-1 text-xs",disabled:!i.trim(),children:"Fill the builder"})})]})})]})}let eM=[{id:"eq",label:"is"},{id:"ne",label:"is not"},{id:"contains",label:"contains"},{id:"startswith",label:"starts with"},{id:"endswith",label:"ends with"},{id:"gt",label:"more than"},{id:"ge",label:"at least"},{id:"lt",label:"less than"},{id:"le",label:"at most"}].map(e=>({value:e.id,label:e.label})),eP=["contains","startswith","endswith"],eB="apitestcenter-field-order",ez="atc:field-order";function e_(){let[e,t]=(0,E.useState)("az");return(0,E.useEffect)(()=>{let e=()=>{try{t("service"===localStorage.getItem(eB)?"service":"az")}catch{}};return e(),window.addEventListener(ez,e),()=>window.removeEventListener(ez,e)},[]),[e,e=>{try{localStorage.setItem(eB,e)}catch{}window.dispatchEvent(new Event(ez))}]}function eW(e,t){return"service"===t?e:[...e].sort((e,t)=>Number(t.key)-Number(e.key)||(e.label??e.name).localeCompare(t.label??t.name,void 0,{sensitivity:"base",numeric:!0}))}function eK(e,t){return"service"===t?e:[...e].sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base"}))}function eH({order:e,onChange:s}){return(0,t.jsx)("button",{type:"button",className:"shrink-0 text-xs text-mute hover:text-ink",onClick:()=>s("az"===e?"service":"az"),title:"az"===e?"Sorted A–Z (keys first) — show the service's own order":"In the service's own order — sort A–Z",children:"az"===e?"A–Z":"Service order"})}let eV=[{value:"10",label:"10 rows"},{value:"50",label:"50 rows"},{value:"100",label:"100 rows"},{value:"500",label:"500 rows"},{value:"1000",label:"1,000 rows"},{value:"all",label:"All, page by page"}];function eZ(e,t){let s=t.indexOf("/");if(s<0)return e[t];let n=e[t.slice(0,s)],a=t.slice(s+1);return Array.isArray(n)?n.map(e=>e&&"object"==typeof e?e[a]:void 0):n&&"object"==typeof n?n[a]:void 0}function eQ({connection:e,schema:s,set:n,initial:a,onPath:l,onNeed:i,memoryKey:o}){let c=eE(s),d=(0,ey.useToast)(),{vars:u}=(0,B.useWorkspace)(),m=n.properties.map(e=>e.name),[p,x]=(0,eR.useRemembered)(`${o}:columns`,a?.select??[]),[h,f]=(0,eR.useRemembered)(`${o}:filters`,a?.filters??[]),[b,g]=(0,eR.useRemembered)(`${o}:filterText`,a?.filterText??null),[j,v]=(0,eR.useRemembered)(`${o}:order`,{field:a?.orderBy?.field??"",desc:!!a?.orderBy?.desc}),[N,w]=(0,eR.useRemembered)(`${o}:limit`,a?a.top??"all":50),[$,S]=(0,eR.useRemembered)(`${o}:withCount`,a?.count??!0),C=!!(s.suiteql&&n.properties.some(e=>e.ref)),[L,A]=(0,eR.useRemembered)(`${o}:names`,a?.names??!0),[R,T]=(0,eR.useRemembered)(`${o}:noNames`,[]),O=e=>C&&L&&!!n.properties.find(t=>t.name===e)?.ref&&!R.includes(e),[D,U]=(0,eR.useRemembered)(`${o}:rows`,[]),[F,q]=(0,eR.useRemembered)(`${o}:count`,void 0),[P,_]=(0,eR.useRemembered)(`${o}:next`,void 0),[W,K]=(0,eR.useRemembered)(`${o}:answer`,null),[H,V]=(0,E.useState)(!1),[Z,Q]=(0,eR.useRemembered)(`${o}:error`,null),[Y,G]=(0,eR.useRemembered)(`${o}:record`,null),J=a?.expand??[],X=e=>{let t=e.indexOf("/");if(t<0)return n.properties.find(t=>t.name===e);let a=n.navigation.find(s=>s.name===e.slice(0,t));return s.entitySets.find(e=>e.name===a?.target)?.properties.find(s=>s.name===e.slice(t+1))},ee=e=>{let t=X(e),s=e.indexOf("/");return s<0?t?.label:`${e.slice(0,s)} / ${t?.label??e.slice(s+1)}`},et=h.filter(e=>e.field&&(e.value||!1===eP.includes(e.op))),es=c.filter(et,n.properties),en=e=>({entitySet:n.name,select:p.length?p:void 0,expand:J.length?J:void 0,filters:et,filterText:b??void 0,orderBy:j.field?j:void 0,top:"all"===N?void 0:N,...e?{skip:e}:{},count:$,...C&&L?{names:!0,...R.length?{noNames:R}:{}}:{}});async function ea(){let t=n.properties.filter(e=>e.ref&&!R.includes(e.name)).map(e=>e.name),s=[];for(let a=0;a<t.length;a+=4)await Promise.all(t.slice(a,a+4).map(async t=>{let a=await M.connectionsApi.get(e.id,c.pathForText(`SELECT BUILTIN.DF(${t}) AS name FROM ${n.name}`,"?limit=1"),u).catch(()=>null);(!a||a.error)&&s.push(t)}));return s}function eo(e,t,s){let n="number"==typeof N?N:c.pageSize,a=void 0!==n&&e.rows.length===n&&(void 0===s||t+n<s);return e.next??(a?c.path(en(t+n)):void 0)}let[ec,ed]=(0,E.useState)(null),eu=(0,E.useRef)(!1),em=(0,z.usePlanGate)();async function ex(t,s){let a=D,l=s?P:void 0,i=(l||a.length>1e3)&&!await em("connections.exportRows",Math.max(a.length,1001))?1e3:eX;eu.current=!1,ed({read:a.length});try{let s,o,m,p,x;for(;l&&a.length<i&&!eu.current;){let t=await M.connectionsApi.get(e.id,l,u);if(t.error)throw Error(t.error);let s=c.rows(t.body),n=a.length;a=[...a,...s.rows],l=s.rows.length?eo(s,n,F):void 0,ed({read:a.length})}let h=function(e){let t=[];for(let e of ev)t.push({name:e,label:ee(e)??e,of:t=>eZ(t,e)}),O(e)&&t.push({name:r(e),label:`${ee(e)??e} (name)`,of:t=>t[r(e)]});return{names:t.map(e=>e.name),labels:t.map(e=>e.label),rows:e.map(e=>t.map(t=>{let s;return Array.isArray(s=t.of(e))?s.map(e=>el(e)).join("; "):"number"==typeof s&&Number.isFinite(s)?s:el(s)}))}}(a.slice(0,i)),f=n.label??n.name;(0,eT.downloadBlob)((s=new Date,o=e=>String(e).padStart(2,"0"),m=f.replace(/[\\/:*?"<>|]+/g," ").replace(/\s+/g," ").trim().slice(0,60)||"export",`${m} ${s.getFullYear()}-${o(s.getMonth()+1)}-${o(s.getDate())} ${o(s.getHours())}${o(s.getMinutes())}.${t}`),"csv"===t?(p=e=>{let t=String(e);return/[",\r\n]/.test(t)||/^\s|\s$/.test(t)?`"${t.replace(/"/g,'""')}"`:t},x=[h.names,...h.rows].map(e=>e.map(p).join(",")),new Blob([`\uFEFF${x.join("\r\n")}\r
|
|
2
|
+
`],{type:"text/csv;charset=utf-8"})):(0,eO.xlsxBook)([{name:f,rows:[h.labels.map(e=>({v:e,s:eO.S.header})),...h.rows.map(e=>e.map(e=>({v:e})))]}]));let b=eu.current?" — stopped before the end":l||a.length>i?` — the first ${i.toLocaleString()}; narrow it with conditions for the rest`:"";d(`Exported ${h.rows.length.toLocaleString()} ${1===h.rows.length?"record":"records"} as ${"csv"===t?"CSV":"Excel"}${b}`,"success")}catch(e){d(e instanceof Error?e.message:"Could not export","error")}finally{ed(null)}}async function eh(t){V(!0),Q(null);let s=t??c.path(en());t||(l(s),G(null));try{let n=await M.connectionsApi.get(e.id,s,u);if(!t&&n.error&&C&&L&&/builtin\.?df|builtin function/i.test(n.error)){let t=await ea();if(t.length){T(e=>[...new Set([...e,...t])]);let s=c.path({...en(),names:!0,noNames:[...new Set([...R,...t])]});l(s),n=await M.connectionsApi.get(e.id,s,u)}}if(K(n),n.error){Q([n.error,n.hint].filter(Boolean).join(" — ")),t||U([]);return}let a=c.rows(n.body),i=t?D.length:0;U(e=>t?[...e,...a.rows]:a.rows);let r=t?F:a.count;if(t||q(a.count),!t&&$&&c.countPath){let t=await M.connectionsApi.get(e.id,c.countPath(en()),u).catch(()=>null),s=Number(t?.body?.totalSize);t&&!t.error&&Number.isFinite(s)&&q(r=s)}_(eo(a,i,r))}catch(e){Q(e instanceof Error?e.message:"Could not read the records")}finally{V(!1)}}let ef=(0,E.useRef)(null!=(0,eR.recall)(`${o}:answer`));(0,E.useEffect)(()=>{ef.current||eh()},[]);let[eb]=e_(),ej=eW(n.properties.filter(e=>e.filterable),eb),ev=p.length?p:m.filter(e=>D.some(t=>e in t)),eN=e=>({value:e.name,label:e.label??e.name,hint:e.label&&e.label!==e.name?e.name:void 0,text:`${e.name} ${e.label??""}`}),ek="rounded-md border border-line bg-panel-2 px-2.5 py-1 text-xs text-ink",ew="number"!=typeof N||eV.some(e=>e.value===String(N))?eV:[{value:String(N),label:`${N} rows`},...eV];return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsxs)("div",{className:"space-y-2 border-b border-line px-4 py-3 lg:px-6",children:[null===b?h.map((e,s)=>{var n;return(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"w-12 text-xs text-mute",children:0===s?"Where":"and"}),(0,t.jsx)(eg.Select,{label:`Condition ${s+1} field`,value:e.field,onChange:e=>f(t=>t.map((t,n)=>n===s?{...t,field:e,byName:!!X(e)?.ref||void 0}:t)),options:ej.map(eN),minWidth:320,className:`${ek} max-w-[22rem]`}),X(e.field)?.ref?(0,t.jsx)(eg.Select,{label:`Condition ${s+1} compares`,value:e.byName?"name":"id",onChange:e=>f(t=>t.map((t,n)=>n===s?{...t,byName:"name"===e||void 0}:t)),options:[{value:"name",label:"its name"},{value:"id",label:"its ID"}],className:ek}):null,(0,t.jsx)(eg.Select,{label:`Condition ${s+1} operator`,value:e.op,onChange:e=>f(t=>t.map((t,n)=>n===s?{...t,op:e}:t)),options:eM,className:ek}),(0,t.jsx)("input",{"aria-label":`Condition ${s+1} value`,value:e.value,onChange:e=>f(t=>t.map((t,n)=>n===s?{...t,value:e.target.value}:t)),onKeyDown:e=>"Enter"===e.key&&void eh(),placeholder:e.byName?"name, e.g. Acme":(n=X(e.field)?.type)?/Date/.test(n)?"2024-01-31":"Edm.Boolean"===n?"true or false":/Int|Decimal|Double|Single|Byte/.test(n)?"a number":"text":"",className:"input w-48 py-1 text-xs"}),(0,t.jsx)("button",{type:"button","aria-label":`Remove condition ${s+1}`,onClick:()=>f(e=>e.filter((e,t)=>t!==s)),className:"rounded p-1 text-mute hover:text-bad",children:(0,t.jsx)(I.X,{size:14})})]},s)}):(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 text-xs text-mute",children:["Filter as text (",c.filterLabel,")",(0,t.jsx)("button",{type:"button",className:"text-accent hover:underline",onClick:()=>g(null),children:"Use conditions instead"})]}),(0,t.jsx)("textarea",{"aria-label":"Filter as text",value:b,onChange:e=>g(e.target.value),rows:2,spellCheck:!1,className:"input font-mono text-xs"})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[null===b?(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>f(e=>[...e,{field:ej[0]?.name??"",op:"eq",value:"",...ej[0]?.ref?{byName:!0}:{}}]),disabled:!ej.length,children:[(0,t.jsx)(k.Plus,{size:13}),"Condition"]}):null,(0,t.jsx)(e2,{schema:s,set:n,value:p,onChange:x,onNeed:i}),(0,t.jsx)(eg.Select,{label:"Sort by",value:j.field,onChange:e=>v(t=>({...t,field:e})),className:ek,minWidth:320,buttonContent:j.field?`Sort: ${ee(j.field)??j.field}`:"No sorting",options:[{value:"",label:"No sorting"},...eW(n.properties.filter(e=>e.sortable),eb).map(eN)]}),j.field?(0,t.jsx)("button",{type:"button",className:"rounded p-1 text-mute hover:text-ink","aria-label":j.desc?"Sorted Z to A — sort A to Z":"Sorted A to Z — sort Z to A",onClick:()=>v(e=>({...e,desc:!e.desc})),children:j.desc?(0,t.jsx)(er,{size:15}):(0,t.jsx)(ei,{size:15})}):null,null===b?(0,t.jsx)("button",{type:"button",className:"text-xs text-mute hover:text-ink",onClick:()=>g(es),title:`See and edit the ${c.filterLabel} the conditions make — for or, brackets and functions`,children:"Filter as text"}):null,(0,t.jsxs)("span",{className:"ml-auto flex flex-wrap items-center gap-3",children:[(0,t.jsx)(eg.Select,{label:"Rows",value:String(N),onChange:e=>w("all"===e?"all":Number(e)),options:ew,className:ek,minWidth:170}),C?(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-mute",title:"Lookups (a sales rep, a customer…) hold an internal ID. Ask NetSuite for the name of each record too — BUILTIN.DF — shown next to its ID. Turn off for faster, raw queries.",children:[(0,t.jsx)("input",{type:"checkbox",className:"accent-[var(--accent)]",checked:L,onChange:e=>A(e.target.checked)}),"Names for IDs"]}):null,(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-mute",title:"Ask for the total number of matching records too ($inlinecount in OData v2, $count in v4)",children:[(0,t.jsx)("input",{type:"checkbox",className:"accent-[var(--accent)]",checked:$,onChange:e=>S(e.target.checked)}),"Total count"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-primary py-1 text-xs",onClick:()=>void eh(),disabled:H,children:[H?(0,t.jsx)(y.Loader2,{size:13,className:"animate-spin"}):(0,t.jsx)(ep.Play,{size:13}),"Run"]})]})]})]}),Z?(0,t.jsx)("p",{role:"alert",className:"mx-4 mt-3 rounded-md border border-bad/40 bg-bad/10 px-3 py-2 text-sm text-ink lg:mx-6",children:Z}):null,(0,t.jsxs)("div",{className:"flex min-h-0 flex-1",children:[(0,t.jsx)("div",{className:"min-h-0 min-w-0 flex-1 overflow-auto",children:D.length?(0,t.jsxs)("table",{className:"w-max min-w-full border-collapse text-[13px]",children:[(0,t.jsx)("thead",{className:"sticky top-0 z-10 bg-panel-2",children:(0,t.jsx)("tr",{children:ev.map(e=>(0,t.jsxs)("th",{scope:"col",className:"border-b border-line px-3 py-1.5 text-left align-bottom font-medium whitespace-nowrap text-ink",children:[ee(e)??e,ee(e)&&ee(e)!==e?(0,t.jsx)("span",{className:"block font-mono text-[11px] font-normal text-mute",children:e}):null]},e))})}),(0,t.jsx)("tbody",{children:D.map((e,s)=>(0,t.jsx)("tr",{onClick:()=>G(s),"aria-selected":Y===s,className:`cursor-pointer ${Y===s?"bg-accent-dim/60":"hover:bg-panel-2"}`,children:ev.map(s=>{let n=eZ(e,s);if(Array.isArray(n))return(0,t.jsx)("td",{className:"border-b border-line px-3 py-1 text-xs",children:(0,t.jsx)("span",{className:"rounded bg-panel-2 px-1.5 py-0.5 text-mute",children:1===n.length?"1 item":`${n.length} items`})},s);let a=el(n),l=O(s)?e[r(s)]:void 0;return null!=l&&""!==l&&""!==a?(0,t.jsxs)("td",{className:"max-w-[22rem] truncate border-b border-line px-3 py-1 text-xs text-ink",title:`${el(l)} — ID ${a}`,children:[el(l)," ",(0,t.jsxs)("span",{className:"font-mono text-mute",children:["· ",a]})]},s):(0,t.jsx)("td",{className:"max-w-[22rem] truncate border-b border-line px-3 py-1 font-mono text-xs text-ink",title:a.length>40?a:void 0,children:a},s)})},s))})]}):H||Z?null:(0,t.jsx)("p",{className:"px-6 py-8 text-sm text-mute",children:"No records match."})}),null!==Y&&D[Y]?(0,t.jsx)(eG,{row:D[Y],index:Y,onClose:()=>G(null)}):null]}),(0,t.jsxs)("footer",{className:"flex flex-wrap items-center gap-3 border-t border-line px-4 py-2 text-xs text-mute lg:px-6",children:[(0,t.jsxs)("span",{children:[D.length.toLocaleString()," ",void 0!==F?`of ${F.toLocaleString()} `:"",1===D.length?"record":"records",W?` \xb7 ${W.ms} ms`:""]}),P?(0,t.jsx)("button",{type:"button",className:"btn btn-secondary py-0.5 text-xs",onClick:()=>void eh(P),disabled:H,children:"Load more"}):null,D.length?(0,t.jsx)(e0,{loaded:D.length,total:P?F:D.length,more:!!P,busy:ec,onExport:(e,t)=>void ex(e,t),onStop:()=>eu.current=!0}):null,W?(0,t.jsx)(e1,{url:W.url,className:"ml-auto"}):null]})]})}let eY="apitestcenter-record-panel-width";function eG({row:e,index:s,onClose:n}){let[a,l]=(0,E.useState)(420);return(0,E.useEffect)(()=>{try{let e=Number(localStorage.getItem(eY));e>=260&&l(e)}catch{}},[]),(0,t.jsxs)("aside",{"aria-label":`Record ${s+1}`,style:{width:a},className:"relative flex shrink-0 flex-col border-l border-line bg-panel",children:[(0,t.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Drag to resize the record",onPointerDown:function(e){e.preventDefault();let t=Number(document.documentElement.style.zoom)||1,s=e.clientX,n=a,i=e=>{l(n=Math.max(260,Math.min(window.innerWidth/t-360,a+(s-e.clientX)/t)))},r=()=>{window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",r);try{localStorage.setItem(eY,String(Math.round(n)))}catch{}};window.addEventListener("pointermove",i),window.addEventListener("pointerup",r)},className:"absolute inset-y-0 -left-1 z-10 w-2 cursor-col-resize hover:bg-accent/30"}),(0,t.jsxs)("header",{className:"flex items-center gap-2 border-b border-line px-3 py-2",children:[(0,t.jsxs)("h3",{className:"flex-1 text-sm font-medium text-ink",children:["Record ",s+1]}),(0,t.jsx)("button",{type:"button",className:"rounded p-1 text-mute hover:text-ink",onClick:()=>void navigator.clipboard.writeText(JSON.stringify(e,null,2)),"aria-label":"Copy as JSON",title:"Copy as JSON",children:(0,t.jsx)(ed.Copy,{size:14})}),(0,t.jsx)("button",{type:"button",className:"rounded p-1 text-mute hover:text-ink",onClick:n,"aria-label":"Close the record",children:(0,t.jsx)(I.X,{size:14})})]}),(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-auto p-3 font-mono text-xs",children:(0,t.jsx)(eJ,{value:e})})]})}function eJ({value:e}){let s=Array.isArray(e)?e.map((e,t)=>[String(t+1),e]):Object.entries(e);return(0,t.jsx)("ul",{className:"space-y-0.5",children:s.map(([n,a])=>a&&"object"==typeof a?(0,t.jsx)("li",{children:(0,t.jsxs)("details",{open:Array.isArray(e)||s.length<8,children:[(0,t.jsxs)("summary",{className:"cursor-pointer text-ink",children:[(0,t.jsx)("span",{className:"text-accent",children:n})," ",(0,t.jsx)("span",{className:"text-mute",children:Array.isArray(a)?`${a.length} ${1===a.length?"item":"items"}`:""})]}),(0,t.jsx)("div",{className:"ml-3 border-l border-line pl-2",children:(0,t.jsx)(eJ,{value:a})})]})},n):(0,t.jsxs)("li",{className:"grid grid-cols-[minmax(0,40%)_minmax(0,1fr)] gap-3",children:[(0,t.jsx)("span",{className:"truncate text-mute",title:n,children:n}),(0,t.jsx)("span",{className:"min-w-0 break-words whitespace-pre-wrap text-ink",children:el(a)})]},n))})}let eX=5e4;function e0({loaded:e,total:s,more:n,busy:a,onExport:l,onStop:i}){let[r,o]=(0,E.useState)(!1),[c,d]=(0,E.useState)(!1),u=(0,E.useRef)(null);if(a)return(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(y.Loader2,{size:13,className:"animate-spin text-accent","aria-hidden":!0}),(0,t.jsxs)("span",{role:"status",children:["Reading ",a.read.toLocaleString(),void 0!==s?` of ${Math.min(s,eX).toLocaleString()}`:"","…"]}),(0,t.jsx)("button",{type:"button",className:"btn btn-secondary py-0.5 text-xs",onClick:i,children:"Stop"})]});let m=e=>{o(!1),l(e,n&&c)};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{ref:u,type:"button",className:"btn btn-secondary py-0.5 text-xs",onClick:()=>o(!0),children:[(0,t.jsx)(eu.Download,{size:12}),"Export"]}),(0,t.jsx)(ef.Popover,{anchor:u,open:r,onClose:()=>o(!1),label:"Export records",width:300,children:(0,t.jsxs)("div",{className:"space-y-2.5 p-3 text-sm",children:[n?(0,t.jsxs)("fieldset",{className:"space-y-1.5",children:[(0,t.jsx)("legend",{className:"mb-1 text-xs text-mute",children:"Which records"}),(0,t.jsxs)("label",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"radio",name:"export-which",checked:!c,onChange:()=>d(!1)}),"The ",e.toLocaleString()," loaded"]}),(0,t.jsxs)("label",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"radio",name:"export-which",checked:c,onChange:()=>d(!0)}),"All ",void 0!==s?`${s.toLocaleString()} `:"","matching",void 0!==s&&s>eX?(0,t.jsxs)("span",{className:"text-xs text-mute",children:["(the first ",eX.toLocaleString(),")"]}):null]})]}):(0,t.jsxs)("p",{className:"text-xs text-mute",children:[e.toLocaleString()," ",1===e?"record":"records",", with the columns shown."]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary flex-1 py-1 text-xs",onClick:()=>m("csv"),children:"CSV"}),(0,t.jsx)("button",{type:"button",className:"btn btn-primary flex-1 py-1 text-xs",onClick:()=>m("xlsx"),children:"Excel"})]})]})})]})}function e1({url:e,className:s=""}){let n=(0,ey.useToast)(),a=(0,eA.readableUrl)(e);return(0,t.jsxs)("span",{className:`flex min-w-0 items-center gap-2 ${s}`,children:[(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-[11px] text-mute",title:a,children:a}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary shrink-0 py-0.5 text-xs",onClick:()=>void navigator.clipboard.writeText(a).then(()=>n("Copied the URL","success"),()=>n("Could not copy","error")),children:[(0,t.jsx)(ed.Copy,{size:12}),"Copy URL"]})]})}function e2({schema:e,set:s,value:n,onChange:a,onNeed:l}){let[i,r]=(0,E.useState)(!1),[o,c]=(0,E.useState)(""),[d,u]=(0,E.useState)(!1),[m,p]=(0,E.useState)(new Set),[x,f]=(0,E.useState)("fields"),[b,g]=e_(),j=(0,E.useRef)(null),v=s.properties.map(e=>e.name),N=o.trim().toLowerCase(),k=(e,t)=>(!d||n.includes(t))&&(!N||t.toLowerCase().includes(N)||(e.label??"").toLowerCase().includes(N)),w=eW(s.properties,b).filter(e=>k(e,e.name)),S=eK(s.navigation,b).map(t=>({link:t,target:e.entitySets.find(e=>e.name===t.target)})).map(({link:e,target:t})=>({link:e,target:t,fields:eW(t?.properties??[],b).filter(t=>k(t,`${e.name}/${t.name}`)||N&&e.name.toLowerCase().includes(N)&&(!d||n.includes(`${e.name}/${t.name}`)))})).filter(({link:e,fields:t})=>!N&&!d||t.length>0||!d&&e.name.toLowerCase().includes(N)),C=e=>{if(n.includes(e))return a(n.filter(t=>t!==e));a([...v.filter(t=>t===e||n.includes(t)),...n.filter(e=>e.includes("/")),...e.includes("/")?[e]:[]])},L=n.filter(e=>!e.includes("/")).length,A=n.length-L;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{ref:j,type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>r(!0),"aria-label":n.length?`Columns, ${n.length} picked`:"Columns, all fields",children:[(0,t.jsx)(ec.Columns3,{size:13}),n.length?`Columns ${n.length}`:"All fields"]}),(0,t.jsx)(ef.Popover,{anchor:j,open:i,onClose:()=>r(!1),label:"Columns",width:420,children:(0,t.jsxs)("div",{className:"space-y-2 p-2",children:[s.navigation.length?(0,t.jsx)(eb.Segmented,{label:"Show",value:x,onChange:f,options:[{value:"fields",label:`Fields ${v.length}${L?` \xb7 ${L} picked`:""}`},{value:"related",label:`Related ($expand) ${s.navigation.length}${A?` \xb7 ${A} picked`:""}`}]}):null,(0,t.jsxs)("label",{className:"relative block",children:[(0,t.jsx)("span",{className:"sr-only",children:"fields"===x?"Find a field":"Find a link or its field"}),(0,t.jsx)($.Search,{size:13,className:"pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-mute","aria-hidden":!0}),(0,t.jsx)("input",{autoFocus:!0,value:o,onChange:e=>c(e.target.value),placeholder:"fields"===x?`Search ${v.length} fields`:`Search ${s.navigation.length} links and their fields`,className:"input py-1 pr-24 pl-7 text-xs"}),(0,t.jsx)("span",{className:"absolute top-1/2 right-2 -translate-y-1/2",children:(0,t.jsx)(eH,{order:b,onChange:g})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 px-1 text-xs",children:[(0,t.jsx)("span",{className:"text-mute",children:n.length?`${n.length} picked — only these are asked for`:"All fields — pick some to ask for only those"}),(0,t.jsxs)("span",{className:"ml-auto flex shrink-0 gap-3",children:["fields"===x&&N&&w.some(e=>!n.includes(e.name))?(0,t.jsx)("button",{type:"button",className:"text-accent hover:underline",onClick:()=>a([...v.filter(e=>n.includes(e)||w.some(t=>t.name===e)),...n.filter(e=>e.includes("/"))]),children:"Pick these"}):null,(0,t.jsx)("button",{type:"button",className:"text-accent hover:underline disabled:text-mute disabled:no-underline",disabled:!n.length,onClick:()=>(a([]),u(!1)),children:"Clear"})]})]}),n.length?(0,t.jsxs)("label",{className:"flex items-center gap-1.5 px-1 text-xs text-mute",children:[(0,t.jsx)("input",{type:"checkbox",className:"accent-[var(--accent)]",checked:d,onChange:e=>u(e.target.checked)}),"Show picked only"]}):null,(0,t.jsx)("div",{className:"max-h-96 space-y-0.5 overflow-y-auto",children:"fields"===x?(0,t.jsxs)("ul",{"aria-label":"Fields",className:"space-y-0.5",children:[w.map(e=>(0,t.jsx)(e3,{p:e,checked:n.includes(e.name),onToggle:()=>C(e.name)},e.name)),w.length?null:(0,t.jsxs)("li",{className:"px-2 py-1 text-xs text-mute",children:["Nothing matches."," ",N&&S.length?(0,t.jsxs)("button",{type:"button",className:"text-accent hover:underline",onClick:()=>f("related"),children:[S.length," in Related"]}):null]})]}):(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"px-2 pb-1 text-[11px] text-mute",children:"Open a link to pick fields of the object it leads to — they come as columns of their own."}),(0,t.jsxs)("ul",{"aria-label":"Related",className:"space-y-0.5",children:[S.map(({link:e,target:s,fields:a})=>{let i=m.has(e.name)||!!N||d,r=n.filter(t=>t.startsWith(`${e.name}/`)).length;return(0,t.jsxs)("li",{children:[(0,t.jsxs)("button",{type:"button","aria-expanded":i,disabled:!s,onClick:()=>{s?.described===!1&&l(s.name),p(t=>new Set(t.has(e.name)?[...t].filter(t=>t!==e.name):[...t,e.name]))},className:"flex w-full items-center gap-1.5 rounded px-2 py-1 text-left hover:bg-panel-2 disabled:opacity-50",title:s?void 0:"This link leads to an object the service doesn't list",children:[(0,t.jsx)(h.ChevronRight,{size:13,className:`shrink-0 text-mute transition-transform ${i?"rotate-90":""}`,"aria-hidden":!0}),(0,t.jsx)("span",{className:"font-mono text-xs text-ink",children:e.name}),(0,t.jsxs)("span",{className:"min-w-0 truncate text-[11px] text-mute",children:["→ ",s?.label??e.target??"?"," (",e.many?"many":"one",")"]}),r?(0,t.jsx)("span",{className:"ml-auto shrink-0 rounded bg-accent-dim px-1.5 text-[10px] text-ink",children:r}):null]}),i&&s?.described===!1?(0,t.jsxs)("p",{className:"ml-6 flex items-center gap-1.5 py-1 text-[11px] text-mute",children:[(0,t.jsx)(y.Loader2,{size:11,className:"animate-spin"})," Reading its fields…"]}):null,i&&s?(0,t.jsx)("ul",{"aria-label":`Fields of ${e.name}`,className:"ml-4 space-y-0.5 border-l border-line pl-1",children:a.map(s=>(0,t.jsx)(e3,{p:s,checked:n.includes(`${e.name}/${s.name}`),onToggle:()=>C(`${e.name}/${s.name}`)},s.name))}):null]},e.name)}),S.length?null:(0,t.jsx)("li",{className:"px-2 py-1 text-xs text-mute",children:"Nothing matches."})]}),(0,t.jsx)("p",{className:"px-2 pt-1.5 text-[11px] text-mute",children:"One level of links for now; deeper levels come later."})]})}),0===L&&n.length?(0,t.jsx)("p",{className:"px-1 text-[11px] text-mute",children:"Only linked fields picked: the service sends just those (and the keys it always sends)."}):null]})})]})}function e3({p:e,checked:s,onToggle:n}){return(0,t.jsx)("li",{children:(0,t.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 rounded px-2 py-1 hover:bg-panel-2",children:[(0,t.jsx)("input",{type:"checkbox",className:"mt-0.5 accent-[var(--accent)]",checked:s,onChange:n,"aria-label":e.label??e.name}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm break-words text-ink",children:e.label??e.name}),e.label&&e.label!==e.name?(0,t.jsx)("span",{className:"block font-mono text-[11px] break-all text-mute",children:e.name}):null]}),(0,t.jsx)("span",{className:"shrink-0 font-mono text-[10px] text-mute",children:eL(e)})]})})}function e5({schema:e,set:s,onOpenObject:n,onNeed:a}){let[l,i]=(0,E.useState)(""),[r,o]=(0,E.useState)(null),[c,d]=e_(),u=l.trim().toLowerCase(),m=eW(s.properties,c).filter(e=>!u||e.name.toLowerCase().includes(u)||(e.label??"").toLowerCase().includes(u)||e.type.toLowerCase().includes(u)),p=eK(s.navigation,c).filter(e=>!u||e.name.toLowerCase().includes(u)||(e.target??"").toLowerCase().includes(u));return(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-3 lg:px-6",children:[(0,t.jsxs)("div",{className:"mb-3 flex items-center gap-3",children:[(0,t.jsxs)("label",{className:"relative block w-full max-w-sm",children:[(0,t.jsx)("span",{className:"sr-only",children:"Find a field"}),(0,t.jsx)($.Search,{size:14,className:"pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-mute","aria-hidden":!0}),(0,t.jsx)("input",{value:l,onChange:e=>i(e.target.value),placeholder:"Find a field or link",className:"input py-1 pl-8 text-sm"})]}),(0,t.jsx)(eH,{order:c,onChange:d})]}),(0,t.jsx)(e4,{fields:m}),p.length?(0,t.jsxs)("div",{className:"mt-5",children:[(0,t.jsx)("h3",{className:"text-xs font-medium text-mute",children:"Links to other objects ($expand) — open one to see its fields"}),(0,t.jsx)("ul",{className:"mt-1.5 space-y-0.5 text-[13px]",children:p.map(s=>{let l=e.entitySets.find(e=>e.name===s.target),i=r===s.name;return(0,t.jsxs)("li",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button","aria-expanded":i,disabled:!l,onClick:()=>{l?.described===!1&&a(l.name),o(i?null:s.name)},className:"flex min-w-0 items-center gap-1.5 rounded px-1 py-0.5 text-left font-mono text-xs text-ink hover:bg-panel-2 disabled:opacity-60",children:[(0,t.jsx)(h.ChevronRight,{size:13,className:`shrink-0 text-mute transition-transform ${i?"rotate-90":""}`,"aria-hidden":!0}),s.name," ",(0,t.jsxs)("span",{className:"text-mute",children:["→ ",s.target??"?"," (",s.many?"many":"one",")"]})]}),l?(0,t.jsxs)("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>n(l.name),children:["Open ",l.label??l.name]}):null]}),i&&l?(0,t.jsx)("div",{className:"mt-1 mb-2 ml-5 border-l border-line pl-3",children:(0,t.jsx)(e4,{fields:eW(l.properties,c)})}):null]},s.name)})})]}):null]})}function e4({fields:e}){return(0,t.jsxs)("table",{className:"w-full border-collapse text-[13px]",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"text-left text-xs text-mute",children:[(0,t.jsx)("th",{scope:"col",className:"border-b border-line py-1.5 pr-3 font-medium",children:"Field"}),(0,t.jsx)("th",{scope:"col",className:"border-b border-line py-1.5 pr-3 font-medium",children:"Label"}),(0,t.jsx)("th",{scope:"col",className:"border-b border-line py-1.5 pr-3 font-medium",children:"Type"}),(0,t.jsx)("th",{scope:"col",className:"border-b border-line py-1.5 font-medium",children:"Notes"})]})}),(0,t.jsx)("tbody",{children:e.map(e=>(0,t.jsxs)("tr",{children:[(0,t.jsxs)("td",{className:"border-b border-line py-1.5 pr-3 font-mono text-xs text-ink",children:[e.key?(0,t.jsx)(em.KeyRound,{size:11,className:"mr-1 inline align-[-1px] text-accent","aria-label":"Key"}):null,e.name]}),(0,t.jsx)("td",{className:"border-b border-line py-1.5 pr-3 text-ink",children:e.label??""}),(0,t.jsxs)("td",{className:"border-b border-line py-1.5 pr-3 font-mono text-xs text-mute",children:[eL(e),e.maxLength?`(${e.maxLength})`:""]}),(0,t.jsx)("td",{className:"border-b border-line py-1.5 text-xs text-mute",children:[e.key?"key":"",e.ref?"lookup — name with BUILTIN.DF":"",!e.nullable?"required":"",!e.filterable?"can't filter":"",!e.sortable?"can't sort":""].filter(Boolean).join(" · ")})]},e.name))})]})}function e6({connection:e,schema:s,path:n,onPath:a,onOpenObject:l,memoryKey:i}){var r,o;let{vars:c}=(0,B.useWorkspace)(),[d,u]=(0,eR.useRemembered)(`${i}:answer`,null),[m,p]=(0,E.useState)(!1),[x,h]=(0,E.useState)(null);async function f(){p(!0),h(null);try{u(await M.connectionsApi.get(e.id,n,c))}catch(e){h(e instanceof Error?e.message:"Could not run it")}finally{p(!1)}}let b=eE(s),g=n.trim()?b.parse(n,e.baseUrl):null,j=b.language?function(e){let t=/[?&]q=([^&]*)/.exec(e);if(!t)return"";try{return decodeURIComponent(t[1].replace(/\+/g," "))}catch{return t[1]}}(n):n,v=d?"string"==typeof d.body?d.body:JSON.stringify(d.body,null,2):"";return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 px-4 py-3 lg:px-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"shrink-0 font-mono text-xs text-mute",title:e.baseUrl,children:b.language??"GET …/"}),(0,t.jsx)("input",{"aria-label":"Query",value:j,onChange:e=>{let t;return t=e.target.value,a(b.pathForText?b.pathForText(t,n):t)},onKeyDown:e=>"Enter"===e.key&&void f(),className:"input min-w-0 flex-1 font-mono text-[13px]",spellCheck:!1}),(0,t.jsxs)("button",{type:"button",className:"btn btn-primary py-1.5 text-sm",onClick:()=>void f(),disabled:m||!n.trim(),children:[m?(0,t.jsx)(y.Loader2,{size:14,className:"animate-spin"}):(0,t.jsx)(ep.Play,{size:14}),"Run"]})]}),(0,t.jsxs)("p",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-mute",children:["SuiteQL"===b.language?(0,t.jsxs)("span",{children:["Any SuiteQL query: ",(0,t.jsx)("span",{className:"font-mono",children:"SELECT … FROM … WHERE … ORDER BY …"})," — rows come ","1,000"," a page at most."]}):"SOQL"===b.language?(0,t.jsxs)("span",{children:["Any SOQL query: ",(0,t.jsx)("span",{className:"font-mono",children:"SELECT … FROM … WHERE … ORDER BY … LIMIT …"}),", parent fields like ",(0,t.jsx)("span",{className:"font-mono",children:"Owner.Name"}),"."]}):(0,t.jsxs)("span",{children:["Any OData query under the service root: ",(0,t.jsx)("span",{className:"font-mono",children:"$select"}),", ",(0,t.jsx)("span",{className:"font-mono",children:"$filter"}),", ",(0,t.jsx)("span",{className:"font-mono",children:"$expand"}),", ",(0,t.jsx)("span",{className:"font-mono",children:"$orderby"}),", ",(0,t.jsx)("span",{className:"font-mono",children:"$top"}),"."]}),g?(0,t.jsx)("button",{type:"button",className:"text-accent hover:underline",onClick:()=>l(g.entitySet,g),children:"Fill Records from this"}):null]}),n.trim()?(0,t.jsx)(e1,{url:/^https?:\/\//i.test(n.trim())?n.trim():(r=e.baseUrl,o=n.trim(),`${r.replace(/\/+$/,"")}/${o.replace(/^\/+/,"")}`)}):null,x?(0,t.jsx)("p",{role:"alert",className:"text-sm text-bad",children:x}):null,d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("p",{className:"text-xs",children:[(0,t.jsx)("span",{className:`font-mono ${d.status>=200&&d.status<300?"text-ok":"text-bad"}`,children:d.status||"ERR"}),(0,t.jsxs)("span",{className:"text-mute",children:[" · ",d.ms," ms"]}),d.error?(0,t.jsxs)("span",{className:"text-ink",children:[" · ",[d.error,d.hint].filter(Boolean).join(" — ")]}):null]}),(0,t.jsx)("pre",{className:"min-h-0 flex-1 overflow-auto rounded-md border border-line bg-panel-2 p-3 font-mono text-xs text-ink",children:v.length>3e5?`${v.slice(0,3e5)}
|
|
3
|
+
…`:v})]}):null]})}var e7=e.i(39170),e8=e.i(17847);function e9({onAdd:e}){return(0,t.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-16 text-center",children:[(0,t.jsx)("div",{className:"grid h-12 w-12 place-items-center rounded-full bg-accent-dim text-accent",children:(0,t.jsx)(N.Plug,{size:22,strokeWidth:1.75,"aria-hidden":!0})}),(0,t.jsx)("h2",{className:"mt-4 text-base font-medium text-ink",children:"Connect a system"}),(0,t.jsxs)("p",{className:"mt-2 max-w-md text-sm text-mute",children:["Set a system up once — its address and sign-in — and every request that starts with its variable, like ","{{successFactors}}","/User, uses it. For SAP SuccessFactors and other OData services, browse objects, fields and records too."]}),(0,t.jsx)("div",{className:"mt-6 flex flex-wrap justify-center gap-2",children:(0,t.jsxs)("button",{type:"button",className:"btn btn-primary text-sm",onClick:e,children:[(0,t.jsx)(k.Plus,{size:14}),"Add connection"]})}),(0,t.jsxs)("p",{className:"mt-3 text-xs text-mute",children:["No system at hand? Pick ",(0,t.jsx)("span",{className:"text-ink",children:"Practice company"})," in Add connection."]})]})}function te({connection:e}){let s=/\/demo-api\/(odata|salesforce|netsuite)(\/|$)/.test(e.baseUrl)?g.FlaskConical:"successfactors"===e.kind?x:f;return(0,t.jsx)(s,{size:15,className:"shrink-0 text-accent","aria-hidden":!0})}function tt({connection:e,active:s,open:n,onToggle:l,onOpen:i,onEdit:r,onRefresh:o,onDelete:c,children:d}){let[u,m]=(0,E.useState)(!1),p=(0,E.useRef)(null),x=e.baseUrl;try{x=new URL(e.baseUrl).host}catch{}return(0,t.jsxs)("div",{className:"mb-1",children:[(0,t.jsxs)("div",{className:`group flex items-center gap-1 rounded-md pr-1 ${s?"bg-accent-dim":"hover:bg-panel-2"}`,children:[a.BROWSABLE_KINDS.includes(e.kind)?(0,t.jsx)("button",{type:"button","aria-label":n?`Hide the objects of ${e.name}`:`Show the objects of ${e.name}`,"aria-expanded":n,onClick:l,className:"ml-1 rounded p-0.5 text-mute hover:text-ink",children:(0,t.jsx)(h.ChevronRight,{size:14,className:`transition-transform ${n?"rotate-90":""}`})}):(0,t.jsx)("span",{className:"ml-1 w-[18px]"}),(0,t.jsxs)("button",{type:"button",onClick:i,"aria-current":s?"true":void 0,className:"flex min-w-0 flex-1 items-center gap-2 py-2 pr-2 pl-1 text-left",children:[(0,t.jsx)(te,{connection:e}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate text-sm text-ink",children:e.name}),(0,t.jsxs)("span",{className:"block truncate text-xs text-mute",children:[(0,t.jsx)("span",{className:"font-mono text-ink/80",children:`{{${e.variable}}}`})," · ",M.KIND_LABEL[e.kind]," · ",x]})]})]}),(0,t.jsx)("button",{ref:p,type:"button","aria-label":`Actions for ${e.name}`,onClick:()=>m(!0),className:"rounded p-1 text-mute opacity-60 group-hover:opacity-100 hover:text-ink focus:opacity-100",children:(0,t.jsx)(j.MoreHorizontal,{size:15})}),(0,t.jsxs)(ef.Popover,{anchor:p,open:u,onClose:()=>m(!1),label:`Actions for ${e.name}`,width:220,role:"menu",children:[(0,t.jsx)(e8.MenuItem,{icon:v.Pencil,label:"Edit",onSelect:()=>(m(!1),r())}),a.BROWSABLE_KINDS.includes(e.kind)?(0,t.jsx)(e8.MenuItem,{icon:w.RefreshCw,label:"Read objects again",onSelect:()=>(m(!1),i(),o())}):null,(0,t.jsx)(e8.MenuSeparator,{}),(0,t.jsx)(e8.MenuItem,{icon:S.Trash2,label:"Delete",danger:!0,onSelect:()=>(m(!1),c())})]})]}),d]})}function ts({sets:e,selected:s,onSelect:n}){let[a,l]=(0,E.useState)(""),i=(0,E.useMemo)(()=>{let t=a.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.label??"").toLowerCase().includes(t)):e},[e,a]);return(0,t.jsxs)("div",{className:"ml-4 border-l border-line py-1 pl-2",children:[e.length>8?(0,t.jsxs)("label",{className:"relative mb-1 block",children:[(0,t.jsx)("span",{className:"sr-only",children:"Find an object"}),(0,t.jsx)($.Search,{size:13,className:"pointer-events-none absolute top-1/2 left-2 -translate-y-1/2 text-mute","aria-hidden":!0}),(0,t.jsx)("input",{value:a,onChange:e=>l(e.target.value),placeholder:`Find among ${e.length} objects`,className:"input py-1 pl-7 text-xs"})]}):null,(0,t.jsxs)("ul",{"aria-label":"Objects",children:[i.map(e=>(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",onClick:()=>n(e.name),"aria-current":s===e.name?"true":void 0,className:`flex w-full items-baseline gap-2 rounded px-2 py-1 text-left ${s===e.name?"bg-accent-dim text-ink":"text-ink hover:bg-panel-2"}`,children:[(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:e.label&&e.label!==e.name?e.label:e.name}),e.label&&e.label!==e.name?(0,t.jsx)("span",{className:"max-w-[45%] shrink-0 truncate font-mono text-[11px] text-mute",children:e.name}):null]})},e.name)),i.length?null:(0,t.jsx)("li",{className:"px-2 py-1 text-xs text-mute",children:"Nothing matches."})]})]})}function tn({connection:e,schema:s}){let n=(0,C.useRouter)(),i=s?.schema.entitySets[0]?.name??"",r=a.BROWSABLE_KINDS.includes(e.kind)?s?.schema.suiteql?u(`SELECT * FROM ${i||"customer"}`,{top:10}):s?.schema.soql?`services/data/${s.schema.soql.apiVersion}/query?q=${encodeURIComponent(`SELECT Id FROM ${i||"Account"} LIMIT 10`)}`:i:"",o=s?.schema.suiteql?`{{${e.variable}}}/${l} { "q": "SELECT * FROM ${i||"customer"}" }`:`{{${e.variable}}}/${"salesforce"===e.kind?decodeURIComponent(r):r}`;return(0,t.jsxs)("div",{className:"max-w-2xl space-y-5 px-6 py-8 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium text-ink",children:e.name}),(0,t.jsx)("p",{className:"mt-0.5 font-mono text-xs break-all text-mute",children:e.baseUrl})]}),(0,t.jsxs)("div",{className:"rounded-lg border border-line p-4",children:[(0,t.jsx)("h3",{className:"font-medium text-ink",children:"Use it in any request"}),(0,t.jsxs)("p",{className:"mt-1 text-mute",children:["Start the address with ",(0,t.jsx)("span",{className:"font-mono text-ink",children:`{{${e.variable}}}`})," and leave ",(0,t.jsx)("span",{className:"text-ink",children:"Auth"})," on"," ",(0,t.jsx)("span",{className:"text-ink",children:"From folder or connection"})," (the default). The request is sent to ",e.baseUrl.replace(/^https?:\/\//,"")," with this connection's"," ","none"===e.settings.auth.authMode?"headers":"sign-in and headers"," — nothing to type again. Change the sign-in here once, and every such request follows."]}),(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("code",{className:"rounded bg-panel-2 px-2 py-1 font-mono text-xs text-ink",children:["GET ",o]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>eI(e,r,n),children:[(0,t.jsx)(b.ExternalLink,{size:13}),"New request"]})]})]}),s?(0,t.jsxs)("p",{className:"text-mute",children:[s.schema.entitySets.length," objects, OData ",s.schema.version,". Pick one on the left to see its records and fields.",(0,t.jsxs)("span",{className:"mt-2 block text-xs",children:["Read ",new Date(s.fetchedAt).toLocaleString()," · ⋯ → Read objects again, after the system changes."]})]}):null]})}e.s(["ConnectionsPage",0,function(){let e=(0,n.useColumnSplit)("connections"),l=(0,ey.useToast)(),i=(0,e7.useConfirm)(),{vars:r}=(0,B.useWorkspace)(),[o,c]=(0,E.useState)(null),[d,u]=(0,E.useState)(null),[m,p]=(0,eR.useRemembered)("connections:active",null),[x,h]=(0,eR.useRemembered)("connections:schema",null),[f,b]=(0,E.useState)(null),[g,j]=(0,E.useState)(!1),[v,N]=(0,eR.useRemembered)("connections:object",null),[w,$]=(0,eR.useRemembered)("connections:opened",{nonce:0}),S=(e,t)=>{N(e),$(e=>({query:t,nonce:e.nonce+1}))},[C,L]=(0,E.useState)(null),[A,R]=(0,eR.useRemembered)("connections:expanded",()=>new Set),T=(e,t)=>R(s=>{let n=new Set(s);return t??!n.has(e)?n.add(e):n.delete(e),n}),O=o?.find(e=>e.id===m)??null;async function I(e,t=!1){let s=o?.find(t=>t.id===e);if(!s||a.BROWSABLE_KINDS.includes(s.kind)){j(!0),b(null);try{let s=await M.connectionsApi.schema(e,r,t);h({id:e,...s}),t&&l(`Read again — ${s.schema.entitySets.length} objects`,"success")}catch(e){b(e instanceof Error?e.message:"Could not read what the service offers")}finally{j(!1)}}}(0,E.useEffect)(()=>{M.connectionsApi.list().then(e=>{c(e),p(t=>t??e[0]?.id??null)}).catch(e=>u(e instanceof Error?e.message:"Can't reach the engine"))},[]);let D=(0,E.useRef)(m);async function U(e){if(await i({title:`Delete ${e.name}?`,body:"The connection and its saved password are removed from this project. Nothing changes in the system itself.",confirmLabel:"Delete",tone:"danger"}))try{await M.connectionsApi.remove(e.id),c(t=>(t??[]).filter(t=>t.id!==e.id)),m===e.id&&p(null),l(`Deleted ${e.name}`,"success")}catch(e){l(e instanceof Error?e.message:"Could not delete","error")}}(0,E.useEffect)(()=>{D.current!==m&&(D.current=m,N(null)),b(null),m&&x?.id!==m&&(h(null),I(m))},[m,null===o]);let F=x?.id===m?x.schema.entitySets.find(e=>e.name===v):void 0,q=(0,E.useRef)(new Set);async function P(e){if(!(x?.schema.soql||x?.schema.suiteql)||q.current.has(`${x.id}/${e}`))return;let t=x.schema.entitySets.find(t=>t.name===e);if(!t||!1!==t.described)return;let s=`${x.id}/${e}`;q.current.add(s);try{let t=await M.connectionsApi.describe(x.id,e,r);h(e=>e&&e.id===x.id?{...e,schema:{...e.schema,entitySets:e.schema.entitySets.map(e=>e.name===t.name?t:e)}}:e)}catch(t){l(t instanceof Error?t.message:`Could not read the fields of ${e}`,"error")}finally{q.current.delete(s)}}return(0,E.useEffect)(()=>{F?.described===!1&&P(F.name)},[F?.name,F?.described]),(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsxs)("header",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b border-line bg-panel px-4 py-3 lg:px-6",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("h1",{className:"text-lg font-medium text-ink",children:"Connections"}),(0,t.jsx)("p",{className:"truncate text-xs text-mute",children:"Set a system up once — address and sign-in — and any request starting with its variable uses it. Browse OData systems' objects and records."})]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-primary py-1.5 text-sm",onClick:()=>L("new"),children:[(0,t.jsx)(k.Plus,{size:15}),"Add connection"]})]}),d?(0,t.jsxs)("div",{role:"alert",className:"m-6 rounded-md border border-bad/40 bg-bad/10 px-4 py-3 text-sm text-ink",children:[(0,t.jsx)("p",{className:"font-medium text-bad",children:"Can't reach the engine"}),(0,t.jsx)("p",{className:"mt-1",children:d})]}):null===o?(0,t.jsxs)("p",{className:"flex items-center gap-2 px-6 py-6 text-sm text-mute",children:[(0,t.jsx)(y.Loader2,{size:14,className:"animate-spin"})," Loading…"]}):0===o.length?(0,t.jsx)(e9,{onAdd:()=>L("new")}):(0,t.jsxs)("div",{ref:e.gridRef,style:e.gridStyle,className:"relative grid min-h-0 flex-1 overflow-y-auto lg:grid-cols-[minmax(16rem,20rem)_minmax(0,1fr)] lg:overflow-hidden",children:[(0,t.jsx)(s.Splitter,{label:"Objects list width",...e.splitter}),(0,t.jsx)("nav",{"aria-label":"Connections and their objects",className:"flex min-h-0 flex-col border-line lg:border-r",children:(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:o.map(e=>(0,t.jsx)(tt,{connection:e,active:e.id===m,open:A.has(e.id),onToggle:()=>{p(e.id),T(e.id)},onOpen:()=>{e.id===m?T(e.id):(p(e.id),T(e.id,!0))},onEdit:()=>L(e),onRefresh:()=>void I(e.id,!0),onDelete:()=>void U(e),children:e.id===m&&A.has(e.id)?g&&!x?(0,t.jsxs)("p",{className:"flex items-center gap-2 px-3 py-3 text-xs text-mute",children:[(0,t.jsx)(y.Loader2,{size:12,className:"animate-spin"})," Reading what it offers…"]}):f?(0,t.jsxs)("div",{role:"alert",className:"mx-2 my-2 rounded-md border border-bad/40 bg-bad/10 px-3 py-2 text-xs",children:[(0,t.jsx)("p",{className:"text-ink",children:f}),(0,t.jsx)("button",{type:"button",className:"mt-1.5 text-accent hover:underline",onClick:()=>void I(e.id,!0),children:"Try again"})]}):x?.id===e.id?(0,t.jsx)(ts,{sets:x.schema.entitySets,selected:v,onSelect:e=>S(e)}):null:null},e.id))})}),(0,t.jsx)("section",{"aria-label":"Object",className:"flex min-h-0 min-w-0 flex-col",children:O&&F&&x?!1===F.described?(0,t.jsxs)("p",{className:"flex items-center gap-2 px-6 py-8 text-sm text-mute",children:[(0,t.jsx)(y.Loader2,{size:14,className:"animate-spin"})," Reading the fields of ",F.label??F.name,"…"]}):(0,t.jsx)(eF,{memoryKey:`connections:${O.id}/${F.name}/${w.nonce}`,connection:O,schema:x.schema,set:F,initial:w.query,onOpenObject:S,onNeed:e=>void P(e)},`${O.id}/${F.name}/${w.nonce}`):O?(0,t.jsx)(tn,{connection:O,schema:x?.id===O.id?x:null}):null})]}),C?(0,t.jsx)(J,{editing:"new"===C?null:C,existing:o??[],onClose:()=>L(null),onSaved:e=>{c(t=>{let s=t??[];return s.some(t=>t.id===e.id)?s.map(t=>t.id===e.id?e:t):[...s,e]}),L(null),e.id===m?I(e.id,"new"!==C&&C.baseUrl!==e.baseUrl):p(e.id),"new"===C&&T(e.id,!0),l("new"===C?`Added ${e.name}`:`Saved ${e.name}`,"success")}}):null]})}],87946)}]);
|