@cartanova/qgrid-cli 1.7.3 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/bundle/dist/application/qgrid/qgrid.dispatcher.js +72 -39
  2. package/bundle/dist/application/qgrid/qgrid.frame.js +12 -25
  3. package/bundle/dist/application/qgrid/qgrid.types.js +17 -4
  4. package/bundle/dist/application/qgrid/token-subscriber.js +149 -0
  5. package/bundle/dist/application/qgrid/token-trigger-setup.js +69 -0
  6. package/bundle/dist/application/sonamu.generated.sso.js +1 -1
  7. package/bundle/dist/application/token/token.types.js +1 -1
  8. package/bundle/dist/i18n/sd.generated.js +2 -2
  9. package/bundle/dist/migrations/20260410171405_create__request_logs.js +1 -1
  10. package/bundle/dist/migrations/20260410171406_create__tokens.js +1 -1
  11. package/bundle/dist/migrations/20260411120624_alter_tokens_alter2.js +1 -1
  12. package/bundle/dist/migrations/20260415134649_alter_request_logs_alter1.js +1 -1
  13. package/bundle/dist/migrations/20260421223627_alter_request_logs_add1_alter1.js +1 -1
  14. package/bundle/dist/migrations/20260423180818_alter_request_logs_add1_alter1.js +1 -1
  15. package/bundle/dist/migrations/20260423182017_alter_request_logs_add2_drop1_alter1.js +1 -1
  16. package/bundle/dist/migrations/20260423183613_alter_request_logs_add1_alter1.js +1 -1
  17. package/bundle/dist/sonamu.config.js +22 -36
  18. package/bundle/dist/testing/setup-mocks.js +1 -1
  19. package/bundle/dist/utils/subset-loaders.js +1 -1
  20. package/bundle/src/application/qgrid/qgrid.dispatcher.ts +103 -46
  21. package/bundle/src/application/qgrid/qgrid.frame.ts +14 -26
  22. package/bundle/src/application/qgrid/qgrid.types.ts +13 -0
  23. package/bundle/src/application/qgrid/token-subscriber.ts +176 -0
  24. package/bundle/src/application/qgrid/token-trigger-setup.ts +80 -0
  25. package/bundle/src/application/request-log/request-log.entity.json +3 -1
  26. package/bundle/src/application/sonamu.generated.http +2 -1
  27. package/bundle/src/application/sonamu.generated.sso.ts +5 -5
  28. package/bundle/src/application/token/token.types.ts +1 -1
  29. package/bundle/src/i18n/sd.generated.ts +1 -1
  30. package/bundle/src/migrations/20260410171405_create__request_logs.ts +1 -1
  31. package/bundle/src/migrations/20260410171406_create__tokens.ts +1 -1
  32. package/bundle/src/migrations/20260411120624_alter_tokens_alter2.ts +1 -1
  33. package/bundle/src/migrations/20260415134649_alter_request_logs_alter1.ts +1 -1
  34. package/bundle/src/migrations/20260421223627_alter_request_logs_add1_alter1.ts +1 -1
  35. package/bundle/src/migrations/20260423180818_alter_request_logs_add1_alter1.ts +1 -1
  36. package/bundle/src/migrations/20260423182017_alter_request_logs_add2_drop1_alter1.ts +1 -1
  37. package/bundle/src/migrations/20260423183613_alter_request_logs_add1_alter1.ts +1 -1
  38. package/bundle/src/sonamu.config.ts +33 -39
  39. package/bundle/src/testing/setup-mocks.ts +1 -1
  40. package/bundle/src/typings/fastify.d.ts +1 -1
  41. package/bundle/src/typings/sonamu.d.ts +3 -2
  42. package/bundle/src/utils/subset-loaders.ts +1 -1
  43. package/bundle/web-dist/client/assets/{index-DUmwX7rR.js → index-DxJOOfGV.js} +3 -3
  44. package/bundle/web-dist/client/assets/{logs-ci_3vzTT.js → logs-D83MPvLO.js} +1 -1
  45. package/bundle/web-dist/client/assets/{routes-Ch5LFN0K.js → routes-C1PeZiBp.js} +1 -1
  46. package/bundle/web-dist/client/assets/{sd.generated-CIOZewtL.js → sd.generated-C9WnMJm4.js} +1 -1
  47. package/bundle/web-dist/client/assets/{services.generated-BrB-RELO.js → services.generated-BV5C1PQa.js} +1 -1
  48. package/bundle/web-dist/client/assets/{show-D3N15Krg.js → show-WxeogUIk.js} +1 -1
  49. package/bundle/web-dist/client/assets/tokens--RfCPd1y.js +1 -0
  50. package/bundle/web-dist/client/index.html +2 -2
  51. package/bundle/web-dist/server/assets/{copy-CKCGxwII.js → copy-SIUvcEcZ.js} +1 -1
  52. package/bundle/web-dist/server/assets/{lazyRouteComponent-BlvOfJIF.js → lazyRouteComponent-CcyhCAoL.js} +2 -2
  53. package/bundle/web-dist/server/assets/{logs-CDacVwTQ.js → logs-9j6ES80h.js} +3 -3
  54. package/bundle/web-dist/server/assets/{routes-BLm-zF86.js → routes-DQh4d03H.js} +2 -2
  55. package/bundle/web-dist/server/assets/{sd.generated-CIg_jf8e.js → sd.generated-CkiEsOwK.js} +1 -1
  56. package/bundle/web-dist/server/assets/{services.generated-wCfUuY7Z.js → services.generated-Q2ZIxMdn.js} +5 -4
  57. package/bundle/web-dist/server/assets/{shim-Dq_Izqnc.js → shim-BYpcQGN1.js} +1 -1
  58. package/bundle/web-dist/server/assets/{show-DjJyZunM.js → show-j1j13Hq1.js} +4 -4
  59. package/bundle/web-dist/server/assets/{tokens-rQIIgqMo.js → tokens-hSHCLF_7.js} +24 -5
  60. package/bundle/web-dist/server/entry-server.generated.js +7 -7
  61. package/package.json +1 -1
  62. package/bundle/web-dist/client/assets/tokens-BAlIaa6X.js +0 -1
