apitestcenter 0.17.0 → 0.17.2
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/LICENSE.txt +2 -2
- package/README.md +1 -1
- package/dist/THIRD-PARTY-NOTICES-UI.txt +1 -1
- package/dist/THIRD-PARTY-NOTICES.txt +1 -1
- package/dist/cli.mjs +359 -354
- 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/0a88gfjsl2a31.css +3 -0
- package/dist/ui/_next/static/chunks/0wrod6xlhsv0m.js +3 -0
- package/dist/ui/_next/static/chunks/23_x0u07xh89v.js +123 -0
- package/dist/ui/_next/static/chunks/2nsf1ik-sgmcf.js +27 -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/0ed__sgjyhon8.css +0 -3
- package/dist/ui/_next/static/chunks/1wd-qahqqdfeq.js +0 -27
- package/dist/ui/_next/static/chunks/3r75fvzmnyvck.js +0 -123
- package/dist/ui/_next/static/chunks/40y4-vb2nag2l.js +0 -3
- /package/dist/ui/_next/static/{u2V4Oq6faI2f3slbxdtb5 → 0pb5ehfBVj_I-XduzZBR3}/_buildManifest.js +0 -0
- /package/dist/ui/_next/static/{u2V4Oq6faI2f3slbxdtb5 → 0pb5ehfBVj_I-XduzZBR3}/_clientMiddlewareManifest.js +0 -0
- /package/dist/ui/_next/static/{u2V4Oq6faI2f3slbxdtb5 → 0pb5ehfBVj_I-XduzZBR3}/_ssgManifest.js +0 -0
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,93639,e=>{"use strict";var t=e.i(14368);e.i(24856);var s=e.i(78451);function a(e){let t=t=>e.filter(e=>e.state===t).length;return{total:e.length,passed:t("passed"),failed:t("failed"),errors:t("error"),skipped:t("skipped"),durationMs:Math.round(e.reduce((e,t)=>e+(t.durationMs??0),0))}}function n(e){let t=a(e.steps);return t.passed>0&&0===t.failed&&0===t.errors}function l(e){let t=a(e.steps),s=t.total-t.skipped;if("running"===e.status)return`Running ${t.passed+t.failed+t.errors+1} of ${s}…`;if(!s)return"Nothing ran";let n=[`${t.passed} of ${s} passed`];return t.failed&&n.push(`${t.failed} failed`),t.errors&&n.push(`${t.errors} could not run`),t.skipped&&n.push(`${t.skipped} skipped`),"stopped"===e.status&&n.push("stopped early"),n.join(" · ")}let i=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),r=e=>((e??0)/1e3).toFixed(3),o=e=>String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),d={passed:"Passed",failed:"Failed",error:"Could not run",skipped:"Skipped",pending:"Not run",running:"Not finished"};var c=e.i(53012),u=e.i(99522);let p=(0,u.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),m=(0,u.default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);var x=e.i(17118),h=e.i(95486),b=e.i(60961),f=e.i(40945),g=e.i(75117);let v=(0,u.default)("file-archive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);var y=e.i(29091),k=e.i(27813);let w=(0,u.default)("circle-minus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);var j=e.i(3792),$=e.i(66478),N=e.i(27122),C=e.i(36994),S=e.i(99181),M=e.i(69578),z=e.i(80707),q=e.i(56396);function A({collection:e,environment:t,data:s="api-tests"}){let a=t?` --env ${JSON.stringify(t)}`:"";return`npx --yes apitestcenter suite ${JSON.stringify(e)} --data ${s}${a} --junit atc-results.xml`}var E=e.i(17219);async function R(e,t){var s;let a,n=await fetch(`/engine/suites/export?collection=${encodeURIComponent(e)}`,{cache:"no-store"}),l=await n.json().catch(()=>null);if(!n.ok||!l?.files)throw Error(l?.error??`Engine error (${n.status})`);let i=l.secrets??[],r={};for(let e of l.files)r[`api-tests/${e.path}`]=e.text;r["api-tests/README.md"]=function(e){let{collection:t,environment:s,secrets:a=[],data:n="api-tests"}=e,l=s?` --env ${JSON.stringify(s)}`:"";return`# API checks — ${t||"requests outside a collection"}
|
|
2
|
-
|
|
3
|
-
Every request in this collection is sent once, in the saved order, and checked. The run fails
|
|
4
|
-
(exit code 1) when any request fails.
|
|
5
|
-
|
|
6
|
-
${A(e)}
|
|
7
|
-
|
|
8
|
-
- Nothing to install first: \`npx\` fetches the command line (Node.js 20 or later).
|
|
9
|
-
- Edit these tests in a window: \`npx apitestcenter ui --data ${n}\` (or the desktop app).
|
|
10
|
-
- \`${n}/requests\` holds the saved requests, \`environments.json\` the environments, and
|
|
11
|
-
\`suites.json\` the run order. Secret values are never in these files.
|
|
12
|
-
- Pass secrets from your CI's secret store: write \`{{token}}\` in the request, then add
|
|
13
|
-
\`--var token=$MY_TOKEN\` to the command.
|
|
14
|
-
${a.length?`
|
|
15
|
-
**These requests have a secret typed straight into them, which is not exported** — change it to a
|
|
16
|
-
{{variable}} and pass it with --var, or they will not run here:
|
|
17
|
-
|
|
18
|
-
${a.map(e=>`- ${e}`).join("\n")}
|
|
19
|
-
`:""}
|
|
20
|
-
To check speed too, load-test one request with goals, and compare with a baseline:
|
|
21
|
-
|
|
22
|
-
npx --yes apitestcenter run "${t?`${t}/`:""}<request name>" --data ${n}${l} --p95 500 --errors 1 --baseline ${n}/baseline.json --max-slower 10
|
|
23
|
-
|
|
24
|
-
Guide: https://apitestcenter.com/docs/ci-walkthrough.html
|
|
25
|
-
`}({collection:e,environment:t,secrets:i}),r[".github/workflows/api-checks.yml"]=(a=(s={collection:e,environment:t}).collection||"requests outside a collection",`# Runs the "${a}" API checks on every push. Made by APITestCenter.
|
|
26
|
-
# Guide: https://apitestcenter.com/docs/ci-walkthrough.html
|
|
27
|
-
name: API checks
|
|
28
|
-
|
|
29
|
-
on:
|
|
30
|
-
push:
|
|
31
|
-
workflow_dispatch:
|
|
32
|
-
# Every hour too, even when nobody pushes (a scheduled check that runs while your computer is off):
|
|
33
|
-
# remove the # from the next two lines.
|
|
34
|
-
# schedule:
|
|
35
|
-
# - cron: "0 * * * *"
|
|
36
|
-
|
|
37
|
-
jobs:
|
|
38
|
-
api-checks:
|
|
39
|
-
runs-on: ubuntu-latest
|
|
40
|
-
steps:
|
|
41
|
-
- uses: actions/checkout@v4
|
|
42
|
-
|
|
43
|
-
- uses: actions/setup-node@v4
|
|
44
|
-
with:
|
|
45
|
-
node-version: 22
|
|
46
|
-
|
|
47
|
-
# Fails the job when any request fails. Secrets: add --var name=\${{ secrets.NAME }}
|
|
48
|
-
- name: Check every request
|
|
49
|
-
run: ${A(s)}
|
|
50
|
-
|
|
51
|
-
- name: Keep the results
|
|
52
|
-
if: always()
|
|
53
|
-
uses: actions/upload-artifact@v4
|
|
54
|
-
with:
|
|
55
|
-
name: api-check-results
|
|
56
|
-
path: atc-results.xml
|
|
57
|
-
`);let o=(e||"requests").replace(/[^\w.-]+/g,"-").replace(/^-|-$/g,"")||"requests";return{blob:(0,E.zipStore)(r),name:`${o}-for-ci.zip`,secrets:i}}var P=e.i(15060),T=e.i(14168),L=e.i(6278),I=e.i(15868),O=e.i(92084),U=e.i(13643);let D=(0,u.default)("bell-ring",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]),F=(0,u.default)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]),H=(0,u.default)("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]);var B=e.i(49913),J=e.i(96659),V=e.i(39170),_=e.i(727),G=e.i(44505),K=e.i(43101);let Y=e=>{let t=new Date(e);return new Date().toDateString()===t.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},W=Object.entries(O.NOTIFY_LABELS);function X({collection:e,environment:s}){let a=(0,q.useToast)(),n=(0,V.useConfirm)(),{environments:l}=(0,L.useWorkspace)(),i=(0,K.useSchedules)(),r=(0,_.useNoticeState)(),[o,d]=(0,S.useState)(15),[c,u]=(0,S.useState)("changes"),[p,m]=(0,S.useState)(null),x=e=>e?l.find(t=>t.id===e)?.name??"an environment that was removed":"no environment",h=i?.find(t=>t.collection===e&&t.environment===s);async function b(e,t,s){m(e);try{let e=await t(),n=s?.(e);n&&a(n,"success")}catch(e){a(e instanceof Error?e.message:"That didn't work","error")}finally{m(null)}}return(0,t.jsxs)("section",{"aria-label":"Scheduled checks",className:"rounded-lg border border-line bg-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-line px-4 py-2 text-xs text-mute",children:[(0,t.jsx)(F,{size:14,"aria-hidden":!0}),(0,t.jsx)("span",{className:"font-medium text-ink",children:"Scheduled checks"}),(0,t.jsxs)("span",{children:["— a collection run every few minutes while the app runs, with a notification when it starts failing.",(0,G.desktop)()?.background?" Closing the window keeps it running in the tray.":""]}),"ask"===r||"off"===r?(0,t.jsxs)("button",{type:"button",className:"ml-auto inline-flex items-center gap-1 text-accent hover:underline",onClick:()=>void(0,_.toggleNotices)(),children:[(0,t.jsx)(D,{size:12,"aria-hidden":!0})," Turn on desktop notifications"]}):"blocked"===r?(0,t.jsxs)("span",{className:"ml-auto inline-flex items-center gap-1",children:[(0,t.jsx)(U.BellOff,{size:12,"aria-hidden":!0})," Notifications are blocked — you'll see them in the app only"]}):null]}),null===e||h?null:(0,t.jsxs)("div",{className:"flex flex-wrap items-end gap-3 border-b border-line px-4 py-3",children:[(0,t.jsxs)("p",{className:"w-full text-sm text-ink",children:["Run ",(0,t.jsx)("span",{className:"font-medium",children:e||"requests outside a folder"})," with ",x(s),":"]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-mute",children:["How often",(0,t.jsx)("select",{value:o,onChange:e=>d(Number(e.target.value)),className:"rounded-md border border-line bg-panel-2 px-2 py-1.5 text-sm text-ink",children:O.SCHEDULE_EVERY.map(e=>(0,t.jsx)("option",{value:e,children:(0,O.everyLabel)(e).replace(/^every /,"Every ")},e))})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-mute",children:["Notify me",(0,t.jsx)("select",{value:c,onChange:e=>u(e.target.value),className:"rounded-md border border-line bg-panel-2 px-2 py-1.5 text-sm text-ink",children:W.map(([e,s])=>(0,t.jsx)("option",{value:e,children:s},e))})]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-primary",disabled:"add"===p,onClick:()=>void b("add",()=>K.schedulesApi.add({collection:e,environment:s,everyMinutes:o,notify:c}),()=>`Scheduled: ${e||"requests outside a folder"} ${(0,O.everyLabel)(o)} — the first run starts now`),children:["add"===p?(0,t.jsx)(k.Loader2,{size:14,className:"animate-spin"}):(0,t.jsx)(F,{size:14}),"Schedule it"]})]}),null===i?(0,t.jsx)("p",{className:"px-4 py-3 text-sm text-mute",children:"Loading…"}):i.length?(0,t.jsx)("ul",{className:"divide-y divide-line","aria-label":"Scheduled collections",children:i.map(e=>(0,t.jsx)(Q,{s:e,env:x(e.environment),busy:p,current:e.id===h?.id,act:b,onRemove:async()=>{await n({title:`Stop running ${e.collection||"requests outside a folder"} on a schedule?`,body:"Its results go too. The requests stay.",confirmLabel:"Remove",tone:"danger"})&&await b(`rm:${e.id}`,()=>K.schedulesApi.remove(e.id))}},e.id))}):(0,t.jsx)("p",{className:"px-4 py-3 text-sm text-mute",children:"None yet. A scheduled check keeps running while you work on something else."})]})}function Q({s:e,env:s,busy:a,current:n,act:l,onRemove:i}){let r=e.results.at(-1),[o,d]=(0,S.useState)(!1),c=e.collection||"Requests outside a folder";return(0,t.jsxs)("li",{className:n?"bg-accent-dim/30":void 0,children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 px-4 py-2.5",children:[r?r.passed?(0,t.jsx)(x.CheckCircle2,{size:16,className:"shrink-0 text-ok","aria-label":"Last run passed"}):(0,t.jsx)(N.XCircle,{size:16,className:"shrink-0 text-bad","aria-label":"Last run failed"}):(0,t.jsx)(F,{size:16,className:"shrink-0 text-mute","aria-label":"Not run yet"}),(0,t.jsxs)("button",{type:"button",className:"min-w-0 text-left",onClick:()=>d(e=>!e),"aria-expanded":o,children:[(0,t.jsx)("span",{className:"block truncate text-sm font-medium text-ink",children:c}),(0,t.jsxs)("span",{className:"block text-xs text-mute",children:[(0,O.everyLabel)(e.everyMinutes)," · ",s," · ",e.enabled?r?`next at ${Y(Math.max((0,O.nextRunAt)(e),Date.now()))}`:"first run starting":"paused"]})]}),(0,t.jsx)("span",{className:"flex items-center gap-0.5","aria-label":`Last ${e.results.length} runs`,title:"Oldest on the left",children:e.results.slice(-20).map(e=>(0,t.jsx)("span",{title:`${Y(e.at)} — ${e.headline}`,className:`h-3.5 w-1.5 rounded-sm ${e.passed?"bg-ok":"bg-bad"}`},e.at))}),(0,t.jsxs)("span",{className:"ml-auto flex items-center gap-1",children:[r?(0,t.jsxs)("span",{className:"mr-2 hidden text-xs text-mute sm:inline",children:[Y(r.at),": ",r.headline]}):null,(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",disabled:a===`run:${e.id}`,onClick:()=>void l(`run:${e.id}`,()=>K.schedulesApi.run(e.id),e=>e.passed?`${c}: ${e.headline}`:null),title:"Run it now",children:[a===`run:${e.id}`?(0,t.jsx)(k.Loader2,{size:12,className:"animate-spin"}):(0,t.jsx)(B.RotateCw,{size:12})," Run now"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>void l(`pause:${e.id}`,()=>K.schedulesApi.update(e.id,{enabled:!e.enabled})),"aria-label":e.enabled?`Pause ${c}`:`Resume ${c}`,children:[e.enabled?(0,t.jsx)(H,{size:12}):(0,t.jsx)(j.Play,{size:12})," ",e.enabled?"Pause":"Resume"]}),(0,t.jsx)("button",{type:"button",className:"rounded p-1 text-mute hover:text-bad",onClick:i,"aria-label":`Remove the schedule of ${c}`,children:(0,t.jsx)(J.Trash2,{size:14})})]})]}),o||r&&!r.passed?(0,t.jsxs)("div",{className:"space-y-2 px-4 pb-3 pl-11 text-xs text-mute",children:[r&&!r.passed?(0,t.jsxs)("div",{className:"rounded-md border border-bad/30 bg-bad/5 px-3 py-2",children:[(0,t.jsx)("p",{className:"text-ink",children:r.headline}),r.failed.length?(0,t.jsx)("ul",{className:"mt-1 list-disc space-y-0.5 pl-4",children:r.failed.map(e=>(0,t.jsxs)("li",{children:[(0,t.jsx)("span",{className:"text-ink",children:e.name}),e.message?` — ${e.message}`:""]},e.name))}):null]}):null,o?(0,t.jsxs)("label",{className:"flex flex-wrap items-center gap-2",children:["Notify me",(0,t.jsx)("select",{value:e.notify,onChange:t=>void l(`notify:${e.id}`,()=>K.schedulesApi.update(e.id,{notify:t.target.value})),className:"rounded-md border border-line bg-panel-2 px-2 py-1 text-xs text-ink",children:W.map(([e,s])=>(0,t.jsx)("option",{value:e,children:s},e))}),"How often",(0,t.jsx)("select",{value:e.everyMinutes,onChange:t=>void l(`every:${e.id}`,()=>K.schedulesApi.update(e.id,{everyMinutes:Number(t.target.value)})),className:"rounded-md border border-line bg-panel-2 px-2 py-1 text-xs text-ink",children:[...new Set([...O.SCHEDULE_EVERY,e.everyMinutes])].sort((e,t)=>e-t).map(e=>(0,t.jsx)("option",{value:e,children:(0,O.everyLabel)(e).replace(/^every /,"Every ")},e))})]}):null]}):null]})}let Z={GET:"text-ok",POST:"text-warn",PUT:"text-accent",PATCH:"text-accent",DELETE:"text-bad"},ee="apitestcenter-suite-stop-on-fail";function et({state:e}){return"passed"===e?(0,t.jsx)(x.CheckCircle2,{size:16,className:"text-ok","aria-label":"Passed"}):"failed"===e?(0,t.jsx)(N.XCircle,{size:16,className:"text-bad","aria-label":"Failed"}):"error"===e?(0,t.jsx)(c.AlertTriangle,{size:16,className:"text-bad","aria-label":"Could not run"}):"skipped"===e?(0,t.jsx)(w,{size:16,className:"text-mute","aria-label":"Skipped"}):"running"===e?(0,t.jsx)(k.Loader2,{size:16,className:"animate-spin text-accent","aria-label":"Running"}):(0,t.jsx)(f.Circle,{size:16,className:"text-line","aria-label":"Not run yet"})}let es=e=>`${(e.collection||"requests").replace(/[^\w.-]+/g,"-")}-${e.startedAt.slice(0,16).replace(/[:T]/g,"-")}`;e.s(["SuitePage",0,function(){let e=(0,C.useRouter)(),c=(0,C.useSearchParams)(),u=(0,q.useToast)(),{index:f,environments:w,activeEnv:A,setActiveEnv:E}=(0,L.useWorkspace)(),O=(0,S.useMemo)(()=>f?.requests??[],[f]),U=(0,S.useMemo)(()=>[...new Set(O.flatMap(e=>e.collection?(0,s.folderChain)(e.collection):[""]))].sort((e,t)=>""===e?1:""===t?-1:e.localeCompare(t)),[O]),D=(0,S.useCallback)(e=>O.filter(t=>e?(0,s.inFolder)(t.collection,e):""===t.collection),[O]),F=c.get("c"),H=null!==F&&U.includes(F)?F:U[0]??null,B=(0,S.useMemo)(()=>null===H?[]:D(H),[D,H]),[J,V]=(0,S.useState)(null),[_,G]=(0,S.useState)(null),[K,Y]=(0,S.useState)(!1),[W,Q]=(0,S.useState)(new Set),[ea,en]=(0,S.useState)(!1),[el,ei]=(0,S.useState)(!1),er=(0,S.useRef)(null);(0,S.useEffect)(()=>{try{Y("1"===localStorage.getItem(ee))}catch{}},[]),(0,S.useEffect)(()=>{if(null===H)return;V(null),G(null),Q(new Set);let e=!0;return T.suiteApi.plan(H).then(t=>e&&V(t)).catch(()=>e&&V({order:[],skip:[]})),()=>{e=!1}},[H]),(0,S.useEffect)(()=>()=>void(er.current&&window.clearInterval(er.current)),[]);let eo=(0,S.useMemo)(()=>(function(e,t){let s=new Map(e.map(e=>[e.id,e])),a=new Set,n=[];for(let e of t?.order??[]){let t=s.get(e);t&&!a.has(e)&&(n.push(t),a.add(e))}for(let t of e)a.has(t.id)||n.push(t);let l=new Set(t?.skip??[]);return n.map(e=>({item:e,skipped:l.has(e.id)}))})(B,J),[B,J]),ed=_?.status==="running";(0,S.useMemo)(()=>new Map((_?.steps??[]).map(e=>[e.id,e])),[_]);let ec=_?_.steps.flatMap(e=>{let t=B.find(t=>t.id===e.id);return t?[{item:t,skipped:"skipped"===e.state&&!!e.message?.startsWith("Left out"),step:e}]:[]}):eo,eu=(0,S.useCallback)(e=>{null!==H&&(V(e),T.suiteApi.savePlan(H,e).catch(e=>u(e instanceof Error?e.message:"Could not save the order","error")))},[H,u]);function ep(e,t){let s=eo.map(e=>e.item.id),a=s.indexOf(e),n=a+t;a<0||n<0||n>=s.length||([s[a],s[n]]=[s[n],s[a]],G(null),eu({order:s,skip:J?.skip??[]}))}async function em(){if(null!==H&&!ea){en(!0),Q(new Set);try{let e=await T.suiteApi.start({collection:H,environmentId:A?.id??null,stopOnFail:K});G(e),er.current&&window.clearInterval(er.current),er.current=window.setInterval(async()=>{try{let t=await T.suiteApi.get(e.id);G(t),"running"!==t.status&&(window.clearInterval(er.current),er.current=null,Q(new Set(t.steps.filter(e=>"failed"===e.state||"error"===e.state).map(e=>e.id))))}catch{}},400)}catch(e){u(e instanceof Error?e.message:"Could not start the run","error")}finally{en(!1)}}}async function ex(){if(null!==H){ei(!0);try{let{blob:e,name:t,secrets:s}=await R(H,A?.name??null);(0,P.downloadBlob)(t,e),u(s.length?`Saved ${t}. ${s.length} request${1===s.length?" has":"s have"} a secret typed in — switch to a {{variable}} for CI (see README in the zip).`:`Saved ${t} — unzip it into your repository. No secrets are in it.`,s.length?"info":"success")}catch(e){u(e instanceof Error?e.message:"Could not export","error")}finally{ei(!1)}}}async function eh(){_&&await T.suiteApi.stop(_.id).catch(()=>void 0)}let eb=_?a(_.steps):null,ef=_&&"running"!==_.status,eg=eo.filter(e=>!e.skipped).length;return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsx)("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:"Run a collection"}),(0,t.jsx)("p",{className:"text-xs text-mute",children:"Sends every request once, in order, and checks each one. Passes when all its checks pass, or on any 2xx/3xx when it has none."})]})}),0===U.length?(0,t.jsx)("div",{className:"m-6 max-w-xl space-y-2 text-sm text-mute",children:(0,t.jsx)("p",{children:"No saved requests yet. Save requests into a collection on the Test API page (Ctrl+S), or import a Postman collection, then come back here to run them all."})}):(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4 lg:px-6",children:(0,t.jsxs)("div",{className:"mx-auto max-w-5xl space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-end gap-3",children:[(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-mute",children:["Collection",(0,t.jsx)(z.Select,{label:"Collection",value:H??"",disabled:ed,onChange:t=>e.replace((0,T.suiteHref)(t)),minWidth:240,buttonContent:null===H?"":`${H||"No collection"} (${B.length})`,options:U.map(e=>({value:e,label:(0,t.jsx)("span",{style:{paddingLeft:`${.9*Math.max(0,(0,s.folderChain)(e).length-1)}rem`},children:e?(0,s.folderName)(e):"No collection"}),hint:`${D(e).length} request${1===D(e).length?"":"s"}${e.includes("/")?` \xb7 ${e}`:""}`,text:e||"no collection"})),className:"min-w-48 rounded-md border border-line bg-panel-2 px-2 py-1.5 text-sm text-ink"})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-mute",children:["Environment",(0,t.jsxs)("select",{value:A?.id??"",disabled:ed,onChange:e=>E(e.target.value||null),className:"min-w-40 rounded-md border border-line bg-panel-2 px-2 py-1.5 text-sm text-ink",children:[(0,t.jsx)("option",{value:"",children:"None"}),w.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,t.jsxs)("label",{className:"flex items-center gap-2 pb-1.5 text-sm text-ink",children:[(0,t.jsx)("input",{type:"checkbox",checked:K,disabled:ed,onChange:e=>{Y(e.target.checked);try{localStorage.setItem(ee,e.target.checked?"1":"0")}catch{}}}),"Stop at the first failure"]}),(0,t.jsxs)("span",{className:"ml-auto flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary",disabled:el||null===H,onClick:()=>void ex(),title:"A zip for your repository: this collection's requests, environments and run order (never secrets), plus a ready GitHub Actions pipeline",children:[el?(0,t.jsx)(k.Loader2,{size:14,className:"animate-spin"}):(0,t.jsx)(v,{size:14}),"Download for CI"]}),ed?(0,t.jsxs)("button",{type:"button",className:"btn btn-danger",onClick:()=>void eh(),children:[(0,t.jsx)($.Square,{size:14})," Stop"]}):(0,t.jsxs)("button",{type:"button",className:"btn btn-primary",disabled:!J||0===eg||ea,onClick:()=>void em(),children:[ea?(0,t.jsx)(k.Loader2,{size:14,className:"animate-spin"}):(0,t.jsx)(j.Play,{size:14}),"Run ",eg," request",1===eg?"":"s"]})]})]}),_?(0,t.jsxs)("div",{role:"status",className:`flex flex-wrap items-center gap-x-4 gap-y-2 rounded-lg border px-4 py-3 ${ed?"border-line bg-panel":n(_)?"border-ok/40 bg-ok/10":"border-bad/40 bg-bad/10"}`,children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 font-medium text-ink",children:[ed?(0,t.jsx)(k.Loader2,{size:16,className:"animate-spin text-accent"}):n(_)?(0,t.jsx)(x.CheckCircle2,{size:16,className:"text-ok"}):(0,t.jsx)(N.XCircle,{size:16,className:"text-bad"}),ed?"Running…":n(_)?"All requests passed":"Not all requests passed"]}),(0,t.jsx)("span",{className:"text-sm text-mute",children:l(_)}),eb&&ef?(0,t.jsxs)("span",{className:"text-sm text-mute",children:["· ",(eb.durationMs/1e3).toFixed(1)," s of response time"]}):null,ef?(0,t.jsxs)("span",{className:"ml-auto flex flex-wrap items-center gap-1",children:[(0,t.jsx)("span",{className:"mr-1 text-xs text-mute",children:"Save as"}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>(0,P.downloadText)(`${es(_)}.html`,function(e,t={}){let s=a(e.steps),i=n(e),r=e.collection||"Saved requests",c=e=>"passed"===e?"ok":"failed"===e||"error"===e?"bad":"mute",u=e.steps.map((e,t)=>{let s=e.checks?.length?`<ul class="checks">${e.checks.map(e=>`<li class="${e.ok?"ok":"bad"}">${e.ok?"✓":"✕"} ${o(e.name)}</li>`).join("")}</ul>`:"",a=e.bodyPreview?`<details><summary>Response body</summary><pre>${o(e.bodyPreview)}</pre></details>`:"",n=e.runFirst?`<div class="sub">Run first: ${o(e.runFirst.label)}${e.runFirst.reused?" (reused)":""}</div>`:"",l=e.saved?.length?`<div class="sub">${e.saved.map(e=>e.found?`Saved {{${o(e.name)}}} = ${o(e.preview??"")}`:`✕ {{${o(e.name)}}} not found`).join(" · ")}</div>`:"";return`<tr>
|
|
58
|
-
<td class="n">${t+1}</td>
|
|
59
|
-
<td><span class="state ${c(e.state)}">${d[e.state]}</span></td>
|
|
60
|
-
<td><div><b class="m">${o(e.method)}</b> ${o(e.name)}</div><div class="sub mono">${o(e.url)}</div>${n}${l}${e.message?`<div class="msg ${c(e.state)}">${o(e.message)}</div>`:""}${s}${a}</td>
|
|
61
|
-
<td class="num">${e.status??"–"}</td>
|
|
62
|
-
<td class="num">${null!=e.durationMs?`${Math.round(e.durationMs)} ms`:"–"}</td>
|
|
63
|
-
</tr>`}).join("\n");return`<!doctype html>
|
|
64
|
-
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
65
|
-
<title>${o(r)} — collection run</title>
|
|
66
|
-
<style>
|
|
67
|
-
:root { --ink:#12151c; --mute:#5c6778; --line:#d5dce6; --panel:#fff; --canvas:#f4f6f9; --ok:#137333; --bad:#c62828; --okbg:#e6f4ea; --badbg:#fce8e6; }
|
|
68
|
-
* { box-sizing:border-box; }
|
|
69
|
-
body { margin:0; background:var(--canvas); color:var(--ink); font:14px/1.5 "Segoe UI",system-ui,-apple-system,sans-serif; }
|
|
70
|
-
main { max-width:1000px; margin:0 auto; padding:28px 16px 48px; }
|
|
71
|
-
h1 { font-size:22px; margin:0 0 4px; }
|
|
72
|
-
.meta { color:var(--mute); font-size:13px; margin-bottom:18px; }
|
|
73
|
-
.banner { border-radius:10px; padding:14px 16px; font-weight:600; margin-bottom:16px; }
|
|
74
|
-
.banner.ok { background:var(--okbg); color:var(--ok); } .banner.bad { background:var(--badbg); color:var(--bad); }
|
|
75
|
-
.tiles { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:10px; margin-bottom:18px; }
|
|
76
|
-
.tile { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:10px 14px; }
|
|
77
|
-
.tile b { display:block; font-size:24px; }
|
|
78
|
-
.tile span { color:var(--mute); font-size:12.5px; }
|
|
79
|
-
table { width:100%; border-collapse:collapse; background:var(--panel); border:1px solid var(--line); border-radius:10px; overflow:hidden; }
|
|
80
|
-
th, td { text-align:left; vertical-align:top; padding:9px 10px; border-bottom:1px solid var(--line); }
|
|
81
|
-
th { font-size:12px; color:var(--mute); font-weight:600; background:#eef1f6; }
|
|
82
|
-
.n, .num { white-space:nowrap; font-variant-numeric:tabular-nums; } .num { text-align:right; }
|
|
83
|
-
.state { display:inline-block; font-size:12px; font-weight:600; padding:1px 8px; border-radius:999px; white-space:nowrap; }
|
|
84
|
-
.state.ok { background:var(--okbg); color:var(--ok); } .state.bad { background:var(--badbg); color:var(--bad); } .state.mute { background:#eef1f6; color:var(--mute); }
|
|
85
|
-
.m { font-family:ui-monospace,Consolas,monospace; font-size:12px; }
|
|
86
|
-
.sub { color:var(--mute); font-size:12.5px; } .mono { font-family:ui-monospace,Consolas,monospace; word-break:break-all; }
|
|
87
|
-
.msg { font-size:13px; margin-top:4px; } .msg.bad { color:var(--bad); } .msg.mute { color:var(--mute); }
|
|
88
|
-
.checks { list-style:none; padding:0; margin:6px 0 0; font-size:12.5px; } .checks .ok { color:var(--ok); } .checks .bad { color:var(--bad); }
|
|
89
|
-
details { margin-top:6px; font-size:12.5px; } summary { cursor:pointer; color:var(--mute); }
|
|
90
|
-
pre { white-space:pre-wrap; word-break:break-all; background:#eef1f6; padding:8px; border-radius:6px; max-height:300px; overflow:auto; }
|
|
91
|
-
footer { color:var(--mute); font-size:12px; margin-top:16px; }
|
|
92
|
-
</style></head><body><main>
|
|
93
|
-
<h1>${o(r)}</h1>
|
|
94
|
-
<div class="meta">Collection run \xb7 ${o(new Date(e.startedAt).toLocaleString("en-GB"))}${e.environment?` \xb7 environment ${o(e.environment)}`:""}</div>
|
|
95
|
-
<div class="banner ${i?"ok":"bad"}">${i?"✓ All requests passed":"✕ Not all requests passed"} — ${o(l(e))}</div>
|
|
96
|
-
<div class="tiles">
|
|
97
|
-
<div class="tile"><b>${s.passed}</b><span>passed</span></div>
|
|
98
|
-
<div class="tile"><b>${s.failed}</b><span>failed</span></div>
|
|
99
|
-
<div class="tile"><b>${s.errors}</b><span>could not run</span></div>
|
|
100
|
-
<div class="tile"><b>${s.skipped}</b><span>skipped</span></div>
|
|
101
|
-
<div class="tile"><b>${(s.durationMs/1e3).toFixed(1)} s</b><span>total response time</span></div>
|
|
102
|
-
</div>
|
|
103
|
-
<table>
|
|
104
|
-
<thead><tr><th>#</th><th>Result</th><th>Request</th><th class="num">Status</th><th class="num">Time</th></tr></thead>
|
|
105
|
-
<tbody>
|
|
106
|
-
${u}
|
|
107
|
-
</tbody></table>
|
|
108
|
-
<footer>Made with APITestCenter \xb7 ${o(t.generatedAt??new Date().toISOString())}. A request passes when all its checks pass; without checks, on any 2xx or 3xx status.</footer>
|
|
109
|
-
</main></body></html>
|
|
110
|
-
`}(_),"text/html"),children:[(0,t.jsx)(g.Download,{size:12})," HTML"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>{let e,t,s,n;return(0,P.downloadText)(`${es(_)}.xml`,(e=a(_.steps),t=_.collection||"Saved requests",s=_.steps.map(e=>{let s=`${e.method} ${e.name}`,a=` <testcase classname="${i(t)}" name="${i(s)}" time="${r(e.durationMs)}">`;if("passed"===e.state)return`${a}</testcase>`;if("skipped"===e.state||"pending"===e.state||"running"===e.state)return`${a}
|
|
111
|
-
<skipped message="${i(e.message??"Not run")}"/>
|
|
112
|
-
</testcase>`;let n="error"===e.state?"error":"failure",l=[e.status?`Status ${e.status}`:"",...(e.checks??[]).map(e=>`${e.ok?"✓":"✕"} ${e.name}`),e.bodyPreview?`
|
|
113
|
-
Response:
|
|
114
|
-
${e.bodyPreview}`:""].filter(Boolean).join("\n");return`${a}
|
|
115
|
-
<${n} message="${i(e.message??e.state)}">${i(l)}</${n}>
|
|
116
|
-
</testcase>`}),n=r(e.durationMs),`<?xml version="1.0" encoding="UTF-8"?>
|
|
117
|
-
<testsuites name="APITestCenter" tests="${e.total}" failures="${e.failed}" errors="${e.errors}" skipped="${e.skipped}" time="${n}">
|
|
118
|
-
<testsuite name="${i(t)}" tests="${e.total}" failures="${e.failed}" errors="${e.errors}" skipped="${e.skipped}" time="${n}" timestamp="${i(_.startedAt)}">
|
|
119
|
-
${s.join("\n")}
|
|
120
|
-
</testsuite>
|
|
121
|
-
</testsuites>
|
|
122
|
-
`),"application/xml")},title:"JUnit XML for CI dashboards",children:[(0,t.jsx)(g.Download,{size:12})," JUnit"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>(0,P.downloadText)(`${es(_)}.json`,`${JSON.stringify({kind:"apitestcenter-suite",version:1,..._,totals:a(_.steps),passed:n(_)},null,2)}
|
|
123
|
-
`,"application/json"),children:[(0,t.jsx)(g.Download,{size:12})," JSON"]})]}):null]}):null,(0,t.jsxs)("section",{"aria-label":"Requests in run order",className:"overflow-hidden rounded-lg border border-line bg-panel",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 border-b border-line px-4 py-2 text-xs text-mute",children:[(0,t.jsx)(y.ListChecks,{size:14,"aria-hidden":!0}),(0,t.jsx)("span",{children:_?"Results":"Run order — untick to leave a request out; use the arrows to reorder. Saved for next time and for the CLI."})]}),J?(0,t.jsx)("ol",{children:ec.map(({item:s,skipped:a,step:n},l)=>{let i=W.has(s.id),r=n&&(n.message||n.checks?.length||n.bodyPreview||n.runFirst||n.saved?.length);return(0,t.jsxs)("li",{className:"border-b border-line last:border-b-0",children:[(0,t.jsxs)("div",{className:`flex items-center gap-3 px-4 py-2 ${a&&!_?"opacity-50":""}`,children:[_?(0,t.jsx)(et,{state:n?.state??"pending"}):(0,t.jsx)("input",{type:"checkbox",checked:!a,onChange:()=>{var e;let t;return e=s.id,void((t=new Set(J?.skip??[])).has(e)?t.delete(e):t.add(e),G(null),eu({order:eo.map(e=>e.item.id),skip:[...t]}))},"aria-label":`Include ${s.name}`}),(0,t.jsx)("span",{className:"w-6 shrink-0 text-right font-mono text-xs text-mute",children:l+1}),(0,t.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left",onClick:()=>r?Q(e=>{let t=new Set(e);return t.has(s.id)?t.delete(s.id):t.add(s.id),t}):void 0,"aria-expanded":r?i:void 0,children:[(0,t.jsx)("span",{className:`w-14 shrink-0 font-mono text-xs font-medium ${Z[s.method]??"text-mute"}`,children:s.method}),(0,t.jsxs)("span",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"block truncate text-sm text-ink",children:s.name}),(0,t.jsx)("span",{className:"block truncate font-mono text-[11px] text-mute",children:s.url})]}),r?i?(0,t.jsx)(h.ChevronDown,{size:14,className:"shrink-0 text-mute"}):(0,t.jsx)(b.ChevronRight,{size:14,className:"shrink-0 text-mute"}):null]}),n?.status?(0,t.jsx)("span",{className:`font-mono text-xs ${n.status<400?"text-ok":"text-bad"}`,children:n.status}):null,n?.durationMs!=null?(0,t.jsxs)("span",{className:"w-16 text-right font-mono text-xs text-mute",children:[Math.round(n.durationMs)," ms"]}):null,_?null:(0,t.jsxs)("span",{className:"flex items-center",children:[(0,t.jsx)("button",{type:"button",className:"rounded p-1 text-mute hover:text-ink disabled:opacity-30",disabled:0===l,onClick:()=>ep(s.id,-1),"aria-label":`Move ${s.name} up`,children:(0,t.jsx)(m,{size:14})}),(0,t.jsx)("button",{type:"button",className:"rounded p-1 text-mute hover:text-ink disabled:opacity-30",disabled:l===ec.length-1,onClick:()=>ep(s.id,1),"aria-label":`Move ${s.name} down`,children:(0,t.jsx)(p,{size:14})})]})]}),i&&n?(0,t.jsxs)("div",{className:"space-y-2 bg-panel-2 px-4 py-3 pl-[4.75rem] text-sm",children:[n.message?(0,t.jsx)("p",{className:"skipped"===n.state?"text-mute":"text-bad",children:n.message}):null,n.runFirst?(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Run first: ",n.runFirst.label,n.runFirst.reused?" (reused from an earlier request)":""]}):null,n.saved?.length?(0,t.jsx)("p",{className:"text-xs",children:n.saved.map(e=>(0,t.jsx)("span",{className:`mr-3 ${e.found?"text-ok":"text-bad"}`,children:e.found?`Saved {{${e.name}}} = ${e.preview??""}`:`✕ {{${e.name}}} not found`},e.name))}):null,n.checks?.length?(0,t.jsx)("ul",{className:"space-y-0.5 text-xs",children:n.checks.map((e,s)=>(0,t.jsxs)("li",{className:e.ok?"text-ok":"text-bad",children:[e.ok?"✓":"✕"," ",e.name,!e.ok&&e.detail?(0,t.jsxs)("span",{className:"text-mute",children:[" — ",e.detail]}):null]},s))}):null,n.bodyPreview?(0,t.jsx)("pre",{className:"max-h-48 overflow-auto rounded-md border border-line bg-canvas p-2 font-mono text-[11px] whitespace-pre-wrap text-ink",children:n.bodyPreview}):null,(0,t.jsx)("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>(function(t){try{sessionStorage.setItem(M.OPEN_REQUEST_KEY,t)}catch{}(0,I.startNavProgress)(),e.push("/")})(s.id),children:"Open this request"})]}):null]},s.id)})}):(0,t.jsx)("p",{className:"px-4 py-6 text-sm text-mute",children:"Loading…"}),ef?(0,t.jsx)("div",{className:"border-t border-line px-4 py-2 text-right",children:(0,t.jsx)("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>G(null),children:"Edit the run order"})}):null]}),(0,t.jsx)(X,{collection:H,environment:A?.id??null})]})})]})}],93639)},17219,e=>{"use strict";let t=new Uint32Array(256).map((e,t)=>{let s=t;for(let e=0;e<8;e++)s=1&s?0xedb88320^s>>>1:s>>>1;return s>>>0});function s(e){let t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!0),t}function a(e){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),t}function n(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),s=0;for(let a of e)t.set(a,s),s+=a.length;return t}e.s(["zipStore",0,function(e){let l=new TextEncoder,i=[],r=[],o=0;for(let[d,c]of Object.entries(e)){let e=l.encode(d),u="string"==typeof c?l.encode(c):c,p=function(e){let s=0xffffffff;for(let a of e)s=t[(s^a)&255]^s>>>8;return(0xffffffff^s)>>>0}(u),m=n([a(0x4034b50),s(20),s(0),s(0),s(0),s(0),a(p),a(u.length),a(u.length),s(e.length),s(0),e,u]),x=n([a(0x2014b50),s(20),s(20),s(0),s(0),s(0),s(0),a(p),a(u.length),a(u.length),s(e.length),s(0),s(0),s(0),s(0),a(0),a(o),e]);i.push(m),r.push(x),o+=m.length}let d=n(r),c=n([a(0x6054b50),s(0),s(0),s(Object.keys(e).length),s(Object.keys(e).length),a(d.length),a(o),s(0)]),u=n([...i,d,c]);return new Blob([u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength)],{type:"application/zip"})}])},13643,e=>{"use strict";let t=(0,e.i(99522).default)("bell-off",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]);e.s(["BellOff",0,t],13643)},3792,e=>{"use strict";let t=(0,e.i(99522).default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);e.s(["Play",0,t],3792)},66478,14168,e=>{"use strict";let t=(0,e.i(99522).default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);async function s(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error??`Engine error (${e.status})`);return t}e.s(["Square",0,t],66478);let a=(e,t,s)=>fetch(t,{method:e,headers:void 0===s?void 0:{"content-type":"application/json"},body:void 0===s?void 0:JSON.stringify(s)});e.s(["suiteApi",0,{plan:e=>fetch(`/engine/suites/plan?collection=${encodeURIComponent(e)}`,{cache:"no-store"}).then(e=>s(e)),savePlan:(e,t)=>a("PUT","/engine/suites/plan",{collection:e,...t}).then(e=>s(e)),start:e=>a("POST","/engine/suites/runs",e).then(e=>s(e)),get:e=>fetch(`/engine/suites/runs/${encodeURIComponent(e)}`,{cache:"no-store"}).then(e=>s(e)),stop:e=>a("POST",`/engine/suites/runs/${encodeURIComponent(e)}/stop`).then(e=>s(e))},"suiteHref",0,function(e){return`/suite?c=${encodeURIComponent(e)}`}],14168)}]);
|
|
@@ -1,3 +0,0 @@
|
|
|
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),B=e.i(20054),z=e.i(6278);function P(e){let t=(0,L.emptyFolderSettings)();return{...t,auth:{...t.auth,authMode:"none",...e}}}let _=[{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}],W=["Oracle EBS","PostgreSQL"];function K(e,t){if(t){let e=P({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=P({authMode:"oauth1"});return{...s,auth:{...s.auth,oauth1:{...s.auth.oauth1,signatureMethod:"HMAC-SHA256",realm:e?i(e):"",addTo:"header"}}}}let H=e=>{let t=/^https:\/\/([^.]+)\.suitetalk\.api\.netsuite\.com/i.exec(e.trim());return t?i(t[1]):""},V=e=>`${e.trim().replace(/\/+$/,"")}/services/oauth2/authorize`,Z=e=>`${e.trim().replace(/\/+$/,"")}/services/oauth2/token`;function Q(e,t,s="",n=""){let a=P({authMode:"oauth2"}),l={...a.auth.oauth,grant:t,authUrl:e?V(e):"",tokenUrl:e?Z(e):"",clientId:s,clientSecret:n,scope:"",pkce:!0,clientAuth:"body"};return{...a,auth:{...a.auth,oauth:l}}}function Y({editing:e,existing:s,onClose:n,onSaved:l}){let{demoApi:i}=(0,B.useEngineHealth)(),{vars:r}=(0,z.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:P({})}),[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||G[s.kind],w)),void 0!==e.baseUrl&&"netsuite"===s.kind&&"oauth1"===s.settings.auth.authMode){let t=H(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()?V(t.baseUrl):"",l=t.baseUrl.trim()?Z(t.baseUrl):"",i=e.baseUrl.trim(),r=n.authUrl&&n.authUrl!==a?n.authUrl:i?V(i):"",o=n.tokenUrl&&n.tokenUrl!==l?n.tokenUrl:i?Z(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()||G[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)}}async function O(){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 J="block space-y-1 text-sm",X="text-xs text-mute",ee=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:ee}),(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:_.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":G[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:P({})};if("salesforce"===e&&(s.settings=Q("","authorization_code")),"practice-salesforce"===e){let e=i?`${i}/salesforce`:"";Object.assign(s,{variable:(0,a.connectionVariableName)("practiceOrg",w),variableEdited:!0,baseUrl:e,settings:Q(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:P({authMode:"basic",username:"practice",password:"demo"})}),"successfactors"===e&&(s.settings=P({authMode:"basic"})),"netsuite"===e&&(s.settings=K("")),"practice-netsuite"===e){let e=i?`${i}/netsuite`:"";Object.assign(s,{variable:(0,a.connectionVariableName)("practiceAccount",w),variableEdited:!0,baseUrl:e,settings:K("",{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:W.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:J,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:G[d.kind]})]}),(0,t.jsxs)("label",{className:J,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:J,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:H(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:X,children:"Setup → Company → Company Information. A sandbox's ends in _SB1, _SB2… The base URL follows."})]}):null,(0,t.jsxs)("label",{className:J,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:X,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:X,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:X,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:X,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 O(),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 G={successfactors:"SuccessFactors",salesforce:"Salesforce",netsuite:"NetSuite",odata:"OData service",api:"My API"},J=/^Edm\.(Int16|Int32|Int64|Byte|SByte|Decimal|Double|Single)$/;function X(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(J.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 ee(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 et=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(et):n&&"object"==typeof n&&!Array.isArray(n)?t[s]=et(n):t[s]=n));return t};function es(e){if(!e||"object"!=typeof e)return{rows:[]};if("d"in e){let t=e.d;if(Array.isArray(t))return{rows:t.map(et)};let s=t??{};if(Array.isArray(s.results)){let e=Number(s.__count);return{rows:s.results.map(et),...Number.isFinite(e)&&void 0!==s.__count?{count:e}:{},..."string"==typeof s.__next?{next:s.__next}:{}}}return{rows:[et(s)]}}if(Array.isArray(e.value)){let t=Number(e["@odata.count"]);return{rows:e.value.map(et),...void 0!==e["@odata.count"]&&Number.isFinite(t)?{count:t}:{},..."string"==typeof e["@odata.nextLink"]?{next:e["@odata.nextLink"]}:{}}}return{rows:[et(e)]}}function en(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 ea=(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"}]]),el=(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 ei=e.i(68204),er=e.i(95211),eo=e.i(89932),ec=e.i(75117),ed=e.i(19286),eu=e.i(3792),em=e.i(95927),ep=e.i(69578),ex=e.i(37837),eh=e.i(28867),ef=e.i(80707),eb=e.i(56396);let eg=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/%/g,"\\%").replace(/_/g,"\\_"),ey={eq:"=",ne:"!=",gt:">",ge:">=",lt:"<",le:"<="},ej=e=>e.replace(/\//g,".");function ev(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?`${ej(e.field)} LIKE '%${eg(e.value)}%'`:"startswith"===e.op?`${ej(e.field)} LIKE '${eg(e.value)}%'`:"endswith"===e.op?`${ej(e.field)} LIKE '%${eg(e.value)}'`:`${ej(e.field)} ${ey[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 eN(e,t,s={}){let n=t.entitySets.find(t=>t.name===e.entitySet),a=e.select?.length?e.select.map(ej):n?.properties.length?n.properties.map(e=>e.name):["Id"],l=e.filterText?.trim()||ev(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 ${ej(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 ek(e,t){return`services/data/${t.soql?.apiVersion??"v62.0"}/query?q=${encodeURIComponent(e)}`}let ew=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(ew):n&&"object"==typeof n&&!Array.isArray(n)?t[s]=ew(n):t[s]=n);return t};function e$(e){let t=e??{};return{rows:Array.isArray(t.records)?t.records.map(ew):[],..."string"==typeof t.nextRecordsUrl?{next:t.nextRecordsUrl}:{}}}function eS(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=>ek(t,e),path:t=>ek(eN(t,e),e),countPath:t=>ek(eN(t,e,{countOnly:!0}),e),rows:e$,filter:(e,t)=>ev(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()||X(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:es,filter:(t,s)=>X(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 ee(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(ee(e," or ").length>1)return null;let t=[];for(let s of ee(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 eC=e=>e.type.includes(":")?e.type.split(":")[1]:e.type.replace(/^Edm\./,"");var eE=e.i(61230),eL=e.i(28950),eA=e.i(15060),eR=e.i(30617);function eT(e,t,s){sessionStorage.setItem(ep.OPEN_DRAFT_KEY,JSON.stringify(eO(e,t))),s.push("/")}function eO(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,eE.readableUrl)(n)}`,headers:a.BROWSABLE_KINDS.includes(e.kind)?[{key:"Accept",value:"application/json"}]:[],authMode:"inherit"}}function eI({connection:e,path:s,name:n}){let a=(0,eb.useToast)(),{index:l,refresh:i}=(0,z.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 z.workspaceApi.create({name:c.trim(),collection:u,request:eO(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)(em.Save,{size:13}),"Save as request"]}),(0,t.jsx)(ex.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)(ef.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 eD({connection:e,schema:s,set:n,initial:a,onOpenObject:l,onNeed:i,memoryKey:r}){let[o,c]=(0,eL.useRemembered)(`${r}:view`,"records"),[d,u]=(0,eL.useRemembered)(`${r}:visited`,()=>new Set(["records"])),[m,p]=(0,eL.useRemembered)(`${r}:path`,()=>eS(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)(eU,{connection:e,schema:s,onOpenObject:l}),(0,t.jsx)(eI,{connection:e,path:m,name:n.label??n.name}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>eT(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)(eV,{connection:e,schema:s,set:n,initial:a,onPath:p,onNeed:i,memoryKey:`${r}:records`}):"fields"===c?(0,t.jsx)(e2,{schema:s,set:n,onOpenObject:l,onNeed:i}):(0,t.jsx)(e5,{connection:e,schema:s,path:m,onPath:p,onOpenObject:l,memoryKey:`${r}:query`})},c):null)]})}function eU({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=eS(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)(ei.ClipboardPaste,{size:13}),"Paste URL"]}),(0,t.jsx)(ex.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 eF=[{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})),eq=["contains","startswith","endswith"],eM="apitestcenter-field-order",eB="atc:field-order";function ez(){let[e,t]=(0,E.useState)("az");return(0,E.useEffect)(()=>{let e=()=>{try{t("service"===localStorage.getItem(eM)?"service":"az")}catch{}};return e(),window.addEventListener(eB,e),()=>window.removeEventListener(eB,e)},[]),[e,e=>{try{localStorage.setItem(eM,e)}catch{}window.dispatchEvent(new Event(eB))}]}function eP(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 e_(e,t){return"service"===t?e:[...e].sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base"}))}function eW({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 eK=[{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 eH(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 eV({connection:e,schema:s,set:n,initial:a,onPath:l,onNeed:i,memoryKey:o}){let c=eS(s),d=(0,eb.useToast)(),{vars:u}=(0,z.useWorkspace)(),m=n.properties.map(e=>e.name),[p,x]=(0,eL.useRemembered)(`${o}:columns`,a?.select??[]),[h,f]=(0,eL.useRemembered)(`${o}:filters`,a?.filters??[]),[b,g]=(0,eL.useRemembered)(`${o}:filterText`,a?.filterText??null),[j,v]=(0,eL.useRemembered)(`${o}:order`,{field:a?.orderBy?.field??"",desc:!!a?.orderBy?.desc}),[N,w]=(0,eL.useRemembered)(`${o}:limit`,a?a.top??"all":50),[$,S]=(0,eL.useRemembered)(`${o}:withCount`,a?.count??!0),C=!!(s.suiteql&&n.properties.some(e=>e.ref)),[L,A]=(0,eL.useRemembered)(`${o}:names`,a?.names??!0),[R,T]=(0,eL.useRemembered)(`${o}:noNames`,[]),O=e=>C&&L&&!!n.properties.find(t=>t.name===e)?.ref&&!R.includes(e),[D,U]=(0,eL.useRemembered)(`${o}:rows`,[]),[F,q]=(0,eL.useRemembered)(`${o}:count`,void 0),[B,P]=(0,eL.useRemembered)(`${o}:next`,void 0),[_,W]=(0,eL.useRemembered)(`${o}:answer`,null),[K,H]=(0,E.useState)(!1),[V,Z]=(0,eL.useRemembered)(`${o}:error`,null),[Q,Y]=(0,eL.useRemembered)(`${o}:record`,null),G=a?.expand??[],J=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))},X=e=>{let t=J(e),s=e.indexOf("/");return s<0?t?.label:`${e.slice(0,s)} / ${t?.label??e.slice(s+1)}`},ee=h.filter(e=>e.field&&(e.value||!1===eq.includes(e.op))),et=c.filter(ee,n.properties),es=e=>({entitySet:n.name,select:p.length?p:void 0,expand:G.length?G:void 0,filters:ee,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 ei(){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 er(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(es(t+n)):void 0)}let[eo,ec]=(0,E.useState)(null),ed=(0,E.useRef)(!1);async function em(t,s){let a=D,l=s?B:void 0;ed.current=!1,ec({read:a.length});try{let s,i,o,m,p;for(;l&&a.length<eG&&!ed.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?er(s,n,F):void 0,ec({read:a.length})}let x=function(e){let t=[];for(let e of ey)t.push({name:e,label:X(e)??e,of:t=>eH(t,e)}),O(e)&&t.push({name:r(e),label:`${X(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=>en(e)).join("; "):"number"==typeof s&&Number.isFinite(s)?s:en(s)}))}}(a.slice(0,eG)),h=n.label??n.name;(0,eA.downloadBlob)((s=new Date,i=e=>String(e).padStart(2,"0"),o=h.replace(/[\\/:*?"<>|]+/g," ").replace(/\s+/g," ").trim().slice(0,60)||"export",`${o} ${s.getFullYear()}-${i(s.getMonth()+1)}-${i(s.getDate())} ${i(s.getHours())}${i(s.getMinutes())}.${t}`),"csv"===t?(m=e=>{let t=String(e);return/[",\r\n]/.test(t)||/^\s|\s$/.test(t)?`"${t.replace(/"/g,'""')}"`:t},p=[x.names,...x.rows].map(e=>e.map(m).join(",")),new Blob([`\uFEFF${p.join("\r\n")}\r
|
|
2
|
-
`],{type:"text/csv;charset=utf-8"})):(0,eR.xlsxBook)([{name:h,rows:[x.labels.map(e=>({v:e,s:eR.S.header})),...x.rows.map(e=>e.map(e=>({v:e})))]}]));let f=ed.current?" — stopped before the end":l?` — the first ${eG.toLocaleString()}; narrow it with conditions for the rest`:"";d(`Exported ${x.rows.length.toLocaleString()} ${1===x.rows.length?"record":"records"} as ${"csv"===t?"CSV":"Excel"}${f}`,"success")}catch(e){d(e instanceof Error?e.message:"Could not export","error")}finally{ec(null)}}async function ep(t){H(!0),Z(null);let s=t??c.path(es());t||(l(s),Y(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 ei();if(t.length){T(e=>[...new Set([...e,...t])]);let s=c.path({...es(),names:!0,noNames:[...new Set([...R,...t])]});l(s),n=await M.connectionsApi.get(e.id,s,u)}}if(W(n),n.error){Z([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(es()),u).catch(()=>null),s=Number(t?.body?.totalSize);t&&!t.error&&Number.isFinite(s)&&q(r=s)}P(er(a,i,r))}catch(e){Z(e instanceof Error?e.message:"Could not read the records")}finally{H(!1)}}let ex=(0,E.useRef)(null!=(0,eL.recall)(`${o}:answer`));(0,E.useEffect)(()=>{ex.current||ep()},[]);let[eh]=ez(),eg=eP(n.properties.filter(e=>e.filterable),eh),ey=p.length?p:m.filter(e=>D.some(t=>e in t)),ej=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??""}`}),ev="rounded-md border border-line bg-panel-2 px-2.5 py-1 text-xs text-ink",eN="number"!=typeof N||eK.some(e=>e.value===String(N))?eK:[{value:String(N),label:`${N} rows`},...eK];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)(ef.Select,{label:`Condition ${s+1} field`,value:e.field,onChange:e=>f(t=>t.map((t,n)=>n===s?{...t,field:e,byName:!!J(e)?.ref||void 0}:t)),options:eg.map(ej),minWidth:320,className:`${ev} max-w-[22rem]`}),J(e.field)?.ref?(0,t.jsx)(ef.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:ev}):null,(0,t.jsx)(ef.Select,{label:`Condition ${s+1} operator`,value:e.op,onChange:e=>f(t=>t.map((t,n)=>n===s?{...t,op:e}:t)),options:eF,className:ev}),(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 ep(),placeholder:e.byName?"name, e.g. Acme":(n=J(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:eg[0]?.name??"",op:"eq",value:"",...eg[0]?.ref?{byName:!0}:{}}]),disabled:!eg.length,children:[(0,t.jsx)(k.Plus,{size:13}),"Condition"]}):null,(0,t.jsx)(e0,{schema:s,set:n,value:p,onChange:x,onNeed:i}),(0,t.jsx)(ef.Select,{label:"Sort by",value:j.field,onChange:e=>v(t=>({...t,field:e})),className:ev,minWidth:320,buttonContent:j.field?`Sort: ${X(j.field)??j.field}`:"No sorting",options:[{value:"",label:"No sorting"},...eP(n.properties.filter(e=>e.sortable),eh).map(ej)]}),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)(el,{size:15}):(0,t.jsx)(ea,{size:15})}):null,null===b?(0,t.jsx)("button",{type:"button",className:"text-xs text-mute hover:text-ink",onClick:()=>g(et),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)(ef.Select,{label:"Rows",value:String(N),onChange:e=>w("all"===e?"all":Number(e)),options:eN,className:ev,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 ep(),disabled:K,children:[K?(0,t.jsx)(y.Loader2,{size:13,className:"animate-spin"}):(0,t.jsx)(eu.Play,{size:13}),"Run"]})]})]})]}),V?(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:V}):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:ey.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:[X(e)??e,X(e)&&X(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:()=>Y(s),"aria-selected":Q===s,className:`cursor-pointer ${Q===s?"bg-accent-dim/60":"hover:bg-panel-2"}`,children:ey.map(s=>{let n=eH(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=en(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:`${en(l)} — ID ${a}`,children:[en(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))})]}):K||V?null:(0,t.jsx)("p",{className:"px-6 py-8 text-sm text-mute",children:"No records match."})}),null!==Q&&D[Q]?(0,t.jsx)(eQ,{row:D[Q],index:Q,onClose:()=>Y(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",_?` \xb7 ${_.ms} ms`:""]}),B?(0,t.jsx)("button",{type:"button",className:"btn btn-secondary py-0.5 text-xs",onClick:()=>void ep(B),disabled:K,children:"Load more"}):null,D.length?(0,t.jsx)(eJ,{loaded:D.length,total:B?F:D.length,more:!!B,busy:eo,onExport:(e,t)=>void em(e,t),onStop:()=>ed.current=!0}):null,_?(0,t.jsx)(eX,{url:_.url,className:"ml-auto"}):null]})]})}let eZ="apitestcenter-record-panel-width";function eQ({row:e,index:s,onClose:n}){let[a,l]=(0,E.useState)(420);return(0,E.useEffect)(()=>{try{let e=Number(localStorage.getItem(eZ));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(eZ,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)(eo.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)(eY,{value:e})})]})}function eY({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)(eY,{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:en(a)})]},n))})}let eG=5e4;function eJ({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,eG).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)(ec.Download,{size:12}),"Export"]}),(0,t.jsx)(ex.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>eG?(0,t.jsxs)("span",{className:"text-xs text-mute",children:["(the first ",eG.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 eX({url:e,className:s=""}){let n=(0,eb.useToast)(),a=(0,eE.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)(eo.Copy,{size:12}),"Copy URL"]})]})}function e0({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]=ez(),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=eP(s.properties,b).filter(e=>k(e,e.name)),S=e_(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:eP(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)(er.Columns3,{size:13}),n.length?`Columns ${n.length}`:"All fields"]}),(0,t.jsx)(ex.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)(eh.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)(eW,{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)(e1,{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)(e1,{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 e1({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:eC(e)})]})})}function e2({schema:e,set:s,onOpenObject:n,onNeed:a}){let[l,i]=(0,E.useState)(""),[r,o]=(0,E.useState)(null),[c,d]=ez(),u=l.trim().toLowerCase(),m=eP(s.properties,c).filter(e=>!u||e.name.toLowerCase().includes(u)||(e.label??"").toLowerCase().includes(u)||e.type.toLowerCase().includes(u)),p=e_(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)(eW,{order:c,onChange:d})]}),(0,t.jsx)(e3,{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)(e3,{fields:eP(l.properties,c)})}):null]},s.name)})})]}):null]})}function e3({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)(ed.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:[eC(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 e5({connection:e,schema:s,path:n,onPath:a,onOpenObject:l,memoryKey:i}){var r,o;let{vars:c}=(0,z.useWorkspace)(),[d,u]=(0,eL.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=eS(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)(eu.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)(eX,{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 e4=e.i(39170),e6=e.i(17847);function e7({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 e8({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 e9({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)(e8,{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)(ex.Popover,{anchor:p,open:u,onClose:()=>m(!1),label:`Actions for ${e.name}`,width:220,role:"menu",children:[(0,t.jsx)(e6.MenuItem,{icon:v.Pencil,label:"Edit",onSelect:()=>(m(!1),r())}),a.BROWSABLE_KINDS.includes(e.kind)?(0,t.jsx)(e6.MenuItem,{icon:w.RefreshCw,label:"Read objects again",onSelect:()=>(m(!1),i(),o())}):null,(0,t.jsx)(e6.MenuSeparator,{}),(0,t.jsx)(e6.MenuItem,{icon:S.Trash2,label:"Delete",danger:!0,onSelect:()=>(m(!1),c())})]})]}),d]})}function te({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 tt({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:()=>eT(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,eb.useToast)(),i=(0,e4.useConfirm)(),{vars:r}=(0,z.useWorkspace)(),[o,c]=(0,E.useState)(null),[d,u]=(0,E.useState)(null),[m,p]=(0,eL.useRemembered)("connections:active",null),[x,h]=(0,eL.useRemembered)("connections:schema",null),[f,b]=(0,E.useState)(null),[g,j]=(0,E.useState)(!1),[v,N]=(0,eL.useRemembered)("connections:object",null),[w,$]=(0,eL.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,eL.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 B(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&&B(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)(e7,{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)(e9,{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)(te,{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)(eD,{memoryKey:`connections:${O.id}/${F.name}/${w.nonce}`,connection:O,schema:x.schema,set:F,initial:w.query,onOpenObject:S,onNeed:e=>void B(e)},`${O.id}/${F.name}/${w.nonce}`):O?(0,t.jsx)(tt,{connection:O,schema:x?.id===O.id?x:null}):null})]}),C?(0,t.jsx)(Y,{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)}]);
|
/package/dist/ui/_next/static/{u2V4Oq6faI2f3slbxdtb5 → 0pb5ehfBVj_I-XduzZBR3}/_buildManifest.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/ui/_next/static/{u2V4Oq6faI2f3slbxdtb5 → 0pb5ehfBVj_I-XduzZBR3}/_ssgManifest.js
RENAMED
|
File without changes
|