@cartanova/qgrid-cli 1.0.4 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/bundle/dist/application/qgrid/pool.js +15 -6
  2. package/bundle/dist/application/qgrid/qgrid.frame.js +17 -22
  3. package/bundle/dist/application/qgrid/qgrid.types.js +5 -2
  4. package/bundle/dist/application/request-log/request-log.model.js +2 -2
  5. package/bundle/dist/sonamu.config.js +5 -2
  6. package/bundle/src/application/qgrid/pool.ts +17 -7
  7. package/bundle/src/application/qgrid/qgrid.frame.ts +18 -25
  8. package/bundle/src/application/qgrid/qgrid.types.ts +1 -1
  9. package/bundle/src/application/request-log/request-log.model.ts +2 -2
  10. package/bundle/src/sonamu.config.ts +1 -1
  11. package/bundle/web-dist/{web-dist/client/assets/index-DlPchHBY.js → client/assets/index-C0m8rRjO.js} +2 -2
  12. package/bundle/web-dist/client/assets/{routes-CagDz23B.js → routes-B1eOXnpo.js} +1 -1
  13. package/bundle/web-dist/client/assets/{show-aXUGa0gm.js → show-BztN6MXO.js} +1 -1
  14. package/bundle/web-dist/client/assets/tokens-rR2_-Pte.js +1 -0
  15. package/bundle/web-dist/client/index.html +1 -1
  16. package/bundle/web-dist/server/assets/{tokens-JH6FsnWZ.js → tokens-ARL5AOAh.js} +4 -1
  17. package/bundle/web-dist/server/entry-server.generated.js +1 -1
  18. package/dist/cli.js +38 -24
  19. package/package.json +10 -10
  20. package/bundle/dist/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +0 -9
  21. package/bundle/dist/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js +0 -6
  22. package/bundle/dist/dist/_virtual/_rolldown/runtime.js +0 -15
  23. package/bundle/dist/dist/application/qgrid/oauth.js +0 -140
  24. package/bundle/dist/dist/application/qgrid/pool.js +0 -100
  25. package/bundle/dist/dist/application/qgrid/qgrid.frame.js +0 -280
  26. package/bundle/dist/dist/application/qgrid/qgrid.types.js +0 -79
  27. package/bundle/dist/dist/application/qgrid/worker.js +0 -183
  28. package/bundle/dist/dist/application/queries.generated.js +0 -31
  29. package/bundle/dist/dist/application/request-log/request-log.model.js +0 -113
  30. package/bundle/dist/dist/application/request-log/request-log.types.js +0 -13
  31. package/bundle/dist/dist/application/sonamu.generated.js +0 -99
  32. package/bundle/dist/dist/application/sonamu.generated.sso.js +0 -34
  33. package/bundle/dist/dist/application/token/token.model.js +0 -157
  34. package/bundle/dist/dist/application/token/token.types.js +0 -22
  35. package/bundle/dist/dist/i18n/en.js +0 -63
  36. package/bundle/dist/dist/i18n/ko.js +0 -62
  37. package/bundle/dist/dist/i18n/sd.generated.js +0 -272
  38. package/bundle/dist/dist/index.js +0 -11
  39. package/bundle/dist/dist/migrations/20260410171405_create__request_logs.js +0 -26
  40. package/bundle/dist/dist/migrations/20260410171406_create__tokens.js +0 -24
  41. package/bundle/dist/dist/migrations/20260411120624_alter_tokens_alter2.js +0 -16
  42. package/bundle/dist/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +0 -155
  43. package/bundle/dist/dist/node_modules/.pnpm/@vitest_expect@4.1.2/node_modules/@vitest/expect/dist/index.js +0 -1484
  44. package/bundle/dist/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.2/node_modules/@vitest/pretty-format/dist/index.js +0 -887
  45. package/bundle/dist/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/chunk-artifact.js +0 -2746
  46. package/bundle/dist/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/index.js +0 -8
  47. package/bundle/dist/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/utils.js +0 -8
  48. package/bundle/dist/dist/node_modules/.pnpm/@vitest_snapshot@4.1.2/node_modules/@vitest/snapshot/dist/index.js +0 -662
  49. package/bundle/dist/dist/node_modules/.pnpm/@vitest_spy@4.1.2/node_modules/@vitest/spy/dist/index.js +0 -386
  50. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +0 -82
  51. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/constants.js +0 -48
  52. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/diff.js +0 -1307
  53. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/display.js +0 -558
  54. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/error.js +0 -33
  55. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/helpers.js +0 -226
  56. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/offset.js +0 -27
  57. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/serialize.js +0 -77
  58. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/source-map.js +0 -374
  59. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/timers.js +0 -37
  60. package/bundle/dist/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.js +0 -2886
  61. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/branding.js +0 -10
  62. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/index.js +0 -109
  63. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/messages.js +0 -10
  64. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/overloads.js +0 -10
  65. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/utils.js +0 -10
  66. package/bundle/dist/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js +0 -1127
  67. package/bundle/dist/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +0 -21
  68. package/bundle/dist/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +0 -432
  69. package/bundle/dist/dist/node_modules/.pnpm/tinybench@2.9.0/node_modules/tinybench/dist/index.js +0 -506
  70. package/bundle/dist/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.js +0 -86
  71. package/bundle/dist/dist/node_modules/.pnpm/vite@8.0.3_@emnapi_core@1.9.2_@emnapi_runtime@1.9.2_@types_node@25.0.7_esbuild@0.27.4_jiti@2.6.1_sass@1.98.0_tsx@4.21.0/node_modules/vite/dist/node/module-runner.js +0 -426
  72. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -6
  73. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/benchmark.CX_oY03V.js +0 -41
  74. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/evaluatedModules.Dg1zASAC.js +0 -19
  75. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/index.Chj8NDwU.js +0 -202
  76. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/index.DOa3dzoN.js +0 -16
  77. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +0 -59
  78. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/test.p_J6dB8a.js +0 -2910
  79. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +0 -44
  80. package/bundle/dist/dist/node_modules/.pnpm/vitest@4.1.2_@opentelemetry_api@1.9.0_@types_node@25.0.7_vite@8.0.3_@emnapi_core@1.9.2__bb31087278f97a39b31b92010beab980/node_modules/vitest/dist/index.js +0 -28
  81. package/bundle/dist/dist/sonamu.config.js +0 -196
  82. package/bundle/dist/dist/testing/fixture.js +0 -8
  83. package/bundle/dist/dist/testing/global.js +0 -9
  84. package/bundle/dist/dist/testing/setup-mocks.js +0 -17
  85. package/bundle/dist/dist/utils/subset-loaders.js +0 -12
  86. package/bundle/src/src/application/qgrid/oauth.ts +0 -181
  87. package/bundle/src/src/application/qgrid/pool.ts +0 -132
  88. package/bundle/src/src/application/qgrid/qgrid.frame.ts +0 -275
  89. package/bundle/src/src/application/qgrid/qgrid.types.ts +0 -117
  90. package/bundle/src/src/application/qgrid/worker.ts +0 -234
  91. package/bundle/src/src/application/queries.generated.ts +0 -59
  92. package/bundle/src/src/application/request-log/request-log.entity.json +0 -75
  93. package/bundle/src/src/application/request-log/request-log.model.ts +0 -155
  94. package/bundle/src/src/application/request-log/request-log.types.ts +0 -15
  95. package/bundle/src/src/application/sonamu.generated.http +0 -187
  96. package/bundle/src/src/application/sonamu.generated.sso.ts +0 -66
  97. package/bundle/src/src/application/sonamu.generated.ts +0 -135
  98. package/bundle/src/src/application/token/token.entity.json +0 -37
  99. package/bundle/src/src/application/token/token.model.ts +0 -160
  100. package/bundle/src/src/application/token/token.types.ts +0 -26
  101. package/bundle/src/src/i18n/en.ts +0 -59
  102. package/bundle/src/src/i18n/ko.ts +0 -59
  103. package/bundle/src/src/i18n/sd.generated.ts +0 -384
  104. package/bundle/src/src/index.ts +0 -6
  105. package/bundle/src/src/migrations/20260410171405_create__request_logs.ts +0 -23
  106. package/bundle/src/src/migrations/20260410171406_create__tokens.ts +0 -21
  107. package/bundle/src/src/migrations/20260411120624_alter_tokens_alter2.ts +0 -15
  108. package/bundle/src/src/sonamu.config.ts +0 -248
  109. package/bundle/src/src/testing/fixture.ts +0 -6
  110. package/bundle/src/src/testing/global.ts +0 -6
  111. package/bundle/src/src/testing/setup-mocks.ts +0 -44
  112. package/bundle/src/src/typings/fastify.d.ts +0 -8
  113. package/bundle/src/src/typings/sonamu.d.ts +0 -17
  114. package/bundle/src/src/utils/subset-loaders.ts +0 -11
  115. package/bundle/web-dist/client/assets/index-DlPchHBY.js +0 -116
  116. package/bundle/web-dist/client/assets/tokens-DRkXtZ3Q.js +0 -1
  117. package/bundle/web-dist/web-dist/client/assets/index-vZsvyuFn.css +0 -1
  118. package/bundle/web-dist/web-dist/client/assets/rolldown-runtime-Dw2cE7zH.js +0 -1
  119. package/bundle/web-dist/web-dist/client/assets/routes-CagDz23B.js +0 -1
  120. package/bundle/web-dist/web-dist/client/assets/sd.generated-BrQoQXvv.js +0 -47
  121. package/bundle/web-dist/web-dist/client/assets/services.generated-BspO2L0j.js +0 -1
  122. package/bundle/web-dist/web-dist/client/assets/show-aXUGa0gm.js +0 -29
  123. package/bundle/web-dist/web-dist/client/assets/tokens-DRkXtZ3Q.js +0 -1
  124. package/bundle/web-dist/web-dist/client/assets/vendor-react-DH4kUfK2.js +0 -9
  125. package/bundle/web-dist/web-dist/client/assets/vendor-tanstack-CUxlo6YN.js +0 -1
  126. package/bundle/web-dist/web-dist/client/index.html +0 -18
  127. package/bundle/web-dist/web-dist/server/assets/react-dom-CGIzOSuj.js +0 -335
  128. package/bundle/web-dist/web-dist/server/assets/routes-ClzReRep.js +0 -490
  129. package/bundle/web-dist/web-dist/server/assets/sd.generated-BnonqqKr.js +0 -21694
  130. package/bundle/web-dist/web-dist/server/assets/services.generated-D5ABD5fr.js +0 -836
  131. package/bundle/web-dist/web-dist/server/assets/show-C9pcdSxc.js +0 -23364
  132. package/bundle/web-dist/web-dist/server/assets/tokens-JH6FsnWZ.js +0 -860
  133. package/bundle/web-dist/web-dist/server/entry-server.generated.js +0 -44646