@@ -1,7 +1,7 @@
1
- import { D as require_react, E as require_jsx_runtime, T as useQueryClient, _ as date, b as object, c as zArrayable, g as custom, h as boolean, i as SonamuQueryMode, m as bigint, ot as __toESM, p as _enum, v as int, x as string, y as number } from "./sd.generated-CIg_jf8e.js";
2
- import { r as TokenService, t as QgridService } from "./services.generated-wCfUuY7Z.js";
1
+ import { D as require_react, E as require_jsx_runtime, T as useQueryClient, _ as date, b as object, c as zArrayable, g as custom, h as boolean, i as SonamuQueryMode, m as bigint, ot as __toESM, p as _enum, v as int, x as string, y as number } from "./sd.generated-CkiEsOwK.js";
2
+ import { r as TokenService, t as QgridService } from "./services.generated-Q2ZIxMdn.js";
3
3
  import { a as lucideKeyRound, i as ro, r as Q } from "../entry-server.generated.js";
4
- import { n as lucideCheck, t as lucideCopy } from "./copy-CKCGxwII.js";
4
+ import { n as lucideCheck, t as lucideCopy } from "./copy-SIUvcEcZ.js";
5
5
  //#region ~icons/lucide/eye.jsx
6
6
  var import_react = /* @__PURE__ */ __toESM(require_react());
7
7
  var import_jsx_runtime = require_jsx_runtime();
@@ -368,12 +368,24 @@ var lucideTrash2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg",
368
368
  d: "M10 11v6m4-6v6m5-11v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"
369
369
  })
370
370
  });
371
+ //#endregion
372
+ //#region src/services/qgrid/qgrid.types.ts
373
+ /**
374
+ * @generated
375
+ * API에서 동기화된 파일입니다. 직접 수정하지 마세요.
376
+ */
377
+ var Effort = _enum([
378
+ "low",
379
+ "medium",
380
+ "high"
381
+ ]);
371
382
  object({
372
383
  system: string().optional(),
373
384
  prompt: string(),
374
385
  model: string().optional(),
375
386
  timeout: number().optional(),
376
- jsonSchema: string().optional()
387
+ jsonSchema: string().optional(),
388
+ effort: Effort.optional()
377
389
  });
