PageSourceSearch

https://topdealspy.com/assets/apikeys-BNh1YpbP.js

js topdealspy.com collected 2026-10-07 22:28:02 UTC 11,130 bytes, 1 lines download raw bytes

1import{b as r,f as ee,r as l,j as t}from"./main-50EuRcKd.js";import{D as te}from"./dashboard-layout-DMTXZwuY.js";import{D as se}from"./data-table-pagination-Dwfc3LrQ.js";import{b as T,B as h}from"./button-DEQGcbHD.js";import{D as R,a as ne,b as E,c as F,d as q,e as O,f as V}from"./dialog-Dl7MyrzA.js";import{D as ae,g as re,h as ie,o as oe}from"./locale-switcher-C6mm9Dwm.js";import{I as L}from"./input-hiZYFofq.js";import{L as le}from"./label-B1jKpNAZ.js";import{S as ce}from"./skeleton-fZDpUOwY.js";import{T as _e,a as ue,b as x,c as pe,d as de,e as z}from"./table-B2Oy0zVo.js";import{f as B}from"./formatter-Ch4RMnre.js";import{c as H}from"./utils-CDN07tui.js";import{u as ye,g as me,a as ge,f as Q}from"./index-DSlNs4A4.js";import{I as ke,a as he}from"./IconTrash-DRSMbBjd.js";import{I as fe}from"./IconPlus-ChWeuXUa.js";import{b as xe}from"./getPseudoElementBounds-CVEGkeAe.js";import{a as N}from"./client-BSxFer0h.js";import{u as je}from"./useQuery-CXOJW_mt.js";import{u as J}from"./QueryClientProvider-ELS2stEQ.js";import{u as U}from"./useMutation-BV_8Fi1k.js";import{k as Ce}from"./query-BEAnUETd.js";import{t as f}from"./index-LWPMHgap.js";import{c as be}from"./common_settings-CsWUEALI.js";import"./dashboard-header-BnitgVQJ.js";import"./useRender-CcfVH1tV.js";import"./useRenderElement-DKbhWM6v.js";import"./separator-ByCxBiqc.js";import"./Separator-DLvKW_wo.js";import"./select-NiKjZSnd.js";import"./IconSelector-Brqu3w-s.js";import"./IconChevronUp-5sUlWq_s.js";import"./createBaseUIEventDetails-B5pL7XeQ.js";import"./useIsoLayoutEffect-BYqbI5TR.js";import"./CompositeList-D8lWML6F.js";import"./useRegisterFieldControl-BFmnIMsT.js";import"./useTransitionStatus-CJEp95nG.js";import"./FormContext-ChC0Iqs_.js";import"./owner-CvMgaIeV.js";import"./useTimeout-CDuwoMnI.js";import"./index-B_jtOnfb.js";import"./CompositeItem-CFsRTrtR.js";import"./mutation-C9dKemFM.js";const we=()=>"Cancel",Pe=()=>"取消",Ae=((s={},e={})=>(e.locale??r())==="en"?we():Pe()),ze=()=>"Actions",Ne=()=>"操作",G=((s={},e={})=>(e.locale??r())==="en"?ze():Ne()),De=()=>"Created at",Ie=()=>"创建时间",Ke=((s={},e={})=>(e.locale??r())==="en"?De():Ie()),ve=()=>"Expires at",Se=()=>"过期时间",Me=((s={},e={})=>(e.locale??r())==="en"?ve():Se()),Te=()=>"Key",Re=()=>"密钥",Ee=((s={},e={})=>(e.locale??r())==="en"?Te():Re()),Fe=()=>"Name",qe=()=>"名称",Oe=((s={},e={})=>(e.locale??r())==="en"?Fe():qe()),Ve=()=>"Create",Le=()=>"创建",Be=((s={},e={})=>(e.locale??r())==="en"?Ve():Le()),He=()=>"Create API Key",Qe=()=>"创建 API 密钥",Ge=((s={},e={})=>(e.locale??r())==="en"?He():Qe()),Ye=()=>"Give your API key a name to identify it later",$e=()=>"为 API 密钥命名以便后续识别",Je=((s={},e={})=>(e.locale??r())==="en"?Ye():$e()),Ue=()=>"Create API Key",We=()=>"创建 API 密钥",Xe=((s={},e={})=>(e.locale??r())==="en"?Ue():We()),Ze=()=>"Could not create the API key. Please try again.",et=()=>"无法创建 API 密钥,请重试。",tt=((s={},e={})=>(e.locale??r())==="en"?Ze():et()),st=()=>"API key created successfully",nt=()=>"API 密钥创建成功",at=((s={},e={})=>(e.locale??r())==="en"?st():nt()),rt=()=>"Creating…",it=()=>"创建中…",ot=((s={},e={})=>(e.locale??r())==="en"?rt():it()),lt=()=>"Delete",ct=()=>"删除",_t=((s={},e={})=>(e.locale??r())==="en"?lt():ct()),ut=()=>"Could not delete the API key. Please try again.",pt=()=>"无法删除 API 密钥,请重试。",dt=((s={},e={})=>(e.locale??r())==="en"?ut():pt()),yt=()=>"API key deleted successfully",mt=()=>"API 密钥已删除",gt=((s={},e={})=>(e.locale??r())==="en"?yt():mt()),kt=()=>"Manage your API keys",ht=()=>"管理用于身份验证的 API 密钥",ft=((s={},e={})=>(e.locale??r())==="en"?kt():ht()),xt=()=>"Done",jt=()=>"完成",Ct=((s={},e={})=>(e.locale??r())==="en"?xt():jt()),bt=()=>"Name",wt=()=>"密钥名称",Pt=((s={},e={})=>(e.locale??r())==="en"?bt():wt()),At=()=>"Enter a name for your API key",zt=()=>"请输入 API 密钥的名称",Nt=((s={},e={})=>(e.locale??r())==="en"?At():zt()),Dt=()=>"Never",It=()=>"永不过期",Kt=((s={},e={})=>(e.locale??r())==="en"?Dt():It()),vt=()=>"Copy this key now, you will not be able to see it again",St=()=>"请立即复制并保存此密钥,之后将无法再次查看",Mt=((s={},e={})=>(e.locale??r())==="en"?vt():St()),Tt=()=>"Your new API key",Rt=()=>"您的新 API 密钥",Et=((s={},e={})=>(e.locale??r())==="en"?Tt():Rt()),Ft=()=>"No API keys found",qt=()=>"未找到 API 密钥",Ot=((s={},e={})=>(e.locale??r())==="en"?Ft():qt()),Vt=()=>"API Keys",Lt=()=>"API 密钥",Y=((s={},e={})=>(e.locale??r())==="en"?Vt():Lt());const Bt=[["path",{d:"M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]],Ht=ee("outline","copy","Copy",Bt);function Qt({columns:s}){return t.jsx(x,{className:"h-14",children:Array.from({length:s}).map((e,n)=>t.jsx(z,{className:"py-3",children:t.jsx(ce,{className:"h-4 w-24"})},n))})}function Gt(s){return s?`${s}••••••••••••`:"••••••••••••••••"}function $(s){return s==null?null:s instanceof Date?s:new Date(s)}function Yt({data:s,total:e,pageIndex:n,pageSize:o,loading:d,creating:c,onPageChange:u,onPageSizeChange:j,onDelete:y,onCreate:C}){const[_,m]=l.useState({}),[g,b]=l.useState(!1),[w,D]=l.useState(""),[W,I]=l.useState(!1),[K,v]=l.useState(""),[X,P]=l.useState(!1),A=l.useMemo(()=>[{id:"name",accessorKey:"name",header:Oe(),cell:({row:a})=>t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("span",{className:"font-medium",children:a.original.n
1ame??"—"})}),minSize:120,size:140,enableSorting:!1},{id:"key",accessorKey:"start",header:Ee(),cell:({row:a})=>t.jsx("span",{children:Gt(a.original.start)}),minSize:180,size:220,enableSorting:!1},{id:"createdAt",accessorKey:"createdAt",header:Ke(),cell:({row:a})=>{const i=$(a.original.createdAt);return i?B(i):"—"},minSize:140,size:160,enableSorting:!1},{id:"expiresAt",accessorKey:"expiresAt",header:Me(),cell:({row:a})=>{const i=$(a.original.expiresAt??null);return i?B(i):Kt()},minSize:140,size:160,enableSorting:!1},{id:"actions",header:G(),cell:({row:a})=>{const i=a.original.id;return t.jsxs(ae,{children:[t.jsxs(re,{className:H(T({variant:"ghost",size:"icon"})),children:[t.jsx(ke,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:G()})]}),t.jsx(ie,{align:"end",children:t.jsxs(oe,{onClick:()=>y(i),children:[t.jsx(he,{className:"mr-2 size-4"}),_t()]})})]})},minSize:80,size:100,enableSorting:!1}],[y]),k=ye({data:s,columns:A,pageCount:Math.max(1,Math.ceil(e/o)),state:{columnFilters:[],columnVisibility:_,pagination:{pageIndex:n,pageSize:o}},onColumnVisibilityChange:m,onPaginationChange:a=>{const i=typeof a=="function"?a({pageIndex:n,pageSize:o}):a;i.pageSize!==o?(j(i.pageSize),n!==0&&u(0)):i.pageIndex!==n&&u(i.pageIndex)},getCoreRowModel:ge(),getPaginationRowModel:me(),manualPagination:!0,manualFiltering:!0,enableMultiSort:!1}),S=async()=>{if(!w.trim())return;const a=await C(w.trim());D(""),b(!1),a?.key&&(v(a.key),I(!0))},Z=async()=>{await navigator.clipboard.writeText(K),P(!0),setTimeout(()=>P(!1),2e3)},M=()=>{I(!1),v(""),P(!1)};return t.jsxs("div",{className:"w-full space-y-4",children:[t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs(R,{open:g,onOpenChange:b,children:[t.jsxs(ne,{className:H(T({variant:"default",size:"default"})),children:[t.jsx(fe,{className:"size-4"}),Ge()]}),t.jsxs(E,{children:[t.jsxs(F,{children:[t.jsx(q,{children:Xe()}),t.jsx(O,{children:Je()})]}),t.jsx("div",{className:"grid gap-4 py-4",children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(le,{htmlFor:"key-name",className:"shrink-0",children:Pt()}),t.jsx(L,{id:"key-name",placeholder:Nt(),value:w,onChange:a=>D(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!c&&S()},disabled:c})]})}),t.jsxs(V,{children:[t.jsx(h,{variant:"outline",onClick:()=>b(!1),disabled:c,children:Ae()}),t.jsx(h,{onClick:S,disabled:c,children:c?ot():Be()})]})]})]})}),t.jsx(R,{open:W,onOpenChange:M,children:t.jsxs(E,{children:[t.jsxs(F,{children:[t.jsx(q,{children:Et()}),t.jsx(O,{children:Mt()})]}),t.jsx("div",{className:"grid gap-4 py-4",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(L,{readOnly:!0,value:K,className:"text-sm"}),t.jsx(h,{variant:"outline",size:"icon",onClick:Z,className:"shrink-0",children:X?t.jsx(xe,{className:"size-4 text-green-500"}):t.jsx(Ht,{className:"size-4"})})]})}),t.jsx(V,{children:t.jsx(h,{onClick:M,children:Ct()})})]})}),t.jsxs("div",{className:"relative flex flex-col gap-4 overflow-auto",children:[t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs(_e,{children:[t.jsx(ue,{className:"bg-muted sticky top-0 z-10",children:k.getHeaderGroups().map(a=>t.jsx(x,{children:a.headers.map(i=>t.jsx(pe,{children:i.isPlaceholder?null:Q(i.column.columnDef.header,i.getContext())},i.id))},a.id))}),t.jsx(de,{children:d?Array.from({length:o}).map((a,i)=>t.jsx(Qt,{columns:A.length},i)):k.getRowModel().rows?.length?k.getRowModel().rows.map(a=>t.jsx(x,{"data-state":a.getIsSelected()?"selected":void 0,className:"h-14",children:a.getVisibleCells().map(i=>t.jsx(z,{className:"py-3",children:Q(i.column.columnDef.cell,i.getContext())},i.id))},a.id)):t.jsx(x,{children:t.jsx(z,{colSpan:A.length,className:"h-24 text-center",children:Ot()})})})]})}),t.jsx(se,{table:k,className:"px-0"})]})]})}const p={all:["apikeys"],lists:()=>[...p.all,"lists"],list:s=>[...p.lists(),s]};function $t(s,e){return je({queryKey:p.list({pageIndex:s,pageSize:e}),queryFn:async()=>{const n=await N.apiKey.list({query:{limit:e,offset:s*e,sortBy:"createdAt",sortDirection:"desc"}});if(n.error)throw new Error(n.error.message||"Failed to fetch API keys");const o=n.data??[];return{items:o,total:o.length}},placeholderData:Ce})}function Jt(){const s=J();return U({mutationFn:async({name:e})=>{const{data:n,error:o}=await N.apiKey.create({name:e});if(o)throw new Error(o.message||"Failed to create API key");return n},onSuccess:()=>{s.invalidateQueries({queryKey:p.all})}})}function Ut(){const s=J();return U({mutationFn:async({keyId:e})=>{const{error:n}=await N.apiKey.delete({keyId:e});if(n)throw new Error(n.message||"Failed to delete API key")},onSuccess:()=>{s.invalidateQueries({queryKey:p.all})}})}function Wt(){const[s,e]=l.useState(0),[n,o]=l.useState(10),{data:d,isLoading:c}=$t(s,n),u=Jt(),j=Ut(),y=_=>new Promise(m=>{u.mutate({name:_},{onSuccess:g=>{f.success(at()),m(g?.key?{key:g.key}:void 0)},onError:()=>{f.error(tt()),m(void 0)}})}),C=_=>{j.mutate({keyId:_},{onSuccess:()=>f.success(gt()),onError:()=>f.error(dt())})};return t.jsx(Yt,{data:d?.items??[],total:d?.total??0,pageIndex:s,pageSize:n,loading:c,creating:u.isPending,onPageChange:e,onPageSizeChange:_=>{o(_),e(0)},onDelete:C,onCreate:y})}
1function Os(){const s=[{label:be(),isCurrentPage:!1},{label:Y(),isCurrentPage:!0}];return t.jsx(te,{breadcrumbs:s,title:Y(),description:ft(),children:t.jsx(Wt,{})})}export{Os as component};

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.