PageSourceSearch

https://boombam.app/assets/ApiManagement-CQUMOZMm.js

js boombam.app collected 2026-10-04 13:34:19 UTC 11,720 bytes, 1 lines download raw bytes

1import{r as h,_ as z,a5 as R,u as B,bW as Q,a as E,a6 as y,j as e,d4 as g,k as V,c_ as _,m as G,B as i,ak as Y,cb as H,aD as J,al as W,am as X,an as Z,ab as t,aF as ee,$ as se,a0 as ae,a1 as te,a2 as ie,a3 as K,bd as ne,ap as re,aq as le,C as o,e as x,b as v,d as N,s as f,au as ce,bp as de,E as oe,X as xe,a7 as b}from"./index-CuSEeJFb.js";import{T as me,a as he,b as A,c as P}from"./tabs-CcPOXtvT.js";import{C as ue}from"./copy-Ctw93tQ7.js";function ve(){var S,T;const[m,je]=h.useState(null),[D,u]=h.useState(!1),[k,$]=h.useState({}),[r,l]=h.useState({name:"",environment:"production",permissions:[],allowedEndpoints:[],notes:"",expiresAt:""}),{toast:n}=z(),j=R(),{subscription:C}=B(),w=C&&Q(C.plan,"apiAccess"),{data:c,isLoading:q}=E({queryKey:["/api/v1/keys"],enabled:w});E({queryKey:["/api/v1/keys",m==null?void 0:m.id,"usage"],enabled:!!m});const p=y({mutationFn:async s=>await b("/api/v1/keys",{method:"POST",body:JSON.stringify(s)}),onSuccess:s=>{j.invalidateQueries({queryKey:["/api/v1/keys"]}),u(!1),l({name:"",environment:"production",permissions:[],allowedEndpoints:[],notes:"",expiresAt:""}),n({title:"API Key Created",description:`Your API key: ${s.key.apiKey}`,duration:3e4})},onError:s=>{n({title:"Error",description:s.message||"Failed to create API key",variant:"destructive"})}}),F=y({mutationFn:async s=>{await b(`/api/v1/keys/${s}`,{method:"DELETE"})},onSuccess:()=>{j.invalidateQueries({queryKey:["/api/v1/keys"]}),n({title:"Success",description:"API key deleted successfully"})},onError:s=>{n({title:"Error",description:s.message||"Failed to delete API key",variant:"destructive"})}}),L=y({mutationFn:async({keyId:s,isActive:a})=>{await b(`/api/v1/keys/${s}`,{method:"PUT",body:JSON.stringify({isActive:a})})},onSuccess:()=>{j.invalidateQueries({queryKey:["/api/v1/keys"]}),n({title:"Success",description:"API key updated successfully"})},onError:s=>{n({title:"Error",description:s.message||"Failed to update API key",variant:"destructive"})}}),M=s=>{navigator.clipboard.writeText(s),n({title:"Copied",description:"API key copied to clipboard"})},I=s=>new Date(s).toLocaleDateString()+" "+new Date(s).toLocaleTimeString(),U=["read","write","manage","admin"];return w?e.jsxs("div",{className:"space-y-6","data-testid":"api-management-page",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(g,{className:"w-8 h-8 text-orange-600"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"API Management"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Manage your API keys and monitor usage"})]})]}),e.jsxs(Y,{open:D,onOpenChange:u,children:[e.jsx(H,{asChild:!0,children:e.jsxs(i,{"data-testid":"create-api-key-button",children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),"Create API Key"]})}),e.jsxs(W,{className:"max-w-2xl",children:[e.jsx(X,{children:e.jsx(Z,{children:"Create New API Key"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(t,{htmlFor:"key-name",children:"Name"}),e.jsx(ee,{id:"key-name",placeholder:"My Application API Key",value:r.name,onChange:s=>l(a=>({...a,name:s.target.value})),"data-testid":"input-key-name"})]}),e.jsxs("div",{children:[e.jsx(t,{htmlFor:"environment",children:"Environment"}),e.jsxs(se,{value:r.environment,onValueChange:s=>l(a=>({...a,environment:s})),children:[e.jsx(ae,{"data-testid":"select-environment",children:e.jsx(te,{})}),e.jsxs(ie,{children:[e.jsx(K,{value:"development",children:"Development"}),e.jsx(K,{value:"production",children:"Production"})]})]})]}),e.jsxs("div",{children:[e.jsx(t,{children:"Permissions"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:U.map(s=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ne,{id:`perm-${s}`,checked:r.permissions.includes(s),onCheckedChange:a=>{l(a?d=>({...d,permissions:[...d.permissions,s]}):d=>({...d,permissions:d.permissions.filter(O=>O!==s)}))},"data-testid":`checkbox-permission-${s}`}),e.jsx(t,{htmlFor:`perm-${s}`,className:"text-sm capitalize",children:s})]},s))})]}),e.jsxs("div",{children:[e.jsx(t,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(re,{id:"notes",placeholder:"API key description or usage notes",value:r.notes,onChange:s=>l(a=>({...a,notes:s.target.value})),"data-testid":"textarea-notes"})]})]}),e.jsxs(le,{children:[e.jsx(i,{variant:"outline",onClick:()=>u(!1),"data-testid":"button-cancel-create",children:"Cancel"}),e.jsx(i,{onClick:()=>p.mutate(r),disabled:!r.name||p.isPending,"data-testid":"button-confirm-create",children:p.isPending?"Creating...":"Create API Key"})]})]})]})]}),e.jsxs(me,{defaultValue:"keys",className:"space-y-4",children:[e.jsxs(he,{children:[e.jsx(A,{value:"keys","data-testid":"tab-api-keys",children:"API Keys"}),e.jsx(A,{value:"usage","data-testid":"tab-usage",children:"Usage Analytics"}),e.jsx(A,{value:"docs","data-testid":"tab-documentation",children:"Documentation"})]}),e.jsx(P,{value:"keys",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:q?e.jsx(o,{children:e.jsx(x,{className:"p-6",children:e.jsx("div",{className:"text-center",children:"Loading API keys..."})})}):((S=c==null?void 0:c.keys)==null?void 0:S.length)===0?e.jsx(o,{children:e.jsx(x,{className:"p-6",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(g,{className:"w-12 h-12 text-gray-400 mx-auto"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"No API Keys"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Create your first API key to start using the API"})]})})}):(T=c==null?void 0:c.keys)==null?void 0:T.map(s=>e.jsxs(o,{"data-testid":`api-key-card-${s.id}`,children:[e.jsxs(v,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(N,{className:"text-base font-medium",children:s.name}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(f,{variant:s.isActive?"default":"secondary","data-testid":`status-${s.id}`,children:s.isActive?"Active":"Inactive"}),e.jsx(f,{variant:"outline",children:s.tier}),e.jsx(f,{variant:"outline",children:s.environment})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(i,{variant:"outline",size:"sm",onClick:()=>L.mutate({keyId:s.id,isActive:!s.isActive}),"data-testid":`toggle-status-${s.id}`,children:s.isActive?"Disable":"Enable"}),e.jsx(i,{variant:"outline",size:"sm",onClick:()=>F.mutate(s.id),"data-testid":`delete-key-${s.id}`,children:e.jsx(ce,{className:"w-4 h-4"})})]})]}),e.jsx(x,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t,{className:"text-sm font-medium",children:"API Key:"}),e.jsxs("div",{className:"flex items-center space-x-2 flex-1",children:[e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded text-sm flex-1","data-testid":`key-display-${s.id}`,children:k[s.id]?`${s.keyPrefix}${"*".repeat(40)}`:`${s.keyPrefix}${"*".repeat(40)}`}),e.jsx(i,{variant:"outline",size:"sm",onClick:()=>$(a=>({...a,[s.id]:!a[s.id]})),"data-testid":`toggle-visibility-${s.id}`,children:k[s.id]?e.jsx(de,{className:"w-4 h-4"}):e.jsx(oe,{className:"w-4 h-4"})}),e.jsx(i,{variant:"outline",size:"sm",onClick:()=>M(s.keyPrefix+"*".repeat(40)),"data-testid":`copy-key-${s.id}`,children:e.jsx(ue,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(t,{className:"font-medium",children:"Total Requests:"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:s.totalRequests.toLocaleStr
1ing()})]}),e.jsxs("div",{children:[e.jsx(t,{className:"font-medium",children:"Last Used:"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:s.lastUsed?I(s.lastUsed):"Never"})]}),e.jsxs("div",{children:[e.jsx(t,{className:"font-medium",children:"Created:"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:I(s.createdAt)})]}),e.jsxs("div",{children:[e.jsx(t,{className:"font-medium",children:"Permissions:"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:s.permissions.join(", ")||"None"})]})]}),s.notes&&e.jsxs("div",{children:[e.jsx(t,{className:"font-medium",children:"Notes:"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:s.notes})]})]})})]},s.id))})}),e.jsx(P,{value:"usage",className:"space-y-4",children:e.jsxs(o,{children:[e.jsx(v,{children:e.jsxs(N,{className:"flex items-center space-x-2",children:[e.jsx(xe,{className:"w-5 h-5"}),e.jsx("span",{children:"API Usage Analytics"})]})}),e.jsx(x,{children:e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Select an API key to view detailed usage analytics and request history."})})]})}),e.jsx(P,{value:"docs",className:"space-y-4",children:e.jsxs(o,{children:[e.jsx(v,{children:e.jsx(N,{children:"API Documentation"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-2",children:"Authentication"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:"Include your API key in the Authorization header:"}),e.jsx("code",{className:"block bg-gray-100 dark:bg-gray-800 p-3 rounded text-sm",children:"Authorization: Bearer YOUR_API_KEY"})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-2",children:"Base URL"}),e.jsx("code",{className:"block bg-gray-100 dark:bg-gray-800 p-3 rounded text-sm",children:"https://your-domain.com/api/v1"})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-2",children:"Rate Limits"}),e.jsxs("ul",{className:"text-sm text-gray-600 dark:text-gray-400 space-y-1",children:[e.jsx("li",{children:"• Starter: 30 requests/minute"}),e.jsx("li",{children:"• Professional: 60 requests/minute"}),e.jsx("li",{children:"• Agency: 200 requests/minute"}),e.jsx("li",{children:"• Enterprise: 500 requests/minute"}),e.jsx("li",{children:"• Admin: 1000 requests/minute"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold mb-2",children:"Common Endpoints"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("code",{children:"GET /api/v1/campaigns"}),e.jsx("span",{className:"text-gray-500",children:"List campaigns"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("code",{children:"POST /api/v1/campaigns"}),e.jsx("span",{className:"text-gray-500",children:"Create campaign"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("code",{children:"GET /api/v1/content"}),e.jsx("span",{className:"text-gray-500",children:"List content"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("code",{children:"POST /api/v1/content/generate"}),e.jsx("span",{className:"text-gray-500",children:"Generate content"})]})]})]})]})]})})]})]}):e.jsxs("div",{className:"space-y-6","data-testid":"api-management-page",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(g,{className:"w-8 h-8 text-orange-600"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"API Management"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Manage your API keys and access"})]})]}),e.jsxs(V,{"data-testid":"upgrade-alert",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsxs(G,{children:["API access is available for Agency, Enterprise, and Admin tiers.",e.jsx(i,{variant:"link",className:"px-0 h-auto font-semibold",children:"Upgrade your plan"})," to access API features."]})]})]})}export{ve as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.