378
390
  object({
379
391
  text: string(),
@@ -418,9 +430,16 @@ object({
418
430
  utilization: number().nullable()
419
431
  }).nullable().optional()
420
432
  });
433
+ var SubscriberStatus = object({
434
+ connected: boolean(),
435
+ connectedAt: date().nullable(),
436
+ lastReconcileAt: date().nullable(),
437
+ attempt: number()
438
+ });
421
439
  object({
422
440
  status: string(),
423
- activeTokens: number()
441
+ activeTokens: number(),
442
+ subscriber: SubscriberStatus.nullable()
424
443
  });
425
444
  function maskToken(token) {
426
445
  return token.length > 4 ? `...${token.slice(-4)}` : token;
@@ -1,6 +1,6 @@
1
- import { B as hashKey, C as require_react_dom, D as require_react, E as require_jsx_runtime, F as onlineManager, G as noop$1, I as notifyManager, K as partialMatchKey, M as infiniteQueryBehavior, N as Query, O as Mutation, Q as skipToken, U as matchMutation, V as hashQueryKeyByOptions, W as matchQuery, Y as resolveStaleTime, at as __require, b as object, d as ZodObject, f as ZodOptional, l as ZodArray, n as SUPPORTED_LOCALES, nt as Subscribable, ot as __toESM, r as setLocale, rt as __commonJSMin, t as SD, tt as focusManager, u as ZodNullable, w as QueryClientProvider, x as string, y as number, z as functionalUpdate } from "./assets/sd.generated-CIg_jf8e.js";
2
- import { A as decodePath, C as findRouteMatch, D as createLRUCache, E as processRouteTree, F as last, I as replaceEqualDeep, M as findLast, N as functionalUpdate$1, O as invariant, P as isPromise, S as findFlatMatch, T as processRouteMasks, _ as interpolatePath, a as Link$1, b as trimPath, c as usePrevious$1, d as useRouter, f as getRouterContext, g as cleanPath, h as isNotFound, i as createRootRouteWithContext, j as deepEqual$2, k as createControlledPromise, l as matchContext, m as rootRouteId, n as createFileRoute, p as warning, r as createLazyFileRoute, s as useLayoutEffect$3, t as lazyRouteComponent, u as useRouterState, v as joinPaths, w as findSingleMatch, x as trimPathRight, y as resolvePath } from "./assets/lazyRouteComponent-BlvOfJIF.js";
3
- import { t as require_shim } from "./assets/shim-Dq_Izqnc.js";
1
+ import { B as hashKey, C as require_react_dom, D as require_react, E as require_jsx_runtime, F as onlineManager, G as noop$1, I as notifyManager, K as partialMatchKey, M as infiniteQueryBehavior, N as Query, O as Mutation, Q as skipToken, U as matchMutation, V as hashQueryKeyByOptions, W as matchQuery, Y as resolveStaleTime, at as __require, b as object, d as ZodObject, f as ZodOptional, l as ZodArray, n as SUPPORTED_LOCALES, nt as Subscribable, ot as __toESM, r as setLocale, rt as __commonJSMin, t as SD, tt as focusManager, u as ZodNullable, w as QueryClientProvider, x as string, y as number, z as functionalUpdate } from "./assets/sd.generated-CkiEsOwK.js";
2
+ import { A as decodePath, C as findRouteMatch, D as createLRUCache, E as processRouteTree, F as last, I as replaceEqualDeep, M as findLast, N as functionalUpdate$1, O as invariant, P as isPromise, S as findFlatMatch, T as processRouteMasks, _ as interpolatePath, a as Link$1, b as trimPath, c as usePrevious$1, d as useRouter, f as getRouterContext, g as cleanPath, h as isNotFound, i as createRootRouteWithContext, j as deepEqual$2, k as createControlledPromise, l as matchContext, m as rootRouteId, n as createFileRoute, p as warning, r as createLazyFileRoute, s as useLayoutEffect$3, t as lazyRouteComponent, u as useRouterState, v as joinPaths, w as findSingleMatch, x as trimPathRight, y as resolvePath } from "./assets/lazyRouteComponent-CcyhCAoL.js";
3
+ import { t as require_shim } from "./assets/shim-BYpcQGN1.js";
4
4
  //#region ../../node_modules/.pnpm/@tanstack+query-core@5.95.2/node_modules/@tanstack/query-core/build/modern/hydration.js
5
5
  function defaultTransformerFn(data) {
6
6
  return data;
@@ -44599,11 +44599,11 @@ function RootComponent() {
44599
44599
  }
44600
44600
  //#endregion
44601
44601
  //#region src/routes/tokens.tsx
44602
- var $$splitComponentImporter$3 = () => import("./assets/tokens-rQIIgqMo.js");
44602
+ var $$splitComponentImporter$3 = () => import("./assets/tokens-hSHCLF_7.js");
44603
44603
  var Route$3 = createFileRoute("/tokens")({ component: lazyRouteComponent($$splitComponentImporter$3, "component") });
44604
44604
  //#endregion
44605
44605
  //#region src/routes/logs.tsx
44606
- var $$splitComponentImporter$2 = () => import("./assets/logs-CDacVwTQ.js");
44606
+ var $$splitComponentImporter$2 = () => import("./assets/logs-9j6ES80h.js");
44607
44607
  var logsSearchSchema = object({
44608
44608
  token: string().optional(),
44609
44609
  project: string().optional(),
@@ -44615,11 +44615,11 @@ var Route$2 = createFileRoute("/logs")({
44615
44615
  });
44616
44616
  //#endregion
44617
44617
  //#region src/routes/index.tsx
44618
- var $$splitComponentImporter$1 = () => import("./assets/routes-BLm-zF86.js");
44618
+ var $$splitComponentImporter$1 = () => import("./assets/routes-DQh4d03H.js");
44619
44619
  var Route$1 = createFileRoute("/")({ component: lazyRouteComponent($$splitComponentImporter$1, "component") });
44620
44620
  //#endregion
44621
44621
  //#region src/routes/requests/show.tsx
44622
- var $$splitComponentImporter = () => import("./assets/show-DjJyZunM.js");
44622
+ var $$splitComponentImporter = () => import("./assets/show-j1j13Hq1.js");
44623
44623
  var showSearchSchema = object({ id: number() });
44624
44624
  var Route = createFileRoute("/requests/show")({
44625
44625
  validateSearch: showSearchSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cartanova/qgrid-cli",
3
- "version": "1.7.3",
3
+ "version": "1.9.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cartanova-ai/qgrid"
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{y as t}from"./vendor-tanstack-DJRQAbrY.js";import{i as n,r}from"./vendor-react-DH4kUfK2.js";import{S as i,_ as a,b as o,g as s,h as c,i as l,l as u,m as d,v as f,x as p,y as m}from"./sd.generated-CIOZewtL.js";import{a as h,i as g,r as _}from"./index-DUmwX7rR.js";import{r as v,t as y}from"./services.generated-BrB-RELO.js";import{n as b,t as x}from"./copy-DdGJDXSK.js";var S=e(n()),C=r(),w=e=>(0,C.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,C.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,C.jsx)(`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0`}),(0,C.jsx)(`circle`,{cx:12,cy:12,r:3})]})}),T=e=>(0,C.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,C.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,C.jsx)(`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575a1 1 0 0 1 0 .696a10.8 10.8 0 0 1-1.444 2.49m-6.41-.679a3 3 0 0 1-4.242-4.242`}),(0,C.jsx)(`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 4.446-5.143M2 2l20 20`})]})}),E=e=>(0,C.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,C.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 12h14m-7-7v14`})}),D=d([`id-desc`]).describe(`RequestLogOrderBy`),O=d([`id`,`token_name`,`user_prompt`]).describe(`RequestLogSearchField`),k=d([`id-desc`,`ord-asc`]).describe(`TokenOrderBy`),A=d([`id`,`name`]).describe(`TokenSearchField`);p({id:m(),created_at:f(),token_name:i().max(100),project_name:i().max(50).nullable(),model_name:i().max(50).nullable(),user_prompt:i().nullable(),system_prompt:i().nullable(),response:i(),input_tokens:m(),output_tokens:m(),cache_read_tokens:m(),cache_creation_tokens:m(),duration_ms:m(),cost_usd:m().nullable()});var j=p({id:m(),created_at:f(),token:i(),name:i(),refresh_token:i().nullable(),expires_at:c().nullable(),account_uuid:i().nullable(),active:s(),ord:m()});p({num:o().int().nonnegative(),page:o().int().min(1),search:O,keyword:i(),orderBy:D,queryMode:l,id:u(o().int().positive()),sonamuFilter:a(),token_name:i().max(100),project_name:i().max(50).nullable(),model_name:i().max(50).nullable()}).partial(),p({num:o().int().nonnegative(),page:o().int().min(1),search:A,keyword:i(),orderBy:k,queryMode:l,id:u(o().int().positive()),sonamuFilter:a(),token:i()}).partial(),p({id:m(),created_at:f(),token_name:i().max(100),project_name:i().max(50).nullable(),model_name:i().max(50).nullable(),user_prompt:i().nullable(),system_prompt:i().nullable(),response:i(),input_tokens:m(),output_tokens:m(),cache_read_tokens:m(),cache_creation_tokens:m(),duration_ms:m(),cost_usd:m().nullable()}),p({id:m(),created_at:f(),token_name:i().max(100),project_name:i().max(50).nullable(),model_name:i().max(50).nullable(),input_tokens:m(),output_tokens:m(),cache_read_tokens:m(),cache_creation_tokens:m(),duration_ms:m(),cost_usd:m().nullable()}),d([`A`,`P`]),p({id:m(),created_at:f(),token:i(),name:i(),refresh_token:i().nullable(),expires_at:c().nullable(),account_uuid:i().nullable(),active:s(),ord:m()}),d([`A`]);var M=j.partial({id:!0,created_at:!0,refresh_token:!0,expires_at:!0,account_uuid:!0,active:!0,ord:!0});M.pick({id:!0,token:!0,refresh_token:!0,name:!0});function N(){let[e,n]=(0,S.useState)(!1),[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(!1),{form:s,register:c,reset:l}=g(M,{name:``,token:``,refresh_token:``}),u=t(),d=y.useAddTokenMutation(),f=y.useOauthStartMutation(),p=async()=>{if(s.name?.trim()){o(!0);try{let{authUrl:e}=await f.mutateAsync({name:s.name.trim()});window.location.href=e}catch{o(!1)}}},m=async()=>{!s.token?.trim()||!s.name?.trim()||(await d.mutateAsync({token:s.token.trim(),name:s.name.trim(),refreshToken:s.refresh_token?.trim()??``})).added&&(await Promise.all([u.invalidateQueries({queryKey:[`Qgrid`]}),u.invalidateQueries({queryKey:[`Token`]})]),v())},v=()=>{n(!1),l(),i(!1),o(!1)};return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md bg-sienna-400 text-white hover:bg-sienna-500 disabled:opacity-50 transition-colors duration-150 active:scale-[0.98] flex items-center gap-1`,onClick:()=>n(!0),children:[(0,C.jsx)(E,{className:`size-3.5`}),`Add Token`]}),e&&(0,C.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,C.jsx)(`div`,{className:`absolute inset-0`,onClick:v,onKeyDown:()=>{}}),(0,C.jsxs)(`div`,{className:`relative bg-white rounded-lg shadow-xl w-full max-w-md mx-4`,children:[(0,C.jsx)(`div`,{className:`px-5 py-4 border-b border-sand-100`,children:(0,C.jsx)(`h2`,{className:`text-base font-medium text-sand-900`,children:`Add Token`})}),(0,C.jsxs)(`div`,{className:`px-5 py-4 space-y-4`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`token-name`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Name *`}),(0,C.jsx)(_,{...c(`name`),placeholder:`e.g. your-token-name`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300`})]}),(0,C.jsx)(`button`,{type:`button`,className:`w-full py-2.5 text-sm font-medium rounded-md bg-sand-900 text-white hover:bg-sand-800 disabled:opacity-50 transition-colors duration-150 flex items-center justify-center gap-2`,disabled:!s.name?.trim()||a,onClick:p,children:a?(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`w-3.5 h-3.5 border-2 border-white border-t-transparent rounded-full animate-spin`}),`Waiting for login...`]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h,{className:`size-4`}),`Login with Claude`]})}),(0,C.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,C.jsx)(`div`,{className:`flex-1 h-px bg-sand-200`}),(0,C.jsx)(`span`,{className:`text-[10px] text-sand-400 uppercase`,children:`or`}),(0,C.jsx)(`div`,{className:`flex-1 h-px bg-sand-200`})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`oauth-token`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Access Token`}),(0,C.jsxs)(`div`,{className:`relative mt-1`,children:[(0,C.jsx)(_,{type:r?`text`:`password`,...c(`token`),placeholder:`sk-ant-oat01-...`,className:`w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300 pr-10`}),(0,C.jsx)(`button`,{type:`button`,className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-sand-400 hover:text-sand-600 transition-colors duration-150`,onClick:()=>i(!r),children:r?(0,C.jsx)(T,{className:`size-4`}):(0,C.jsx)(w,{className:`size-4`})})]})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`label`,{htmlFor:`refresh-token`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:[`Refresh Token`,` `,(0,C.jsx)(`span`,{className:`text-sand-400 normal-case tracking-normal`,children:`(optional)`})]}),(0,C.jsx)(_,{type:`password`,...c(`refresh_token`),placeholder:`sk-ant-ort01-...`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300`}),(0,C.jsx)(`p`,{className:`text-[10px] text-sand-400 mt-1`,children:`Enables auto-refresh when access token expires (~8h)`})]})]}),(0,C.jsxs)(`div`,{className:`px-5 py-3 border-t border-sand-100 flex items-center justify-end gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md border border-sand-200 text-sand-600 hover:bg-sand-100 transition-colors duration-150`,onClick:v,children:`Cancel`}),s.token?.trim()&&(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md bg-sienna-400 text-white hover:bg-sienna-500 disabled:opacity-50 transition-colors duration-150`,disabled:!s.name?.trim()||!s.token?.trim()||d.isPending,onClick:m,children:d.isPending?`Adding...`:`Add Token`})]})]})]})]})}var P=e=>(0,C.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,C.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497zM15 5l4 4`})}),F=e=>(0,C.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,C.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M10 11v6m4-6v6m5-11v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})});p({system:i().optional(),prompt:i(),model:i().optional(),timeout:o().optional(),jsonSchema:i().optional()}),p({text:i(),tokenName:i().optional(),model:i().optional(),usage:p({input_tokens:o(),output_tokens:o(),cache_creation_input_tokens:o(),cache_read_input_tokens:o()}),durationMs:o(),costUsd:o()}),p({token:i(),name:i()}),p({token:i()}),p({token:i(),name:i(),requests:o()}),p({authUrl:i()});var I=p({utilization:o().nullable(),resets_at:i().nullable()}).nullable();p({error:i().optional(),five_hour:I.optional(),seven_day:I.optional(),seven_day_opus:I.optional(),seven_day_sonnet:I.optional(),seven_day_oauth_apps:I.optional(),seven_day_cowork:I.optional(),extra_usage:p({is_enabled:s(),monthly_limit:o().nullable(),used_credits:o().nullable(),utilization:o().nullable()}).nullable().optional()}),p({status:i(),activeTokens:o()});function L(e){return e.length>4?`...${e.slice(-4)}`:e}function R(e){if(!e)return{text:``,color:``};let t=Number(e)-Date.now();if(t<=0)return{text:`expired`,color:`text-red-500`};let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),i=n>0?`${n}h ${r}m`:`${r}m`;return t<36e5?{text:i,color:`text-amber-500`}:{text:i,color:`text-sand-400`}}function z({data:e,isLoading:n}){let[r,i]=(0,S.useState)(null),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(!1),[l,u]=(0,S.useState)(!1),[d,f]=(0,S.useState)(!1),[p,m]=(0,S.useState)(!1),{form:h,setForm:v,register:E}=g(M,{name:``,token:``,active:!0}),D=t(),O=y.useRemoveTokenMutation(),k=y.useUpdateTokenMutation(),A=y.useToggleTokenMutation(),j=()=>Promise.all([D.invalidateQueries({queryKey:[`Token`]}),D.invalidateQueries({queryKey:[`Qgrid`]})]),N=async e=>{await A.mutateAsync({id:e.id}),await j()},I=async()=>{r&&(await O.mutateAsync({token:r.token}),await j(),i(null))},z=e=>{o(e),v({name:e.name??``,token:e.token,active:e.active,refresh_token:e.refresh_token??``}),c(!1),u(!1),f(!1),m(!1)},B=async()=>{if(!a)return;let e=h.token&&h.token!==a.token?h.token.trim():void 0,t=[k.mutateAsync({token:a.token,name:h.name?.trim()??``,newToken:e??``,refreshToken:h.refresh_token?.trim()??``})];h.active!==a.active&&t.push(A.mutateAsync({id:a.id})),await Promise.all(t),await j(),o(null)},V=()=>{a&&(navigator.clipboard.writeText(a.token),f(!0),setTimeout(()=>f(!1),1500))},H=()=>{a?.refresh_token&&(navigator.clipboard.writeText(a.refresh_token),m(!0),setTimeout(()=>m(!1),1500))};if(n)return(0,C.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:3}).map((e,t)=>(0,C.jsx)(`div`,{className:`h-12 bg-sand-100 rounded-md animate-pulse`},`skeleton-${t}`))});let U=e??[];return U.length===0?(0,C.jsxs)(`div`,{className:`text-sand-400 text-center py-16 text-sm`,children:[`No tokens registered. Click `,(0,C.jsx)(`strong`,{className:`text-sand-600`,children:`Add Token`}),` to get started.`]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`div`,{className:`rounded-lg bg-sand-50 overflow-hidden`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-sand-200`,children:[(0,C.jsx)(`th`,{className:`text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Token`}),(0,C.jsx)(`th`,{className:`text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Name`}),(0,C.jsx)(`th`,{className:`text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Expires`}),(0,C.jsx)(`th`,{className:`w-20 px-3 py-3`})]})}),(0,C.jsx)(`tbody`,{className:`divide-y divide-sand-200/60`,children:U.map(e=>{let t=R(e.expires_at);return(0,C.jsxs)(`tr`,{className:`transition-colors duration-150 hover:bg-sand-100/60 ${e.active?``:`opacity-50`}`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`code`,{className:`text-[13px] font-mono text-sand-800`,children:L(e.token)})}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:e.name?(0,C.jsx)(`span`,{className:`text-sm text-sand-700`,children:e.name}):(0,C.jsx)(`span`,{className:`text-[11px] text-sand-400`,children:`—`})}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`button`,{type:`button`,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors duration-200 ${e.active?`bg-sage-400`:`bg-sand-300`}`,onClick:()=>N(e),disabled:A.isPending,children:(0,C.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform duration-200 ${e.active?`translate-x-4.5`:`translate-x-0.5`}`})})}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:t.text&&(0,C.jsx)(`span`,{className:`text-xs ${t.color}`,children:t.text})}),(0,C.jsx)(`td`,{className:`px-3 py-3`,children:(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sienna-500 transition-colors duration-150`,onClick:()=>z(e),children:(0,C.jsx)(P,{className:`size-4`})}),(0,C.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-red-500 transition-colors duration-150`,onClick:()=>i(e),children:(0,C.jsx)(F,{className:`size-4`})})]})})]},e.id)})})]})}),a&&(0,C.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,C.jsx)(`div`,{className:`absolute inset-0`,onClick:()=>o(null),onKeyDown:()=>{}}),(0,C.jsxs)(`div`,{className:`relative bg-white rounded-lg shadow-xl w-full max-w-sm mx-4`,children:[(0,C.jsx)(`div`,{className:`px-5 py-4 border-b border-sand-100`,children:(0,C.jsx)(`h3`,{className:`text-base font-medium text-sand-900`,children:`Edit Token`})}),(0,C.jsxs)(`div`,{className:`px-5 py-4 space-y-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`token-name`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Name`}),(0,C.jsx)(_,{...E(`name`),placeholder:`e.g. prod, dev, team-a`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300`})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`input`,{id:`token-active`,type:`checkbox`,checked:h.active??!0,onChange:e=>v({...h,active:e.target.checked}),className:`h-4 w-4 rounded border-sand-300 text-sienna-500 focus:ring-sienna-300`}),(0,C.jsx)(`label`,{htmlFor:`token-active`,className:`text-sm text-sand-700`,children:`Active`})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsx)(`label`,{htmlFor:`token-value`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Token`}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,className:`flex items-center gap-1 text-[10px] text-sand-400 hover:text-sienna-500 transition-colors duration-150`,onClick:V,children:d?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(b,{className:`size-3 text-sage-500`}),(0,C.jsx)(`span`,{className:`text-sage-500`,children:`Copied`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(x,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Copy`})]})}),(0,C.jsx)(`button`,{type:`button`,className:`flex items-center gap-1 text-[10px] text-sand-400 hover:text-sand-600 transition-colors duration-150`,onClick:()=>c(!s),children:s?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(T,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Hide`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(w,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Show`})]})})]})]}),(0,C.jsx)(`input`,{id:`token-value`,type:s?`text`:`password`,value:h.token||(s?a.token:``),onChange:e=>v({...h,token:e.target.value}),placeholder:s?``:`●●●●●●●●●●●●●●●●`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-400 focus:outline-none focus:border-sienna-300`})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsxs)(`label`,{htmlFor:`edit-refresh-token`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:[`Refresh Token`,` `,(0,C.jsx)(`span`,{className:`text-sand-400 normal-case tracking-normal`,children:`(optional)`})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,className:`flex items-center gap-1 text-[10px] text-sand-400 hover:text-sienna-500 transition-colors duration-150`,onClick:H,children:p?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(b,{className:`size-3 text-sage-500`}),(0,C.jsx)(`span`,{className:`text-sage-500`,children:`Copied`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(x,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Copy`})]})}),(0,C.jsx)(`button`,{type:`button`,className:`flex items-center gap-1 text-[10px] text-sand-400 hover:text-sand-600 transition-colors duration-150`,onClick:()=>u(!l),children:l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(T,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Hide`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(w,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Show`})]})})]})]}),(0,C.jsx)(`input`,{id:`edit-refresh-token`,type:l?`text`:`password`,value:h.refresh_token??``,onChange:e=>v({...h,refresh_token:e.target.value}),placeholder:`sk-ant-ort01-...`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300`}),(0,C.jsx)(`p`,{className:`text-[10px] text-sand-400 mt-1`,children:`Enables auto-refresh when access token expires`})]})]}),(0,C.jsxs)(`div`,{className:`px-5 py-3 border-t border-sand-100 flex items-center justify-end gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md border border-sand-200 text-sand-600 hover:bg-sand-100 transition-colors duration-150`,onClick:()=>o(null),children:`Cancel`}),(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md bg-sienna-400 text-white hover:bg-sienna-500 disabled:opacity-50 transition-colors duration-150`,disabled:k.isPending,onClick:B,children:k.isPending?`Saving...`:`Save`})]})]})]}),r&&(0,C.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,C.jsx)(`div`,{className:`absolute inset-0`,onClick:()=>i(null),onKeyDown:()=>{}}),(0,C.jsxs)(`div`,{className:`relative bg-white rounded-lg shadow-xl w-full max-w-sm mx-4`,children:[(0,C.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,C.jsx)(`h3`,{className:`text-base font-medium text-sand-900`,children:`Remove Token`}),(0,C.jsxs)(`p`,{className:`text-sm text-sand-700 mt-2`,children:[`Are you sure you want to remove`,` `,(0,C.jsx)(`code`,{className:`text-[13px] font-mono text-sand-800`,children:L(r.token)}),r.name&&(0,C.jsxs)(`span`,{className:`text-sand-500`,children:[` (`,r.name,`)`]}),`?`]})]}),(0,C.jsxs)(`div`,{className:`px-5 py-3 border-t border-sand-100 flex items-center justify-end gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md border border-sand-200 text-sand-600 hover:bg-sand-100 transition-colors duration-150`,onClick:()=>i(null),children:`Cancel`}),(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 transition-colors duration-150`,disabled:O.isPending,onClick:I,children:O.isPending?`Removing...`:`Remove`})]})]})]})]})}function B(){let{data:e,isLoading:t}=v.useTokens(`A`);return(0,C.jsxs)(`div`,{className:`space-y-5 max-w-300 mx-auto -translate-x-4`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsx)(`h1`,{className:`text-xl font-medium text-sand-900 tracking-tight`,children:`Tokens`}),(0,C.jsx)(N,{})]}),(0,C.jsx)(z,{data:e?.rows,isLoading:t})]})}export{B as component};