@cartanova/qgrid-cli 1.0.1 → 1.0.3

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 (138) hide show
  1. package/bundle/dist/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
  2. package/bundle/dist/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js +6 -0
  3. package/bundle/dist/dist/_virtual/_rolldown/runtime.js +15 -0
  4. package/bundle/dist/dist/application/qgrid/oauth.js +140 -0
  5. package/bundle/dist/dist/application/qgrid/pool.js +100 -0
  6. package/bundle/dist/dist/application/qgrid/qgrid.frame.js +280 -0
  7. package/bundle/dist/dist/application/qgrid/qgrid.types.js +79 -0
  8. package/bundle/dist/dist/application/qgrid/worker.js +183 -0
  9. package/bundle/dist/dist/application/queries.generated.js +31 -0
  10. package/bundle/dist/dist/application/request-log/request-log.model.js +113 -0
  11. package/bundle/dist/dist/application/request-log/request-log.types.js +13 -0
  12. package/bundle/dist/dist/application/sonamu.generated.js +99 -0
  13. package/bundle/dist/dist/application/sonamu.generated.sso.js +34 -0
  14. package/bundle/dist/dist/application/token/token.model.js +157 -0
  15. package/bundle/dist/dist/application/token/token.types.js +22 -0
  16. package/bundle/dist/dist/i18n/en.js +63 -0
  17. package/bundle/dist/dist/i18n/ko.js +62 -0
  18. package/bundle/dist/dist/i18n/sd.generated.js +272 -0
  19. package/bundle/dist/dist/index.js +11 -0
  20. package/bundle/dist/dist/migrations/20260410171405_create__request_logs.js +26 -0
  21. package/bundle/dist/dist/migrations/20260410171406_create__tokens.js +24 -0
  22. package/bundle/dist/dist/migrations/20260411120624_alter_tokens_alter2.js +16 -0
  23. package/bundle/dist/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +155 -0
  24. package/bundle/dist/dist/node_modules/.pnpm/@vitest_expect@4.1.2/node_modules/@vitest/expect/dist/index.js +1484 -0
  25. package/bundle/dist/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.2/node_modules/@vitest/pretty-format/dist/index.js +887 -0
  26. package/bundle/dist/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/chunk-artifact.js +2746 -0
  27. package/bundle/dist/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/index.js +8 -0
  28. package/bundle/dist/dist/node_modules/.pnpm/@vitest_runner@4.1.2/node_modules/@vitest/runner/dist/utils.js +8 -0
  29. package/bundle/dist/dist/node_modules/.pnpm/@vitest_snapshot@4.1.2/node_modules/@vitest/snapshot/dist/index.js +662 -0
  30. package/bundle/dist/dist/node_modules/.pnpm/@vitest_spy@4.1.2/node_modules/@vitest/spy/dist/index.js +386 -0
  31. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +82 -0
  32. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/constants.js +48 -0
  33. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/diff.js +1307 -0
  34. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/display.js +558 -0
  35. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/error.js +33 -0
  36. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/helpers.js +226 -0
  37. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/offset.js +27 -0
  38. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/serialize.js +77 -0
  39. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/source-map.js +374 -0
  40. package/bundle/dist/dist/node_modules/.pnpm/@vitest_utils@4.1.2/node_modules/@vitest/utils/dist/timers.js +37 -0
  41. package/bundle/dist/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.js +2886 -0
  42. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/branding.js +10 -0
  43. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/index.js +109 -0
  44. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/messages.js +10 -0
  45. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/overloads.js +10 -0
  46. package/bundle/dist/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/utils.js +10 -0
  47. package/bundle/dist/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js +1127 -0
  48. package/bundle/dist/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +21 -0
  49. package/bundle/dist/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +432 -0
  50. package/bundle/dist/dist/node_modules/.pnpm/tinybench@2.9.0/node_modules/tinybench/dist/index.js +506 -0
  51. package/bundle/dist/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.js +86 -0
  52. 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 +426 -0
  53. 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 +6 -0
  54. 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 +41 -0
  55. 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 +19 -0
  56. 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 +202 -0
  57. 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 +16 -0
  58. 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 +59 -0
  59. 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 +2910 -0
  60. 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 +44 -0
  61. 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 +28 -0
  62. package/bundle/dist/dist/sonamu.config.js +196 -0
  63. package/bundle/dist/dist/testing/fixture.js +8 -0
  64. package/bundle/dist/dist/testing/global.js +9 -0
  65. package/bundle/dist/dist/testing/setup-mocks.js +17 -0
  66. package/bundle/dist/dist/utils/subset-loaders.js +12 -0
  67. package/bundle/src/application/qgrid/oauth.ts +181 -0
  68. package/bundle/src/application/qgrid/pool.ts +132 -0
  69. package/bundle/src/application/qgrid/qgrid.frame.ts +275 -0
  70. package/bundle/src/application/qgrid/qgrid.types.ts +117 -0
  71. package/bundle/src/application/qgrid/worker.ts +234 -0
  72. package/bundle/src/application/queries.generated.ts +59 -0
  73. package/bundle/src/application/request-log/request-log.model.ts +155 -0
  74. package/bundle/src/application/request-log/request-log.types.ts +15 -0
  75. package/bundle/src/application/sonamu.generated.http +187 -0
  76. package/bundle/src/application/sonamu.generated.sso.ts +66 -0
  77. package/bundle/src/application/sonamu.generated.ts +135 -0
  78. package/bundle/src/application/token/token.model.ts +160 -0
  79. package/bundle/src/application/token/token.types.ts +26 -0
  80. package/bundle/src/i18n/en.ts +59 -0
  81. package/bundle/src/i18n/ko.ts +59 -0
  82. package/bundle/src/i18n/sd.generated.ts +384 -0
  83. package/bundle/src/index.ts +6 -0
  84. package/bundle/src/sonamu.config.ts +248 -0
  85. package/bundle/src/src/application/qgrid/oauth.ts +181 -0
  86. package/bundle/src/src/application/qgrid/pool.ts +132 -0
  87. package/bundle/src/src/application/qgrid/qgrid.frame.ts +275 -0
  88. package/bundle/src/src/application/qgrid/qgrid.types.ts +117 -0
  89. package/bundle/src/src/application/qgrid/worker.ts +234 -0
  90. package/bundle/src/src/application/queries.generated.ts +59 -0
  91. package/bundle/src/src/application/request-log/request-log.entity.json +75 -0
  92. package/bundle/src/src/application/request-log/request-log.model.ts +155 -0
  93. package/bundle/src/src/application/request-log/request-log.types.ts +15 -0
  94. package/bundle/src/src/application/sonamu.generated.http +187 -0
  95. package/bundle/src/src/application/sonamu.generated.sso.ts +66 -0
  96. package/bundle/src/src/application/sonamu.generated.ts +135 -0
  97. package/bundle/src/src/application/token/token.entity.json +37 -0
  98. package/bundle/src/src/application/token/token.model.ts +160 -0
  99. package/bundle/src/src/application/token/token.types.ts +26 -0
  100. package/bundle/src/src/i18n/en.ts +59 -0
  101. package/bundle/src/src/i18n/ko.ts +59 -0
  102. package/bundle/src/src/i18n/sd.generated.ts +384 -0
  103. package/bundle/src/src/index.ts +6 -0
  104. package/bundle/src/src/migrations/20260410171405_create__request_logs.ts +23 -0
  105. package/bundle/src/src/migrations/20260410171406_create__tokens.ts +21 -0
  106. package/bundle/src/src/migrations/20260411120624_alter_tokens_alter2.ts +15 -0
  107. package/bundle/src/src/sonamu.config.ts +248 -0
  108. package/bundle/src/src/testing/fixture.ts +6 -0
  109. package/bundle/src/src/testing/global.ts +6 -0
  110. package/bundle/src/src/testing/setup-mocks.ts +44 -0
  111. package/bundle/src/src/typings/fastify.d.ts +8 -0
  112. package/bundle/src/src/typings/sonamu.d.ts +17 -0
  113. package/bundle/src/src/utils/subset-loaders.ts +11 -0
  114. package/bundle/src/testing/fixture.ts +6 -0
  115. package/bundle/src/testing/global.ts +6 -0
  116. package/bundle/src/testing/setup-mocks.ts +44 -0
  117. package/bundle/src/typings/fastify.d.ts +8 -0
  118. package/bundle/src/typings/sonamu.d.ts +17 -0
  119. package/bundle/src/utils/subset-loaders.ts +11 -0
  120. package/bundle/web-dist/web-dist/client/assets/index-DlPchHBY.js +116 -0
  121. package/bundle/web-dist/web-dist/client/assets/index-vZsvyuFn.css +1 -0
  122. package/bundle/web-dist/web-dist/client/assets/rolldown-runtime-Dw2cE7zH.js +1 -0
  123. package/bundle/web-dist/web-dist/client/assets/routes-CagDz23B.js +1 -0
  124. package/bundle/web-dist/web-dist/client/assets/sd.generated-BrQoQXvv.js +47 -0
  125. package/bundle/web-dist/web-dist/client/assets/services.generated-BspO2L0j.js +1 -0
  126. package/bundle/web-dist/web-dist/client/assets/show-aXUGa0gm.js +29 -0
  127. package/bundle/web-dist/web-dist/client/assets/tokens-DRkXtZ3Q.js +1 -0
  128. package/bundle/web-dist/web-dist/client/assets/vendor-react-DH4kUfK2.js +9 -0
  129. package/bundle/web-dist/web-dist/client/assets/vendor-tanstack-CUxlo6YN.js +1 -0
  130. package/bundle/web-dist/web-dist/client/index.html +18 -0
  131. package/bundle/web-dist/web-dist/server/assets/react-dom-CGIzOSuj.js +335 -0
  132. package/bundle/web-dist/web-dist/server/assets/routes-ClzReRep.js +490 -0
  133. package/bundle/web-dist/web-dist/server/assets/sd.generated-BnonqqKr.js +21694 -0
  134. package/bundle/web-dist/web-dist/server/assets/services.generated-D5ABD5fr.js +836 -0
  135. package/bundle/web-dist/web-dist/server/assets/show-C9pcdSxc.js +23364 -0
  136. package/bundle/web-dist/web-dist/server/assets/tokens-JH6FsnWZ.js +860 -0
  137. package/bundle/web-dist/web-dist/server/entry-server.generated.js +44646 -0
  138. package/package.json +11 -10