@@ -1,860 +0,0 @@
1
- import { b as require_jsx_runtime, c as array, d as custom, f as date, g as string, h as object, i as SonamuQueryMode, l as bigint, m as number, o as zArrayable, p as int, s as _enum, tt as __toESM, u as boolean, x as require_react, y as useQueryClient } from "./sd.generated-BnonqqKr.js";
2
- import { r as TokenService, t as QgridService } from "./services.generated-D5ABD5fr.js";
3
- import { i as lucideKeyRound, n as m5, r as mn } from "../entry-server.generated.js";
4
- //#region ~icons/lucide/eye.jsx
5
- var import_react = /* @__PURE__ */ __toESM(require_react());
6
- var import_jsx_runtime = require_jsx_runtime();
7
- var lucideEye = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
8
- viewBox: "0 0 24 24",
9
- width: "1.2em",
10
- height: "1.2em",
11
- ...props,
12
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
13
- fill: "none",
14
- stroke: "currentColor",
15
- strokeLinecap: "round",
16
- strokeLinejoin: "round",
17
- strokeWidth: 2,
18
- children: [/* @__PURE__ */ (0, import_jsx_runtime.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" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", {
19
- cx: 12,
20
- cy: 12,
21
- r: 3
22
- })]
23
- })
24
- });
25
- //#endregion
26
- //#region ~icons/lucide/eye-off.jsx
27
- var lucideEyeOff = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
28
- viewBox: "0 0 24 24",
29
- width: "1.2em",
30
- height: "1.2em",
31
- ...props,
32
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
33
- fill: "none",
34
- stroke: "currentColor",
35
- strokeLinecap: "round",
36
- strokeLinejoin: "round",
37
- strokeWidth: 2,
38
- children: [/* @__PURE__ */ (0, import_jsx_runtime.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" }), /* @__PURE__ */ (0, import_jsx_runtime.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" })]
39
- })
40
- });
41
- //#endregion
42
- //#region ~icons/lucide/plus.jsx
43
- var lucidePlus = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
44
- viewBox: "0 0 24 24",
45
- width: "1.2em",
46
- height: "1.2em",
47
- ...props,
48
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
49
- fill: "none",
50
- stroke: "currentColor",
51
- strokeLinecap: "round",
52
- strokeLinejoin: "round",
53
- strokeWidth: 2,
54
- d: "M5 12h14m-7-7v14"
55
- })
56
- });
57
- //#endregion
58
- //#region src/services/sonamu.generated.ts
59
- /**
60
- * @generated
61
- * API에서 동기화된 파일입니다. 직접 수정하지 마세요.
62
- */
63
- var RequestLogOrderBy = _enum(["id-desc"]).describe("RequestLogOrderBy");
64
- var RequestLogSearchField = _enum([
65
- "id",
66
- "token_name",
67
- "query"
68
- ]).describe("RequestLogSearchField");
69
- var TokenOrderBy = _enum(["id-desc"]).describe("TokenOrderBy");
70
- var TokenSearchField = _enum(["id", "name"]).describe("TokenSearchField");
71
- object({
72
- id: int(),
73
- created_at: date(),
74
- token_name: string().max(100),
75
- query: string(),
76
- response: string(),
77
- input_tokens: int(),
78
- output_tokens: int(),
79
- cache_read_tokens: int(),
80
- cache_creation_tokens: int(),
81
- duration_ms: int()
82
- });
83
- var TokenBaseSchema = object({
84
- id: int(),
85
- created_at: date(),
86
- token: string(),
87
- name: string(),
88
- refresh_token: string().nullable(),
89
- expires_at: bigint().nullable(),
90
- account_uuid: string().nullable(),
91
- active: boolean()
92
- });
93
- object({
94
- num: number().int().nonnegative(),
95
- page: number().int().min(1),
96
- search: RequestLogSearchField,
97
- keyword: string(),
98
- orderBy: RequestLogOrderBy,
99
- queryMode: SonamuQueryMode,
100
- id: zArrayable(number().int().positive()),
101
- sonamuFilter: custom(),
102
- token_name: string().max(100)
103
- }).partial();
104
- object({
105
- num: number().int().nonnegative(),
106
- page: number().int().min(1),
107
- search: TokenSearchField,
108
- keyword: string(),
109
- orderBy: TokenOrderBy,
110
- queryMode: SonamuQueryMode,
111
- id: zArrayable(number().int().positive()),
112
- sonamuFilter: custom(),
113
- token: string()
114
- }).partial();
115
- object({
116
- id: int(),
117
- created_at: date(),
118
- token_name: string().max(100),
119
- query: string(),
120
- response: string(),
121
- input_tokens: int(),
122
- output_tokens: int(),
123
- cache_read_tokens: int(),
124
- cache_creation_tokens: int(),
125
- duration_ms: int()
126
- });
127
- _enum(["A"]);
128
- object({
129
- id: int(),
130
- created_at: date(),
131
- token: string(),
132
- name: string(),
133
- refresh_token: string().nullable(),
134
- expires_at: bigint().nullable(),
135
- account_uuid: string().nullable(),
136
- active: boolean()
137
- });
138
- _enum(["A"]);
139
- //#endregion
140
- //#region src/services/token/token.types.ts
141
- var TokenSaveParams = TokenBaseSchema.partial({
142
- id: true,
143
- created_at: true,
144
- refresh_token: true,
145
- expires_at: true,
146
- account_uuid: true,
147
- active: true
148
- });
149
- TokenSaveParams.pick({
150
- id: true,
151
- token: true,
152
- refresh_token: true,
153
- name: true
154
- });
155
- //#endregion
156
- //#region src/components/qgrid/AddTokenModal.tsx
157
- function AddTokenModal() {
158
- const [open, setOpen] = (0, import_react.useState)(false);
159
- const [showToken, setShowToken] = (0, import_react.useState)(false);
160
- const [oauthLoading, setOauthLoading] = (0, import_react.useState)(false);
161
- const { form, register, reset } = m5(TokenSaveParams, {
162
- name: "",
163
- token: "",
164
- refresh_token: ""
165
- });
166
- const queryClient = useQueryClient();
167
- const addMutation = QgridService.useAddTokenMutation();
168
- const oauthStartMutation = QgridService.useOauthStartMutation();
169
- const handleOAuthLogin = async () => {
170
- if (!form.name?.trim()) return;
171
- setOauthLoading(true);
172
- try {
173
- const { authUrl } = await oauthStartMutation.mutateAsync({ name: form.name.trim() });
174
- window.location.href = authUrl;
175
- } catch {
176
- setOauthLoading(false);
177
- }
178
- };
179
- const handleManualSubmit = async () => {
180
- if (!form.token?.trim() || !form.name?.trim()) return;
181
- if (!(await addMutation.mutateAsync({
182
- token: form.token.trim(),
183
- name: form.name.trim(),
184
- refreshToken: form.refresh_token?.trim() ?? ""
185
- })).added) return;
186
- await Promise.all([queryClient.invalidateQueries({ queryKey: ["Qgrid"] }), queryClient.invalidateQueries({ queryKey: ["Token"] })]);
187
- close();
188
- };
189
- const close = () => {
190
- setOpen(false);
191
- reset();
192
- setShowToken(false);
193
- setOauthLoading(false);
194
- };
195
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
196
- type: "button",
197
- 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",
198
- onClick: () => setOpen(true),
199
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucidePlus, { className: "size-3.5" }), "Add Token"]
200
- }), open && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
201
- className: "fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",
202
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
203
- className: "absolute inset-0",
204
- onClick: close,
205
- onKeyDown: () => {}
206
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
207
- className: "relative bg-white rounded-lg shadow-xl w-full max-w-md mx-4",
208
- children: [
209
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
210
- className: "px-5 py-4 border-b border-sand-100",
211
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
212
- className: "text-base font-medium text-sand-900",
213
- children: "Add Token"
214
- })
215
- }),
216
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
217
- className: "px-5 py-4 space-y-4",
218
- children: [
219
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
220
- htmlFor: "token-name",
221
- className: "text-[10px] uppercase tracking-wider text-sand-500 font-medium",
222
- children: "Name *"
223
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(mn, {
224
- ...register("name"),
225
- placeholder: "e.g. your-token-name",
226
- 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"
227
- })] }),
228
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
229
- type: "button",
230
- 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",
231
- disabled: !form.name?.trim() || oauthLoading,
232
- onClick: handleOAuthLogin,
233
- children: oauthLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
234
- className: "flex items-center gap-1.5",
235
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "w-3.5 h-3.5 border-2 border-white border-t-transparent rounded-full animate-spin" }), "Waiting for login..."]
236
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideKeyRound, { className: "size-4" }), "Login with Claude"] })
237
- }),
238
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
239
- className: "flex items-center gap-3",
240
- children: [
241
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1 h-px bg-sand-200" }),
242
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
243
- className: "text-[10px] text-sand-400 uppercase",
244
- children: "or"
245
- }),
246
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1 h-px bg-sand-200" })
247
- ]
248
- }),
249
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
250
- htmlFor: "oauth-token",
251
- className: "text-[10px] uppercase tracking-wider text-sand-500 font-medium",
252
- children: "Access Token"
253
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
254
- className: "relative mt-1",
255
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(mn, {
256
- type: showToken ? "text" : "password",
257
- ...register("token"),
258
- placeholder: "sk-ant-oat01-...",
259
- 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"
260
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
261
- type: "button",
262
- className: "absolute right-2.5 top-1/2 -translate-y-1/2 text-sand-400 hover:text-sand-600 transition-colors duration-150",
263
- onClick: () => setShowToken(!showToken),
264
- children: showToken ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideEyeOff, { className: "size-4" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideEye, { className: "size-4" })
265
- })]
266
- })] }),
267
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
268
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
269
- htmlFor: "refresh-token",
270
- className: "text-[10px] uppercase tracking-wider text-sand-500 font-medium",
271
- children: [
272
- "Refresh Token",
273
- " ",
274
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
275
- className: "text-sand-400 normal-case tracking-normal",
276
- children: "(optional)"
277
- })
278
- ]
279
- }),
280
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(mn, {
281
- type: "password",
282
- ...register("refresh_token"),
283
- placeholder: "sk-ant-ort01-...",
284
- 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"
285
- }),
286
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
287
- className: "text-[10px] text-sand-400 mt-1",
288
- children: "Enables auto-refresh when access token expires (~8h)"
289
- })
290
- ] })
291
- ]
292
- }),
293
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
294
- className: "px-5 py-3 border-t border-sand-100 flex items-center justify-end gap-2",
295
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
296
- type: "button",
297
- 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",
298
- onClick: close,
299
- children: "Cancel"
300
- }), form.token?.trim() && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
301
- type: "button",
302
- 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",
303
- disabled: !form.name?.trim() || !form.token?.trim() || addMutation.isPending,
304
- onClick: handleManualSubmit,
305
- children: addMutation.isPending ? "Adding..." : "Add Token"
306
- })]
307
- })
308
- ]
309
- })]
310
- })] });
311
- }
312
- //#endregion
313
- //#region ~icons/lucide/check.jsx
314
- var lucideCheck = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
315
- viewBox: "0 0 24 24",
316
- width: "1.2em",
317
- height: "1.2em",
318
- ...props,
319
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
320
- fill: "none",
321
- stroke: "currentColor",
322
- strokeLinecap: "round",
323
- strokeLinejoin: "round",
324
- strokeWidth: 2,
325
- d: "M20 6L9 17l-5-5"
326
- })
327
- });
328
- //#endregion
329
- //#region ~icons/lucide/copy.jsx
330
- var lucideCopy = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
331
- viewBox: "0 0 24 24",
332
- width: "1.2em",
333
- height: "1.2em",
334
- ...props,
335
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
336
- fill: "none",
337
- stroke: "currentColor",
338
- strokeLinecap: "round",
339
- strokeLinejoin: "round",
340
- strokeWidth: 2,
341
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", {
342
- width: 14,
343
- height: 14,
344
- x: 8,
345
- y: 8,
346
- rx: 2,
347
- ry: 2
348
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })]
349
- })
350
- });
351
- //#endregion
352
- //#region ~icons/lucide/pencil.jsx
353
- var lucidePencil = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
354
- viewBox: "0 0 24 24",
355
- width: "1.2em",
356
- height: "1.2em",
357
- ...props,
358
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
359
- fill: "none",
360
- stroke: "currentColor",
361
- strokeLinecap: "round",
362
- strokeLinejoin: "round",
363
- strokeWidth: 2,
364
- 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"
365
- })
366
- });
367
- //#endregion
368
- //#region ~icons/lucide/trash-2.jsx
369
- var lucideTrash2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
370
- viewBox: "0 0 24 24",
371
- width: "1.2em",
372
- height: "1.2em",
373
- ...props,
374
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
375
- fill: "none",
376
- stroke: "currentColor",
377
- strokeLinecap: "round",
378
- strokeLinejoin: "round",
379
- strokeWidth: 2,
380
- 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"
381
- })
382
- });
383
- object({
384
- system: string().optional(),
385
- prompt: string(),
386
- timeout: number().optional()
387
- });
388
- object({
389
- text: string(),
390
- usage: object({
391
- input_tokens: number(),
392
- output_tokens: number(),
393
- cache_creation_input_tokens: number(),
394
- cache_read_input_tokens: number()
395
- }),
396
- durationMs: number(),
397
- costUsd: number()
398
- });
399
- object({
400
- tokens: array(string()),
401
- size: number().optional(),
402
- model: string().optional(),
403
- timeout: number().optional(),
404
- cwd: string().optional(),
405
- maxCalls: number().optional()
406
- });
407
- object({
408
- token: string(),
409
- name: string()
410
- });
411
- object({ token: string() });
412
- object({
413
- token: string(),
414
- name: string(),
415
- requests: number(),
416
- active: boolean()
417
- });
418
- object({ authUrl: string() });
419
- var RateLimit = object({
420
- utilization: number().nullable(),
421
- resets_at: string().nullable()
422
- }).nullable();
423
- object({
424
- error: string().optional(),
425
- five_hour: RateLimit.optional(),
426
- seven_day: RateLimit.optional(),
427
- seven_day_opus: RateLimit.optional(),
428
- seven_day_sonnet: RateLimit.optional(),
429
- seven_day_oauth_apps: RateLimit.optional(),
430
- seven_day_cowork: RateLimit.optional(),
431
- extra_usage: object({
432
- is_enabled: boolean(),
433
- monthly_limit: number().nullable(),
434
- used_credits: number().nullable(),
435
- utilization: number().nullable()
436
- }).nullable().optional()
437
- });
438
- object({
439
- status: string(),
440
- workers: number(),
441
- activeTokens: number()
442
- });
443
- function maskToken(token) {
444
- return token.length > 4 ? `...${token.slice(-4)}` : token;
445
- }
446
- //#endregion
447
- //#region src/components/qgrid/TokenTable.tsx
448
- function formatExpiry(expiresAt) {
449
- if (!expiresAt) return {
450
- text: "",
451
- color: ""
452
- };
453
- const diff = Number(expiresAt) - Date.now();
454
- if (diff <= 0) return {
455
- text: "expired",
456
- color: "text-red-500"
457
- };
458
- const h = Math.floor(diff / 36e5);
459
- const m = Math.floor(diff % 36e5 / 6e4);
460
- const text = h > 0 ? `${h}h ${m}m` : `${m}m`;
461
- if (diff < 36e5) return {
462
- text,
463
- color: "text-amber-500"
464
- };
465
- return {
466
- text,
467
- color: "text-sand-400"
468
- };
469
- }
470
- function TokenTable({ data, isLoading }) {
471
- const [deleteTarget, setDeleteTarget] = (0, import_react.useState)(null);
472
- const [editTarget, setEditTarget] = (0, import_react.useState)(null);
473
- const [showEditToken, setShowEditToken] = (0, import_react.useState)(false);
474
- const [showRefreshToken, setShowRefreshToken] = (0, import_react.useState)(false);
475
- const [copiedToken, setCopiedToken] = (0, import_react.useState)(false);
476
- const [copiedRefreshToken, setCopiedRefreshToken] = (0, import_react.useState)(false);
477
- const { form, setForm, register } = m5(TokenSaveParams, {
478
- name: "",
479
- token: "",
480
- active: true
481
- });
482
- const queryClient = useQueryClient();
483
- const removeMutation = QgridService.useRemoveTokenMutation();
484
- const updateMutation = QgridService.useUpdateTokenMutation();
485
- const toggleMutation = QgridService.useToggleTokenMutation();
486
- const invalidate = () => Promise.all([queryClient.invalidateQueries({ queryKey: ["Token"] }), queryClient.invalidateQueries({ queryKey: ["Qgrid"] })]);
487
- const handleToggle = async (token) => {
488
- await toggleMutation.mutateAsync({ id: token.id });
489
- await invalidate();
490
- };
491
- const handleDelete = async () => {
492
- if (!deleteTarget) return;
493
- await removeMutation.mutateAsync({ token: deleteTarget.token });
494
- await invalidate();
495
- setDeleteTarget(null);
496
- };
497
- const openEdit = (token) => {
498
- setEditTarget(token);
499
- setForm({
500
- name: token.name ?? "",
501
- token: token.token,
502
- active: token.active,
503
- refresh_token: token.refresh_token ?? ""
504
- });
505
- setShowEditToken(false);
506
- setShowRefreshToken(false);
507
- setCopiedToken(false);
508
- setCopiedRefreshToken(false);
509
- };
510
- const handleUpdate = async () => {
511
- if (!editTarget) return;
512
- const newToken = form.token && form.token !== editTarget.token ? form.token.trim() : void 0;
513
- const mutations = [updateMutation.mutateAsync({
514
- token: editTarget.token,
515
- name: form.name?.trim() ?? "",
516
- newToken: newToken ?? "",
517
- refreshToken: form.refresh_token?.trim() ?? ""
518
- })];
519
- if (form.active !== editTarget.active) mutations.push(toggleMutation.mutateAsync({ id: editTarget.id }));
520
- await Promise.all(mutations);
521
- await invalidate();
522
- setEditTarget(null);
523
- };
524
- const handleCopyToken = () => {
525
- if (!editTarget) return;
526
- navigator.clipboard.writeText(editTarget.token);
527
- setCopiedToken(true);
528
- setTimeout(() => setCopiedToken(false), 1500);
529
- };
530
- const handleCopyRefreshToken = () => {
531
- if (!editTarget?.refresh_token) return;
532
- navigator.clipboard.writeText(editTarget.refresh_token);
533
- setCopiedRefreshToken(true);
534
- setTimeout(() => setCopiedRefreshToken(false), 1500);
535
- };
536
- if (isLoading) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
537
- className: "space-y-2",
538
- children: Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-12 bg-sand-100 rounded-md animate-pulse" }, `skeleton-${i}`))
539
- });
540
- const tokens = data ?? [];
541
- if (tokens.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
542
- className: "text-sand-400 text-center py-16 text-sm",
543
- children: [
544
- "No tokens registered. Click ",
545
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", {
546
- className: "text-sand-600",
547
- children: "Add Token"
548
- }),
549
- " to get started."
550
- ]
551
- });
552
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
553
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
554
- className: "rounded-lg bg-sand-50 overflow-hidden",
555
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", {
556
- className: "w-full text-sm",
557
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
558
- className: "border-b border-sand-200",
559
- children: [
560
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
561
- className: "text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
562
- children: "Token"
563
- }),
564
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
565
- className: "text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
566
- children: "Name"
567
- }),
568
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
569
- className: "text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
570
- children: "Status"
571
- }),
572
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
573
- className: "text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
574
- children: "Expires"
575
- }),
576
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { className: "w-20 px-3 py-3" })
577
- ]
578
- }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", {
579
- className: "divide-y divide-sand-200/60",
580
- children: tokens.map((token) => {
581
- const expiry = formatExpiry(token.expires_at);
582
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
583
- className: `transition-colors duration-150 hover:bg-sand-100/60 ${token.active ? "" : "opacity-50"}`,
584
- children: [
585
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
586
- className: "px-5 py-3",
587
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
588
- className: "text-[13px] font-mono text-sand-800",
589
- children: maskToken(token.token)
590
- })
591
- }),
592
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
593
- className: "px-5 py-3",
594
- children: token.name ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
595
- className: "text-sm text-sand-700",
596
- children: token.name
597
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
598
- className: "text-[11px] text-sand-400",
599
- children: "—"
600
- })
601
- }),
602
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
603
- className: "px-5 py-3",
604
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
605
- type: "button",
606
- className: `relative inline-flex h-5 w-9 items-center rounded-full transition-colors duration-200 ${token.active ? "bg-sage-400" : "bg-sand-300"}`,
607
- onClick: () => handleToggle(token),
608
- disabled: toggleMutation.isPending,
609
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform duration-200 ${token.active ? "translate-x-4.5" : "translate-x-0.5"}` })
610
- })
611
- }),
612
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
613
- className: "px-5 py-3",
614
- children: expiry.text && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
615
- className: `text-xs ${expiry.color}`,
616
- children: expiry.text
617
- })
618
- }),
619
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
620
- className: "px-3 py-3",
621
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
622
- className: "flex items-center gap-1",
623
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
624
- type: "button",
625
- className: "p-1 rounded text-sand-400 hover:text-sienna-500 transition-colors duration-150",
626
- onClick: () => openEdit(token),
627
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucidePencil, { className: "size-4" })
628
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
629
- type: "button",
630
- className: "p-1 rounded text-sand-400 hover:text-red-500 transition-colors duration-150",
631
- onClick: () => setDeleteTarget(token),
632
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideTrash2, { className: "size-4" })
633
- })]
634
- })
635
- })
636
- ]
637
- }, token.id);
638
- })
639
- })]
640
- })
641
- }),
642
- editTarget && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
643
- className: "fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",
644
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
645
- className: "absolute inset-0",
646
- onClick: () => setEditTarget(null),
647
- onKeyDown: () => {}
648
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
649
- className: "relative bg-white rounded-lg shadow-xl w-full max-w-sm mx-4",
650
- children: [
651
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
652
- className: "px-5 py-4 border-b border-sand-100",
653
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
654
- className: "text-base font-medium text-sand-900",
655
- children: "Edit Token"
656
- })
657
- }),
658
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
659
- className: "px-5 py-4 space-y-3",
660
- children: [
661
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
662
- htmlFor: "token-name",
663
- className: "text-[10px] uppercase tracking-wider text-sand-500 font-medium",
664
- children: "Name"
665
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(mn, {
666
- ...register("name"),
667
- placeholder: "e.g. prod, dev, team-a",
668
- 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"
669
- })] }),
670
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
671
- className: "flex items-center gap-2",
672
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
673
- id: "token-active",
674
- type: "checkbox",
675
- checked: form.active ?? true,
676
- onChange: (e) => setForm({
677
- ...form,
678
- active: e.target.checked
679
- }),
680
- className: "h-4 w-4 rounded border-sand-300 text-sienna-500 focus:ring-sienna-300"
681
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
682
- htmlFor: "token-active",
683
- className: "text-sm text-sand-700",
684
- children: "Active"
685
- })]
686
- }),
687
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
688
- className: "flex items-center justify-between",
689
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
690
- htmlFor: "token-value",
691
- className: "text-[10px] uppercase tracking-wider text-sand-500 font-medium",
692
- children: "Token"
693
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
694
- className: "flex items-center gap-2",
695
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
696
- type: "button",
697
- className: "flex items-center gap-1 text-[10px] text-sand-400 hover:text-sienna-500 transition-colors duration-150",
698
- onClick: handleCopyToken,
699
- children: copiedToken ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideCheck, { className: "size-3 text-sage-500" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
700
- className: "text-sage-500",
701
- children: "Copied"
702
- })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideCopy, { className: "size-3" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Copy" })] })
703
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
704
- type: "button",
705
- className: "flex items-center gap-1 text-[10px] text-sand-400 hover:text-sand-600 transition-colors duration-150",
706
- onClick: () => setShowEditToken(!showEditToken),
707
- children: showEditToken ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideEyeOff, { className: "size-3" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Hide" })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideEye, { className: "size-3" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Show" })] })
708
- })]
709
- })]
710
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
711
- id: "token-value",
712
- type: showEditToken ? "text" : "password",
713
- value: form.token || (showEditToken ? editTarget.token : ""),
714
- onChange: (e) => setForm({
715
- ...form,
716
- token: e.target.value
717
- }),
718
- placeholder: showEditToken ? "" : "●●●●●●●●●●●●●●●●",
719
- 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"
720
- })] }),
721
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
722
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
723
- className: "flex items-center justify-between",
724
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
725
- htmlFor: "edit-refresh-token",
726
- className: "text-[10px] uppercase tracking-wider text-sand-500 font-medium",
727
- children: [
728
- "Refresh Token",
729
- " ",
730
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
731
- className: "text-sand-400 normal-case tracking-normal",
732
- children: "(optional)"
733
- })
734
- ]
735
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
736
- className: "flex items-center gap-2",
737
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
738
- type: "button",
739
- className: "flex items-center gap-1 text-[10px] text-sand-400 hover:text-sienna-500 transition-colors duration-150",
740
- onClick: handleCopyRefreshToken,
741
- children: copiedRefreshToken ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideCheck, { className: "size-3 text-sage-500" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
742
- className: "text-sage-500",
743
- children: "Copied"
744
- })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideCopy, { className: "size-3" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Copy" })] })
745
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
746
- type: "button",
747
- className: "flex items-center gap-1 text-[10px] text-sand-400 hover:text-sand-600 transition-colors duration-150",
748
- onClick: () => setShowRefreshToken(!showRefreshToken),
749
- children: showRefreshToken ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideEyeOff, { className: "size-3" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Hide" })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideEye, { className: "size-3" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Show" })] })
750
- })]
751
- })]
752
- }),
753
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
754
- id: "edit-refresh-token",
755
- type: showRefreshToken ? "text" : "password",
756
- value: form.refresh_token ?? "",
757
- onChange: (e) => setForm({
758
- ...form,
759
- refresh_token: e.target.value
760
- }),
761
- placeholder: "sk-ant-ort01-...",
762
- 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"
763
- }),
764
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
765
- className: "text-[10px] text-sand-400 mt-1",
766
- children: "Enables auto-refresh when access token expires"
767
- })
768
- ] })
769
- ]
770
- }),
771
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
772
- className: "px-5 py-3 border-t border-sand-100 flex items-center justify-end gap-2",
773
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
774
- type: "button",
775
- 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",
776
- onClick: () => setEditTarget(null),
777
- children: "Cancel"
778
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
779
- type: "button",
780
- 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",
781
- disabled: updateMutation.isPending,
782
- onClick: handleUpdate,
783
- children: updateMutation.isPending ? "Saving..." : "Save"
784
- })]
785
- })
786
- ]
787
- })]
788
- }),
789
- deleteTarget && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
790
- className: "fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",
791
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
792
- className: "absolute inset-0",
793
- onClick: () => setDeleteTarget(null),
794
- onKeyDown: () => {}
795
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
796
- className: "relative bg-white rounded-lg shadow-xl w-full max-w-sm mx-4",
797
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
798
- className: "px-5 py-4",
799
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
800
- className: "text-base font-medium text-sand-900",
801
- children: "Remove Token"
802
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
803
- className: "text-sm text-sand-700 mt-2",
804
- children: [
805
- "Are you sure you want to remove",
806
- " ",
807
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
808
- className: "text-[13px] font-mono text-sand-800",
809
- children: maskToken(deleteTarget.token)
810
- }),
811
- deleteTarget.name && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
812
- className: "text-sand-500",
813
- children: [
814
- " (",
815
- deleteTarget.name,
816
- ")"
817
- ]
818
- }),
819
- "?"
820
- ]
821
- })]
822
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
823
- className: "px-5 py-3 border-t border-sand-100 flex items-center justify-end gap-2",
824
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
825
- type: "button",
826
- 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",
827
- onClick: () => setDeleteTarget(null),
828
- children: "Cancel"
829
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
830
- type: "button",
831
- 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",
832
- disabled: removeMutation.isPending,
833
- onClick: handleDelete,
834
- children: removeMutation.isPending ? "Removing..." : "Remove"
835
- })]
836
- })]
837
- })]
838
- })
839
- ] });
840
- }
841
- //#endregion
842
- //#region src/routes/tokens.tsx?tsr-split=component
843
- function TokensPage() {
844
- const { data, isLoading } = TokenService.useTokens("A");
845
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
846
- className: "space-y-5 max-w-300 mx-auto -translate-x-4",
847
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
848
- className: "flex items-center justify-between",
849
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
850
- className: "text-xl font-medium text-sand-900 tracking-tight",
851
- children: "Tokens"
852
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AddTokenModal, {})]
853
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TokenTable, {
854
- data: data?.rows,
855
- isLoading
856
- })]
857
- });
858
- }
859
- //#endregion
860
- export { TokensPage as component };