@@ -0,0 +1,187 @@
1
+ # @generated
2
+ # 직접 수정하지 마세요.
3
+
4
+ GET {{baseUrl}}/api/token/findById
5
+ ?subset=A
6
+ &id=0
7
+ Content-Type: application/json
8
+
9
+ ###
10
+
11
+ GET {{baseUrl}}/api/token/findMany
12
+ ?subset=A
13
+ &rawParams[num]=24
14
+ &rawParams[page]=1
15
+ &rawParams[search]=id
16
+ &rawParams[keyword]=KEYWORD
17
+ &rawParams[orderBy]=id-desc
18
+ &rawParams[queryMode]=both
19
+ &rawParams[id]=0
20
+ &rawParams[sonamuFilter]=unknown-custom
21
+ &rawParams[token]=TOKEN
22
+ Content-Type: application/json
23
+
24
+ ###
25
+
26
+ POST {{baseUrl}}/api/token/save
27
+ Content-Type: application/json
28
+
29
+ {
30
+ "spa": [
31
+ {
32
+ "id": 0,
33
+ "created_at": "2000-01-01",
34
+ "token": "TOKEN",
35
+ "name": "NAME",
36
+ "refresh_token": null,
37
+ "expires_at": null,
38
+ "account_uuid": null,
39
+ "active": false
40
+ }
41
+ ]
42
+ }
43
+
44
+ ###
45
+
46
+ POST {{baseUrl}}/api/token/del
47
+ Content-Type: application/json
48
+
49
+ {
50
+ "ids": [
51
+ 0
52
+ ]
53
+ }
54
+
55
+ ###
56
+
57
+ GET {{baseUrl}}/api/requestLog/findById
58
+ ?subset=A
59
+ &id=0
60
+ Content-Type: application/json
61
+
62
+ ###
63
+
64
+ GET {{baseUrl}}/api/requestLog/findMany
65
+ ?subset=A
66
+ &rawParams[num]=24
67
+ &rawParams[page]=1
68
+ &rawParams[search]=id
69
+ &rawParams[keyword]=KEYWORD
70
+ &rawParams[orderBy]=id-desc
71
+ &rawParams[queryMode]=both
72
+ &rawParams[id]=0
73
+ &rawParams[sonamuFilter]=unknown-custom
74
+ &rawParams[token_name]=TOKEN_NAME
75
+ Content-Type: application/json
76
+
77
+ ###
78
+
79
+ POST {{baseUrl}}/api/requestLog/save
80
+ Content-Type: application/json
81
+
82
+ {
83
+ "spa": [
84
+ {
85
+ "id": 0,
86
+ "created_at": "2000-01-01",
87
+ "token_name": "TOKEN_NAME",
88
+ "query": "QUERY",
89
+ "response": "RESPONSE",
90
+ "input_tokens": 0,
91
+ "output_tokens": 0,
92
+ "cache_read_tokens": 0,
93
+ "cache_creation_tokens": 0,
94
+ "duration_ms": 0
95
+ }
96
+ ]
97
+ }
98
+
99
+ ###
100
+
101
+ POST {{baseUrl}}/api/requestLog/del
102
+ Content-Type: application/json
103
+
104
+ {
105
+ "ids": [
106
+ 0
107
+ ]
108
+ }
109
+
110
+ ###
111
+
112
+ POST {{baseUrl}}/api/qgrid/query
113
+ Content-Type: application/json
114
+
115
+ {
116
+ "prompt": "PROMPT",
117
+ "system": "SYSTEM",
118
+ "timeout": 0
119
+ }
120
+
121
+ ###
122
+
123
+ GET {{baseUrl}}/api/qgrid/stats
124
+ ?
125
+ Content-Type: application/json
126
+
127
+ ###
128
+
129
+ POST {{baseUrl}}/api/qgrid/addToken
130
+ Content-Type: application/json
131
+
132
+ {
133
+ "token": "TOKEN",
134
+ "name": "NAME",
135
+ "refreshToken": "REFRESHTOKEN"
136
+ }
137
+
138
+ ###
139
+
140
+ POST {{baseUrl}}/api/qgrid/updateToken
141
+ Content-Type: application/json
142
+
143
+ {
144
+ "token": "TOKEN",
145
+ "name": "NAME",
146
+ "newToken": "NEWTOKEN",
147
+ "refreshToken": "REFRESHTOKEN"
148
+ }
149
+
150
+ ###
151
+
152
+ POST {{baseUrl}}/api/qgrid/removeToken
153
+ Content-Type: application/json
154
+
155
+ {
156
+ "token": "TOKEN"
157
+ }
158
+
159
+ ###
160
+
161
+ POST {{baseUrl}}/api/qgrid/toggleToken
162
+ Content-Type: application/json
163
+
164
+ {
165
+ "id": 0
166
+ }
167
+
168
+ ###
169
+
170
+ POST {{baseUrl}}/api/qgrid/oauthStart
171
+ Content-Type: application/json
172
+
173
+ {
174
+ "name": "NAME"
175
+ }
176
+
177
+ ###
178
+
179
+ GET {{baseUrl}}/api/qgrid/usage
180
+ ?tokenName=TOKENNAME
181
+ Content-Type: application/json
182
+
183
+ ###
184
+
185
+ GET {{baseUrl}}/api/qgrid/health
186
+ ?
187
+ Content-Type: application/json
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @generated
3
+ * 직접 수정하지 마세요.
4
+ */
5
+ import { PuriWrapper, DatabaseSchemaExtend, PuriLoaderQueries } from "sonamu";
6
+
7
+ import {
8
+ RequestLogSubsetKey,
9
+ TokenSubsetKey,
10
+ RequestLogBaseSchema,
11
+ TokenBaseSchema,
12
+ } from "./sonamu.generated";
13
+
14
+ // SubsetQuery: RequestLog
15
+ export const requestLogSubsetQueries = {
16
+ A: (qbWrapper: PuriWrapper<DatabaseSchemaExtend>) => {
17
+ return qbWrapper.from("request_logs").select({
18
+ id: "request_logs.id",
19
+ created_at: "request_logs.created_at",
20
+ token_name: "request_logs.token_name",
21
+ query: "request_logs.query",
22
+ response: "request_logs.response",
23
+ input_tokens: "request_logs.input_tokens",
24
+ output_tokens: "request_logs.output_tokens",
25
+ cache_read_tokens: "request_logs.cache_read_tokens",
26
+ cache_creation_tokens: "request_logs.cache_creation_tokens",
27
+ duration_ms: "request_logs.duration_ms",
28
+ });
29
+ },
30
+ };
31
+
32
+ // LoaderQuery: RequestLog
33
+ export const requestLogLoaderQueries = {
34
+ A: [],
35
+ } as const satisfies PuriLoaderQueries<RequestLogSubsetKey>;
36
+
37
+ // SubsetQuery: Token
38
+ export const tokenSubsetQueries = {
39
+ A: (qbWrapper: PuriWrapper<DatabaseSchemaExtend>) => {
40
+ return qbWrapper.from("tokens").select({
41
+ id: "tokens.id",
42
+ created_at: "tokens.created_at",
43
+ token: "tokens.token",
44
+ name: "tokens.name",
45
+ refresh_token: "tokens.refresh_token",
46
+ expires_at: "tokens.expires_at",
47
+ account_uuid: "tokens.account_uuid",
48
+ active: "tokens.active",
49
+ });
50
+ },
51
+ };
52
+
53
+ // LoaderQuery: Token
54
+ export const tokenLoaderQueries = {
55
+ A: [],
56
+ } as const satisfies PuriLoaderQueries<TokenSubsetKey>;
57
+
58
+ // DatabaseSchema
59
+ declare module "sonamu" {
60
+ export interface DatabaseSchemaExtend {
61
+ request_logs: RequestLogBaseSchema;
62
+ tokens: TokenBaseSchema;
63
+ }
64
+
65
+ export interface DatabaseForeignKeys {}
66
+ }
@@ -0,0 +1,135 @@
1
+ /**
2
+ * @generated
3
+ * 직접 수정하지 마세요.
4
+ */
5
+ /* oxlint-disable */
6
+
7
+ import { zArrayable, SonamuQueryMode, ApplySonamuFilter } from "sonamu";
8
+ import { z } from "zod";
9
+
10
+ // Enums: RequestLog
11
+ export const RequestLogOrderBy = z.enum(["id-desc"]).describe("RequestLogOrderBy");
12
+ export type RequestLogOrderBy = z.infer<typeof RequestLogOrderBy>;
13
+ export const RequestLogOrderByLabel = { "id-desc": "ID최신순" };
14
+ export const RequestLogSearchField = z
15
+ .enum(["id", "token_name", "query"])
16
+ .describe("RequestLogSearchField");
17
+ export type RequestLogSearchField = z.infer<typeof RequestLogSearchField>;
18
+ export const RequestLogSearchFieldLabel = { id: "ID", token_name: "토큰이름", query: "쿼리" };
19
+
20
+ // Enums: Token
21
+ export const TokenOrderBy = z.enum(["id-desc"]).describe("TokenOrderBy");
22
+ export type TokenOrderBy = z.infer<typeof TokenOrderBy>;
23
+ export const TokenOrderByLabel = { "id-desc": "ID최신순" };
24
+ export const TokenSearchField = z.enum(["id", "name"]).describe("TokenSearchField");
25
+ export type TokenSearchField = z.infer<typeof TokenSearchField>;
26
+ export const TokenSearchFieldLabel = { id: "ID", name: "이름" };
27
+
28
+ // BaseSchema: RequestLog
29
+ export const RequestLogBaseSchema = z.object({
30
+ id: z.int(),
31
+ created_at: z.date(),
32
+ token_name: z.string().max(100),
33
+ query: z.string(),
34
+ response: z.string(),
35
+ input_tokens: z.int(),
36
+ output_tokens: z.int(),
37
+ cache_read_tokens: z.int(),
38
+ cache_creation_tokens: z.int(),
39
+ duration_ms: z.int(),
40
+ });
41
+ export type RequestLogBaseSchema = z.infer<typeof RequestLogBaseSchema> & {
42
+ readonly __hasDefault__: readonly ["created_at", "id"];
43
+ };
44
+
45
+ // BaseSchema: Token
46
+ export const TokenBaseSchema = z.object({
47
+ id: z.int(),
48
+ created_at: z.date(),
49
+ token: z.string(),
50
+ name: z.string(),
51
+ refresh_token: z.string().nullable(),
52
+ expires_at: z.bigint().nullable(),
53
+ account_uuid: z.string().nullable(),
54
+ active: z.boolean(),
55
+ });
56
+ export type TokenBaseSchema = z.infer<typeof TokenBaseSchema> & {
57
+ readonly __hasDefault__: readonly [
58
+ "created_at",
59
+ "refresh_token",
60
+ "expires_at",
61
+ "account_uuid",
62
+ "active",
63
+ "id",
64
+ ];
65
+ };
66
+
67
+ // BaseListParams: RequestLog
68
+ export const RequestLogBaseListParams = z
69
+ .object({
70
+ num: z.number().int().nonnegative(),
71
+ page: z.number().int().min(1),
72
+ search: RequestLogSearchField,
73
+ keyword: z.string(),
74
+ orderBy: RequestLogOrderBy,
75
+ queryMode: SonamuQueryMode,
76
+ id: zArrayable(z.number().int().positive()),
77
+ sonamuFilter: z.custom<ApplySonamuFilter<RequestLogBaseSchema, never, never>>(),
78
+ token_name: z.string().max(100),
79
+ })
80
+ .partial();
81
+ export type RequestLogBaseListParams = z.infer<typeof RequestLogBaseListParams>;
82
+
83
+ // BaseListParams: Token
84
+ export const TokenBaseListParams = z
85
+ .object({
86
+ num: z.number().int().nonnegative(),
87
+ page: z.number().int().min(1),
88
+ search: TokenSearchField,
89
+ keyword: z.string(),
90
+ orderBy: TokenOrderBy,
91
+ queryMode: SonamuQueryMode,
92
+ id: zArrayable(z.number().int().positive()),
93
+ sonamuFilter: z.custom<ApplySonamuFilter<TokenBaseSchema, never, never>>(),
94
+ token: z.string(),
95
+ })
96
+ .partial();
97
+ export type TokenBaseListParams = z.infer<typeof TokenBaseListParams>;
98
+
99
+ // Subsets: RequestLog
100
+ export const RequestLogSubsetA = z.object({
101
+ id: z.int(),
102
+ created_at: z.date(),
103
+ token_name: z.string().max(100),
104
+ query: z.string(),
105
+ response: z.string(),
106
+ input_tokens: z.int(),
107
+ output_tokens: z.int(),
108
+ cache_read_tokens: z.int(),
109
+ cache_creation_tokens: z.int(),
110
+ duration_ms: z.int(),
111
+ });
112
+ export type RequestLogSubsetA = z.infer<typeof RequestLogSubsetA>;
113
+ export type RequestLogSubsetMapping = {
114
+ A: RequestLogSubsetA;
115
+ };
116
+ export const RequestLogSubsetKey = z.enum(["A"]);
117
+ export type RequestLogSubsetKey = z.infer<typeof RequestLogSubsetKey>;
118
+
119
+ // Subsets: Token
120
+ export const TokenSubsetA = z.object({
121
+ id: z.int(),
122
+ created_at: z.date(),
123
+ token: z.string(),
124
+ name: z.string(),
125
+ refresh_token: z.string().nullable(),
126
+ expires_at: z.bigint().nullable(),
127
+ account_uuid: z.string().nullable(),
128
+ active: z.boolean(),
129
+ });
130
+ export type TokenSubsetA = z.infer<typeof TokenSubsetA>;
131
+ export type TokenSubsetMapping = {
132
+ A: TokenSubsetA;
133
+ };
134
+ export const TokenSubsetKey = z.enum(["A"]);
135
+ export type TokenSubsetKey = z.infer<typeof TokenSubsetKey>;
@@ -0,0 +1,37 @@
1
+ {
2
+ "id": "Token",
3
+ "table": "tokens",
4
+ "title": "Token",
5
+ "props": [
6
+ { "name": "id", "type": "integer", "desc": "ID" },
7
+ { "name": "created_at", "type": "date", "desc": "등록일시", "dbDefault": "CURRENT_TIMESTAMP" },
8
+ { "name": "token", "toFilter": true, "desc": "access_token", "type": "string" },
9
+ { "name": "name", "desc": "토큰 이름", "type": "string" },
10
+ { "name": "refresh_token", "type": "string", "nullable": true, "desc": "refresh_token" },
11
+ {
12
+ "name": "expires_at",
13
+ "type": "bigInteger",
14
+ "nullable": true,
15
+ "desc": "만료 시각 (epoch ms)"
16
+ },
17
+ { "name": "account_uuid", "type": "string", "nullable": true, "desc": "Anthropic 계정 UUID" },
18
+ { "name": "active", "type": "boolean", "desc": "활성 여부", "dbDefault": "true" }
19
+ ],
20
+ "indexes": [],
21
+ "subsets": {
22
+ "A": [
23
+ "id",
24
+ "created_at",
25
+ "token",
26
+ "name",
27
+ "refresh_token",
28
+ "expires_at",
29
+ "account_uuid",
30
+ "active"
31
+ ]
32
+ },
33
+ "enums": {
34
+ "TokenOrderBy": { "id-desc": "ID최신순" },
35
+ "TokenSearchField": { "id": "ID", "name": "이름" }
36
+ }
37
+ }
@@ -0,0 +1,160 @@
1
+ import {
2
+ api,
3
+ asArray,
4
+ BadRequestException,
5
+ BaseModelClass,
6
+ exhaustive,
7
+ type ListResult,
8
+ NotFoundException,
9
+ } from "sonamu";
10
+
11
+ import { SD } from "../../i18n/sd.generated";
12
+ import type { TokenSubsetKey, TokenSubsetMapping } from "../sonamu.generated";
13
+ import { tokenLoaderQueries, tokenSubsetQueries } from "../sonamu.generated.sso";
14
+ import type { TokenListParams, TokenSaveParams } from "./token.types";
15
+
16
+ class TokenModelClass extends BaseModelClass<
17
+ TokenSubsetKey,
18
+ TokenSubsetMapping,
19
+ typeof tokenSubsetQueries,
20
+ typeof tokenLoaderQueries
21
+ > {
22
+ constructor() {
23
+ super("Token", tokenSubsetQueries, tokenLoaderQueries);
24
+ }
25
+
26
+ @api({ httpMethod: "GET", clients: ["axios", "tanstack-query"], resourceName: "Token" })
27
+ async findById<T extends TokenSubsetKey>(subset: T, id: number): Promise<TokenSubsetMapping[T]> {
28
+ const { rows } = await this.findMany(subset, { id, num: 1, page: 1 });
29
+ if (!rows[0]) {
30
+ throw new NotFoundException(SD("error.entityNotFound")("Token", id));
31
+ }
32
+ return rows[0];
33
+ }
34
+
35
+ async findOne<T extends TokenSubsetKey>(
36
+ subset: T,
37
+ listParams: TokenListParams,
38
+ ): Promise<TokenSubsetMapping[T] | null> {
39
+ const { rows } = await this.findMany(subset, { ...listParams, num: 1, page: 1 });
40
+ return rows[0] ?? null;
41
+ }
42
+
43
+ @api({ httpMethod: "GET", clients: ["axios", "tanstack-query"], resourceName: "Tokens" })
44
+ async findMany<T extends TokenSubsetKey, LP extends TokenListParams>(
45
+ subset: T,
46
+ rawParams?: LP,
47
+ ): Promise<ListResult<LP, TokenSubsetMapping[T]>> {
48
+ const params = {
49
+ num: 24,
50
+ page: 1,
51
+ search: "id" as const,
52
+ orderBy: "id-desc" as const,
53
+ ...rawParams,
54
+ } satisfies TokenListParams;
55
+
56
+ const { qb, onSubset: _ } = this.getSubsetQueries(subset);
57
+
58
+ if (params.id) {
59
+ qb.whereIn("tokens.id", asArray(params.id));
60
+ }
61
+
62
+ if (params.token) {
63
+ qb.where("tokens.token", params.token);
64
+ }
65
+
66
+ if (params.search && params.keyword && params.keyword.length > 0) {
67
+ if (params.search === "id") {
68
+ qb.where("tokens.id", Number(params.keyword));
69
+ } else if (params.search === "name") {
70
+ qb.where("tokens.name", "like", `%${params.keyword}%`);
71
+ } else {
72
+ throw new BadRequestException(SD("error.unknownSearchField")(params.search));
73
+ }
74
+ }
75
+
76
+ if (params.orderBy) {
77
+ if (params.orderBy === "id-desc") {
78
+ qb.orderBy("tokens.id", "desc");
79
+ } else {
80
+ exhaustive(params.orderBy);
81
+ }
82
+ }
83
+
84
+ const enhancers = this.createEnhancers({
85
+ A: (row) => ({ ...row }),
86
+ });
87
+
88
+ return this.executeSubsetQuery({ subset, qb, params, enhancers, debug: false });
89
+ }
90
+
91
+ async findByToken<T extends TokenSubsetKey>(
92
+ subset: T,
93
+ token: string,
94
+ ): Promise<TokenSubsetMapping[T] | null> {
95
+ const { qb } = this.getSubsetQueries(subset);
96
+ qb.where("tokens.token", token);
97
+ const enhancers = this.createEnhancers({ A: (row) => ({ ...row }) });
98
+ const result = await this.executeSubsetQuery({
99
+ subset,
100
+ qb,
101
+ params: { num: 1, page: 1 },
102
+ enhancers,
103
+ debug: false,
104
+ });
105
+ return result.rows[0] ?? null;
106
+ }
107
+
108
+ async findByAccountUuid<T extends TokenSubsetKey>(
109
+ subset: T,
110
+ accountUuid: string,
111
+ ): Promise<TokenSubsetMapping[T][]> {
112
+ const { qb } = this.getSubsetQueries(subset);
113
+ qb.where("tokens.account_uuid", accountUuid);
114
+ const enhancers = this.createEnhancers({ A: (row) => ({ ...row }) });
115
+ const result = await this.executeSubsetQuery({
116
+ subset,
117
+ qb,
118
+ params: { num: 100, page: 1 },
119
+ enhancers,
120
+ debug: false,
121
+ });
122
+ return result.rows;
123
+ }
124
+
125
+ async findActive<T extends TokenSubsetKey>(subset: T): Promise<TokenSubsetMapping[T][]> {
126
+ const { qb } = this.getSubsetQueries(subset);
127
+ qb.where("tokens.active", true);
128
+ const enhancers = this.createEnhancers({ A: (row) => ({ ...row }) });
129
+ const result = await this.executeSubsetQuery({
130
+ subset,
131
+ qb,
132
+ params: { num: 100, page: 1 },
133
+ enhancers,
134
+ debug: false,
135
+ });
136
+ return result.rows;
137
+ }
138
+
139
+ @api({ httpMethod: "POST", clients: ["axios", "tanstack-mutation"] })
140
+ async save(spa: TokenSaveParams[]): Promise<number[]> {
141
+ const wdb = this.getPuri("w");
142
+ spa.forEach((sp) => {
143
+ wdb.ubRegister("tokens", sp);
144
+ });
145
+ return wdb.transaction(async (trx) => {
146
+ return trx.ubUpsert("tokens");
147
+ });
148
+ }
149
+
150
+ @api({ httpMethod: "POST", clients: ["axios", "tanstack-mutation"] })
151
+ async del(ids: number[]): Promise<number> {
152
+ const wdb = this.getPuri("w");
153
+ await wdb.transaction(async (trx) => {
154
+ return trx.table("tokens").whereIn("tokens.id", ids).delete();
155
+ });
156
+ return ids.length;
157
+ }
158
+ }
159
+
160
+ export const TokenModel = new TokenModelClass();
@@ -0,0 +1,26 @@
1
+ import type { z } from "zod";
2
+
3
+ import { TokenBaseListParams, TokenBaseSchema } from "../sonamu.generated";
4
+
5
+ // Token - ListParams
6
+ export const TokenListParams = TokenBaseListParams;
7
+ export type TokenListParams = z.infer<typeof TokenListParams>;
8
+
9
+ // Token - SaveParams
10
+ export const TokenSaveParams = TokenBaseSchema.partial({
11
+ id: true,
12
+ created_at: true,
13
+ refresh_token: true,
14
+ expires_at: true,
15
+ account_uuid: true,
16
+ active: true,
17
+ });
18
+ export type TokenSaveParams = z.infer<typeof TokenSaveParams>;
19
+
20
+ export const refreshTokenParams = TokenSaveParams.pick({
21
+ id: true,
22
+ token: true,
23
+ refresh_token: true,
24
+ name: true,
25
+ });
26
+ export type RefreshTokenParams = z.infer<typeof refreshTokenParams>;
@@ -0,0 +1,59 @@
1
+ import { plural } from "sonamu/dict";
2
+
3
+ /**
4
+ * Project EN Dictionary
5
+ */
6
+ export default {
7
+ "common.all": "All",
8
+ "common.backToList": "Back to List",
9
+ "common.cancel": "Cancel",
10
+ "common.close": "Close",
11
+ "common.confirm": "Confirm",
12
+ "common.create": "Create",
13
+ "common.createdAt": "Created At",
14
+ "common.delete": "Delete",
15
+ "common.edit": "Edit",
16
+ "common.login": "Login",
17
+ "common.logout": "Logout",
18
+ "common.manage": "Manage",
19
+ "common.results": (count: number) =>
20
+ plural(count, { one: `${count} result`, other: `${count} results` }),
21
+ "common.save": "Save",
22
+ "common.search": "Search",
23
+ "common.searchPlaceholder": "Search...",
24
+ "common.searchType": "Search Type",
25
+ "common.sort": "Sort",
26
+ "confirm.delete": "Are you sure you want to delete?",
27
+ "confirm.save": "Do you want to save?",
28
+ "dashboard.adminMenu": "Admin Menu",
29
+ "dashboard.createdAt": "Joined",
30
+ "dashboard.email": "Email",
31
+ "dashboard.loginRequired": "Please login to continue.",
32
+ "dashboard.name": "Name",
33
+ "dashboard.role": "Role",
34
+ "dashboard.title": "Admin Dashboard",
35
+ "dashboard.welcome": "Welcome!",
36
+ "delete.confirm.description":
37
+ "This action cannot be undone. This will permanently delete this item.",
38
+ "delete.confirm.title": "Are you sure?",
39
+ "entity.create": (name: string) => `Create ${name}`,
40
+ "entity.edit": (name: string, id: number) => `Edit ${name} (#${id})`,
41
+ "entity.list": (name: string) => `${name} List`,
42
+ "entity.listManage": (name: string) => `Manage ${name} List`,
43
+ "error.alreadyProcessed": "Already processed",
44
+ "error.badRequest": "Bad request",
45
+ "error.duplicateRow": "Duplicate data",
46
+ "error.forbidden": "Forbidden",
47
+ "error.internalServerError": "Internal server error",
48
+ "error.notFound": "Not found",
49
+ "error.serviceUnavailable": "Service unavailable",
50
+ "error.unauthorized": "Unauthorized",
51
+ notFound: (name: string, id: number) => `${name} ID ${id} not found`,
52
+ "validation.email": "Invalid email format",
53
+ "validation.maxLength": (field: string, max: number) =>
54
+ `${field} must be at most ${max} characters`,
55
+ "validation.minLength": (field: string, min: number) =>
56
+ `${field} must be at least ${min} characters`,
57
+ "validation.required": (field: string) => `${field} is required`,
58
+ "validation.url": "Invalid URL format",
59
+ };