@getrouter/getrouter-cli 0.1.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.
- package/.github/workflows/ci.yml +19 -0
- package/AGENTS.md +78 -0
- package/README.ja.md +116 -0
- package/README.md +116 -0
- package/README.zh-cn.md +116 -0
- package/biome.json +10 -0
- package/bun.lock +397 -0
- package/dist/bin.mjs +1422 -0
- package/docs/plans/2026-01-01-getrouter-cli-config-command-plan.md +231 -0
- package/docs/plans/2026-01-01-getrouter-cli-config-core-plan.md +307 -0
- package/docs/plans/2026-01-01-getrouter-cli-design.md +106 -0
- package/docs/plans/2026-01-01-getrouter-cli-scaffold-plan.md +327 -0
- package/docs/plans/2026-01-02-getrouter-cli-auth-design.md +68 -0
- package/docs/plans/2026-01-02-getrouter-cli-auth-device-design.md +73 -0
- package/docs/plans/2026-01-02-getrouter-cli-auth-device-plan.md +411 -0
- package/docs/plans/2026-01-02-getrouter-cli-auth-plan.md +435 -0
- package/docs/plans/2026-01-02-getrouter-cli-http-client-plan.md +235 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-create-update-output-design.md +24 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-create-update-output-plan.md +141 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-delete-output-design.md +22 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-delete-output-plan.md +122 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-get-output-design.md +23 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-get-output-plan.md +141 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-interactive-design.md +28 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-interactive-plan.md +247 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-output-design.md +31 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-output-plan.md +187 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-subscription-design.md +52 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-subscription-plan.md +306 -0
- package/docs/plans/2026-01-02-getrouter-cli-setup-env-design.md +67 -0
- package/docs/plans/2026-01-02-getrouter-cli-setup-env-plan.md +441 -0
- package/docs/plans/2026-01-02-getrouter-cli-subscription-output-design.md +34 -0
- package/docs/plans/2026-01-02-getrouter-cli-subscription-output-plan.md +157 -0
- package/docs/plans/2026-01-03-bun-migration-plan.md +103 -0
- package/docs/plans/2026-01-03-cli-emoji-output.md +45 -0
- package/docs/plans/2026-01-03-cli-english-output.md +123 -0
- package/docs/plans/2026-01-03-cli-simplify-design.md +62 -0
- package/docs/plans/2026-01-03-cli-simplify-implementation.md +468 -0
- package/docs/plans/2026-01-03-readme-command-descriptions.md +116 -0
- package/docs/plans/2026-01-03-tsdown-migration-plan.md +75 -0
- package/docs/plans/2026-01-04-cli-docs-cleanup-design.md +49 -0
- package/docs/plans/2026-01-04-cli-docs-cleanup-plan.md +126 -0
- package/docs/plans/2026-01-04-codex-multistep-design.md +76 -0
- package/docs/plans/2026-01-04-codex-multistep-plan.md +240 -0
- package/docs/plans/2026-01-04-env-hook-design.md +48 -0
- package/docs/plans/2026-01-04-env-hook-plan.md +173 -0
- package/docs/plans/2026-01-04-models-keys-fuzzy-design.md +75 -0
- package/docs/plans/2026-01-04-models-keys-fuzzy-implementation.md +704 -0
- package/package.json +37 -0
- package/src/.gitkeep +0 -0
- package/src/bin.ts +4 -0
- package/src/cli.ts +12 -0
- package/src/cmd/auth.ts +44 -0
- package/src/cmd/claude.ts +10 -0
- package/src/cmd/codex.ts +119 -0
- package/src/cmd/config-helpers.ts +16 -0
- package/src/cmd/config.ts +31 -0
- package/src/cmd/env.ts +103 -0
- package/src/cmd/index.ts +20 -0
- package/src/cmd/keys.ts +207 -0
- package/src/cmd/models.ts +48 -0
- package/src/cmd/status.ts +106 -0
- package/src/cmd/usages.ts +29 -0
- package/src/core/api/client.ts +79 -0
- package/src/core/auth/device.ts +105 -0
- package/src/core/auth/index.ts +37 -0
- package/src/core/config/fs.ts +13 -0
- package/src/core/config/index.ts +37 -0
- package/src/core/config/paths.ts +5 -0
- package/src/core/config/redact.ts +18 -0
- package/src/core/config/types.ts +23 -0
- package/src/core/http/errors.ts +32 -0
- package/src/core/http/request.ts +41 -0
- package/src/core/http/url.ts +12 -0
- package/src/core/interactive/clipboard.ts +61 -0
- package/src/core/interactive/codex.ts +75 -0
- package/src/core/interactive/fuzzy.ts +64 -0
- package/src/core/interactive/keys.ts +164 -0
- package/src/core/output/table.ts +34 -0
- package/src/core/output/usages.ts +75 -0
- package/src/core/paths.ts +4 -0
- package/src/core/setup/codex.ts +129 -0
- package/src/core/setup/env.ts +220 -0
- package/src/core/usages/aggregate.ts +69 -0
- package/src/generated/router/dashboard/v1/index.ts +1104 -0
- package/src/index.ts +1 -0
- package/tests/.gitkeep +0 -0
- package/tests/auth/device.test.ts +75 -0
- package/tests/auth/status.test.ts +64 -0
- package/tests/cli.test.ts +31 -0
- package/tests/cmd/auth.test.ts +90 -0
- package/tests/cmd/claude.test.ts +132 -0
- package/tests/cmd/codex.test.ts +147 -0
- package/tests/cmd/config-helpers.test.ts +18 -0
- package/tests/cmd/config.test.ts +56 -0
- package/tests/cmd/keys.test.ts +163 -0
- package/tests/cmd/models.test.ts +63 -0
- package/tests/cmd/status.test.ts +82 -0
- package/tests/cmd/usages.test.ts +42 -0
- package/tests/config/fs.test.ts +14 -0
- package/tests/config/index.test.ts +63 -0
- package/tests/config/paths.test.ts +10 -0
- package/tests/config/redact.test.ts +17 -0
- package/tests/config/types.test.ts +10 -0
- package/tests/core/api/client.test.ts +92 -0
- package/tests/core/interactive/clipboard.test.ts +44 -0
- package/tests/core/interactive/codex.test.ts +17 -0
- package/tests/core/interactive/fuzzy.test.ts +30 -0
- package/tests/core/setup/codex.test.ts +38 -0
- package/tests/core/setup/env.test.ts +84 -0
- package/tests/core/usages/aggregate.test.ts +55 -0
- package/tests/http/errors.test.ts +15 -0
- package/tests/http/request.test.ts +82 -0
- package/tests/http/url.test.ts +17 -0
- package/tests/output/table.test.ts +29 -0
- package/tests/output/usages.test.ts +71 -0
- package/tests/paths.test.ts +9 -0
- package/tsconfig.json +13 -0
- package/tsdown.config.ts +5 -0
- package/vitest.config.ts +7 -0
|
@@ -0,0 +1,1104 @@
|
|
|
1
|
+
// Code generated by protoc-gen-typescript-http. DO NOT EDIT.
|
|
2
|
+
/* eslint-disable camelcase */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
|
|
5
|
+
// Identity represents a user identity such as email or phone.
|
|
6
|
+
export type Identity = {
|
|
7
|
+
// The unique ID of the identity.
|
|
8
|
+
id: string | undefined;
|
|
9
|
+
// The ID of the user this identity belongs to.
|
|
10
|
+
userId: string | undefined;
|
|
11
|
+
// The type of the identity.
|
|
12
|
+
type: Identity_Type | undefined;
|
|
13
|
+
// The identifier of the identity (e.g., email address).
|
|
14
|
+
identifier: string | undefined;
|
|
15
|
+
// The credential associated with the identity (e.g., password hash).
|
|
16
|
+
credential: string | undefined;
|
|
17
|
+
// The timestamp at which the identity was created.
|
|
18
|
+
createdAt: wellKnownTimestamp | undefined;
|
|
19
|
+
// The latest timestamp at which the identity was updated.
|
|
20
|
+
updatedAt: wellKnownTimestamp | undefined;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// The type of the identity.
|
|
24
|
+
export type Identity_Type =
|
|
25
|
+
| "TYPE_UNSPECIFIED"
|
|
26
|
+
| "EMAIL"
|
|
27
|
+
| "GITHUB";
|
|
28
|
+
// Encoded using RFC 3339, where generated output will always be Z-normalized
|
|
29
|
+
// and uses 0, 3, 6 or 9 fractional digits.
|
|
30
|
+
// Offsets other than "Z" are also accepted.
|
|
31
|
+
type wellKnownTimestamp = string;
|
|
32
|
+
|
|
33
|
+
// RegisterRequest is the request message for registering.
|
|
34
|
+
export type RegisterRequest = {
|
|
35
|
+
// The identity to register.
|
|
36
|
+
identity: Identity | undefined;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// UpdatePasswordRequest is the request message for updating password.
|
|
40
|
+
export type UpdatePasswordRequest = {
|
|
41
|
+
// The new password.
|
|
42
|
+
password: string | undefined;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// LoginRequest is the request message for logging in.
|
|
46
|
+
export type LoginRequest = {
|
|
47
|
+
// The type of the identity.
|
|
48
|
+
identity: Identity | undefined;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// ConnectRequest is the request message for initiating OAuth connection.
|
|
52
|
+
export type ConnectRequest = {
|
|
53
|
+
// The type of the identity.
|
|
54
|
+
//
|
|
55
|
+
// Behaviors: REQUIRED
|
|
56
|
+
type: Identity_Type | undefined;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// CallbackRequest is the request message for handling OAuth callbacks.
|
|
60
|
+
export type CallbackRequest = {
|
|
61
|
+
// The type of the identity.
|
|
62
|
+
//
|
|
63
|
+
// Behaviors: REQUIRED
|
|
64
|
+
type: Identity_Type | undefined;
|
|
65
|
+
// The code received from the OAuth provider.
|
|
66
|
+
//
|
|
67
|
+
// Behaviors: REQUIRED
|
|
68
|
+
code: string | undefined;
|
|
69
|
+
// The state parameter to prevent CSRF attacks.
|
|
70
|
+
//
|
|
71
|
+
// Behaviors: REQUIRED
|
|
72
|
+
state: string | undefined;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// IdentityService is the identity service definition.
|
|
76
|
+
export interface IdentityService {
|
|
77
|
+
// Register a new identity and user.
|
|
78
|
+
Register(request: RegisterRequest): Promise<routercommonv1_User>;
|
|
79
|
+
// Login an identity and return the associated user.
|
|
80
|
+
Login(request: LoginRequest): Promise<routercommonv1_User>;
|
|
81
|
+
// Logout the current identity.
|
|
82
|
+
Logout(request: wellKnownEmpty): Promise<wellKnownEmpty>;
|
|
83
|
+
// Connect initiates the OAuth connection flow for the given identity.
|
|
84
|
+
Connect(request: ConnectRequest): Promise<wellKnownEmpty>;
|
|
85
|
+
// Callback handles the OAuth callback for the given identity type.
|
|
86
|
+
// The type is specified in the URL path.
|
|
87
|
+
// For example: /v1/identities/GITHUB/callback
|
|
88
|
+
Callback(request: CallbackRequest): Promise<wellKnownEmpty>;
|
|
89
|
+
// UpdatePassword updates the password for the current user.
|
|
90
|
+
UpdatePassword(request: UpdatePasswordRequest): Promise<wellKnownEmpty>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type RequestType = {
|
|
94
|
+
path: string;
|
|
95
|
+
method: string;
|
|
96
|
+
body: string | null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
type RequestHandler = (request: RequestType, meta: { service: string, method: string }) => Promise<unknown>;
|
|
100
|
+
|
|
101
|
+
export function createIdentityServiceClient(
|
|
102
|
+
handler: RequestHandler
|
|
103
|
+
): IdentityService {
|
|
104
|
+
return {
|
|
105
|
+
Register(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
106
|
+
const path = `v1/dashboard/identities/register`; // eslint-disable-line quotes
|
|
107
|
+
const body = JSON.stringify(request?.identity ?? {});
|
|
108
|
+
const queryParams: string[] = [];
|
|
109
|
+
let uri = path;
|
|
110
|
+
if (queryParams.length > 0) {
|
|
111
|
+
uri += `?${queryParams.join("&")}`
|
|
112
|
+
}
|
|
113
|
+
return handler({
|
|
114
|
+
path: uri,
|
|
115
|
+
method: "POST",
|
|
116
|
+
body,
|
|
117
|
+
}, {
|
|
118
|
+
service: "IdentityService",
|
|
119
|
+
method: "Register",
|
|
120
|
+
}) as Promise<routercommonv1_User>;
|
|
121
|
+
},
|
|
122
|
+
Login(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
123
|
+
const path = `v1/dashboard/identities/login`; // eslint-disable-line quotes
|
|
124
|
+
const body = JSON.stringify(request?.identity ?? {});
|
|
125
|
+
const queryParams: string[] = [];
|
|
126
|
+
let uri = path;
|
|
127
|
+
if (queryParams.length > 0) {
|
|
128
|
+
uri += `?${queryParams.join("&")}`
|
|
129
|
+
}
|
|
130
|
+
return handler({
|
|
131
|
+
path: uri,
|
|
132
|
+
method: "POST",
|
|
133
|
+
body,
|
|
134
|
+
}, {
|
|
135
|
+
service: "IdentityService",
|
|
136
|
+
method: "Login",
|
|
137
|
+
}) as Promise<routercommonv1_User>;
|
|
138
|
+
},
|
|
139
|
+
Logout(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
140
|
+
const path = `v1/dashboard/identities/logout`; // eslint-disable-line quotes
|
|
141
|
+
const body = JSON.stringify(request);
|
|
142
|
+
const queryParams: string[] = [];
|
|
143
|
+
let uri = path;
|
|
144
|
+
if (queryParams.length > 0) {
|
|
145
|
+
uri += `?${queryParams.join("&")}`
|
|
146
|
+
}
|
|
147
|
+
return handler({
|
|
148
|
+
path: uri,
|
|
149
|
+
method: "POST",
|
|
150
|
+
body,
|
|
151
|
+
}, {
|
|
152
|
+
service: "IdentityService",
|
|
153
|
+
method: "Logout",
|
|
154
|
+
}) as Promise<wellKnownEmpty>;
|
|
155
|
+
},
|
|
156
|
+
Connect(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
157
|
+
const path = `v1/dashboard/identities/connect`; // eslint-disable-line quotes
|
|
158
|
+
const body = null;
|
|
159
|
+
const queryParams: string[] = [];
|
|
160
|
+
if (request.type) {
|
|
161
|
+
queryParams.push(`type=${encodeURIComponent(request.type.toString())}`)
|
|
162
|
+
}
|
|
163
|
+
let uri = path;
|
|
164
|
+
if (queryParams.length > 0) {
|
|
165
|
+
uri += `?${queryParams.join("&")}`
|
|
166
|
+
}
|
|
167
|
+
return handler({
|
|
168
|
+
path: uri,
|
|
169
|
+
method: "GET",
|
|
170
|
+
body,
|
|
171
|
+
}, {
|
|
172
|
+
service: "IdentityService",
|
|
173
|
+
method: "Connect",
|
|
174
|
+
}) as Promise<wellKnownEmpty>;
|
|
175
|
+
},
|
|
176
|
+
Callback(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
177
|
+
if (!request.type) {
|
|
178
|
+
throw new Error("missing required field request.type");
|
|
179
|
+
}
|
|
180
|
+
const path = `v1/dashboard/identities/${request.type}/callback`; // eslint-disable-line quotes
|
|
181
|
+
const body = null;
|
|
182
|
+
const queryParams: string[] = [];
|
|
183
|
+
if (request.code) {
|
|
184
|
+
queryParams.push(`code=${encodeURIComponent(request.code.toString())}`)
|
|
185
|
+
}
|
|
186
|
+
if (request.state) {
|
|
187
|
+
queryParams.push(`state=${encodeURIComponent(request.state.toString())}`)
|
|
188
|
+
}
|
|
189
|
+
let uri = path;
|
|
190
|
+
if (queryParams.length > 0) {
|
|
191
|
+
uri += `?${queryParams.join("&")}`
|
|
192
|
+
}
|
|
193
|
+
return handler({
|
|
194
|
+
path: uri,
|
|
195
|
+
method: "GET",
|
|
196
|
+
body,
|
|
197
|
+
}, {
|
|
198
|
+
service: "IdentityService",
|
|
199
|
+
method: "Callback",
|
|
200
|
+
}) as Promise<wellKnownEmpty>;
|
|
201
|
+
},
|
|
202
|
+
UpdatePassword(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
203
|
+
const path = `v1/dashboard/identities/password`; // eslint-disable-line quotes
|
|
204
|
+
const body = JSON.stringify(request);
|
|
205
|
+
const queryParams: string[] = [];
|
|
206
|
+
let uri = path;
|
|
207
|
+
if (queryParams.length > 0) {
|
|
208
|
+
uri += `?${queryParams.join("&")}`
|
|
209
|
+
}
|
|
210
|
+
return handler({
|
|
211
|
+
path: uri,
|
|
212
|
+
method: "PUT",
|
|
213
|
+
body,
|
|
214
|
+
}, {
|
|
215
|
+
service: "IdentityService",
|
|
216
|
+
method: "UpdatePassword",
|
|
217
|
+
}) as Promise<wellKnownEmpty>;
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
// User is the user message.
|
|
222
|
+
export type routercommonv1_User = {
|
|
223
|
+
// The unique ID of the user.
|
|
224
|
+
id: string | undefined;
|
|
225
|
+
// The name of the user.
|
|
226
|
+
name: string | undefined;
|
|
227
|
+
// The email of the user.
|
|
228
|
+
email: string | undefined;
|
|
229
|
+
// The phone number of the user.
|
|
230
|
+
phone: string | undefined;
|
|
231
|
+
// The avatar URL of the user.
|
|
232
|
+
avatar: string | undefined;
|
|
233
|
+
// The status of the user.
|
|
234
|
+
status: routercommonv1_User_Status | undefined;
|
|
235
|
+
// The timestamp at which the user was created.
|
|
236
|
+
createdAt: wellKnownTimestamp | undefined;
|
|
237
|
+
// The latest timestamp at which the user was updated.
|
|
238
|
+
updatedAt: wellKnownTimestamp | undefined;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export type routercommonv1_User_Status =
|
|
242
|
+
// Unknown status.
|
|
243
|
+
| "STATUS_UNSPECIFIED"
|
|
244
|
+
// Active user.
|
|
245
|
+
| "ACTIVE"
|
|
246
|
+
// Inactive user.
|
|
247
|
+
| "INACTIVE"
|
|
248
|
+
// Banned user.
|
|
249
|
+
| "BANNED";
|
|
250
|
+
// An empty JSON object
|
|
251
|
+
type wellKnownEmpty = Record<never, never>;
|
|
252
|
+
|
|
253
|
+
// SubscriptionService is the subscription service definition.
|
|
254
|
+
export interface SubscriptionService {
|
|
255
|
+
CurrentSubscription(request: wellKnownEmpty): Promise<routercommonv1_Subscription>;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function createSubscriptionServiceClient(
|
|
259
|
+
handler: RequestHandler
|
|
260
|
+
): SubscriptionService {
|
|
261
|
+
return {
|
|
262
|
+
CurrentSubscription(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
263
|
+
const path = `v1/dashboard/subscriptions/current`; // eslint-disable-line quotes
|
|
264
|
+
const body = null;
|
|
265
|
+
const queryParams: string[] = [];
|
|
266
|
+
let uri = path;
|
|
267
|
+
if (queryParams.length > 0) {
|
|
268
|
+
uri += `?${queryParams.join("&")}`
|
|
269
|
+
}
|
|
270
|
+
return handler({
|
|
271
|
+
path: uri,
|
|
272
|
+
method: "GET",
|
|
273
|
+
body,
|
|
274
|
+
}, {
|
|
275
|
+
service: "SubscriptionService",
|
|
276
|
+
method: "CurrentSubscription",
|
|
277
|
+
}) as Promise<routercommonv1_Subscription>;
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
// Subscription represents a user's subscription details.
|
|
282
|
+
export type routercommonv1_Subscription = {
|
|
283
|
+
// Unique identifier for the subscription.
|
|
284
|
+
id: string | undefined;
|
|
285
|
+
// User ID associated with the subscription.
|
|
286
|
+
userId: string | undefined;
|
|
287
|
+
// Plan ID of the subscription.
|
|
288
|
+
planId: string | undefined;
|
|
289
|
+
// Current status of the subscription.
|
|
290
|
+
status: routercommonv1_Subscription_Status | undefined;
|
|
291
|
+
// Start time of the subscription.
|
|
292
|
+
startAt: wellKnownTimestamp | undefined;
|
|
293
|
+
// End time of the subscription.
|
|
294
|
+
endAt: wellKnownTimestamp | undefined;
|
|
295
|
+
// Timestamps for subscription creation and last update.
|
|
296
|
+
createdAt: wellKnownTimestamp | undefined;
|
|
297
|
+
// Timestamp for the last update of the subscription.
|
|
298
|
+
updatedAt: wellKnownTimestamp | undefined;
|
|
299
|
+
// Associated plan details.
|
|
300
|
+
plan: routercommonv1_Plan | undefined;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// Status of the subscription.
|
|
304
|
+
export type routercommonv1_Subscription_Status =
|
|
305
|
+
// Subscription status is unspecified.
|
|
306
|
+
| "STATUS_UNSPECIFIED"
|
|
307
|
+
// Subscription is active.
|
|
308
|
+
| "ACTIVE"
|
|
309
|
+
// Subscription is inactive.
|
|
310
|
+
| "INACTIVE"
|
|
311
|
+
// Subscription is cancelled.
|
|
312
|
+
| "CANCELLED"
|
|
313
|
+
// Subscription has expired.
|
|
314
|
+
| "EXPIRED";
|
|
315
|
+
// Plan represents a subscription plan with its details.
|
|
316
|
+
export type routercommonv1_Plan = {
|
|
317
|
+
// Unique identifier for the plan.
|
|
318
|
+
id: string | undefined;
|
|
319
|
+
// Name of the plan. (e.g. Free、Starter、Pro、Business)
|
|
320
|
+
name: string | undefined;
|
|
321
|
+
// Description of the plan.
|
|
322
|
+
description: string | undefined;
|
|
323
|
+
// Price of the plan (decimal string, e.g. "9.99").
|
|
324
|
+
price: number | undefined;
|
|
325
|
+
// Currency code (ISO 4217), e.g. "USD".
|
|
326
|
+
currency: string | undefined;
|
|
327
|
+
// Billing cycle in days. E.g., 30 for monthly, 365 for yearly.
|
|
328
|
+
billingCycleDays: number | undefined;
|
|
329
|
+
// Rate limits for the plan. (e.g. Requests per minute 20)
|
|
330
|
+
requestPerMinute: number | undefined;
|
|
331
|
+
// Token limits for the plan. (e.g. Tokens per minute 150K)
|
|
332
|
+
tokenPerMinute: string | undefined;
|
|
333
|
+
// Timestamp for when the plan was created.
|
|
334
|
+
createdAt: wellKnownTimestamp | undefined;
|
|
335
|
+
// Timestamp for when the plan was last updated.
|
|
336
|
+
updatedAt: wellKnownTimestamp | undefined;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
// CreateConsumerRequest is the request message for CreateConsumer.
|
|
340
|
+
export type CreateConsumerRequest = {
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
// GetConsumerRequest is the request message for GetConsumer.
|
|
344
|
+
export type GetConsumerRequest = {
|
|
345
|
+
// Required. The id of the consumer to retrieve.
|
|
346
|
+
//
|
|
347
|
+
// Behaviors: REQUIRED
|
|
348
|
+
id: string | undefined;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
// ListConsumersRequest is the request message for ListConsumers.
|
|
352
|
+
export type ListConsumersRequest = {
|
|
353
|
+
// The maximum number of consumers to return. The service may return fewer than
|
|
354
|
+
// this value, even if there are additional pages. If unspecified, the
|
|
355
|
+
// server will pick an appropriate default.
|
|
356
|
+
pageSize: number | undefined;
|
|
357
|
+
// A page token, received from a previous `ListConsumers` call.
|
|
358
|
+
// Provide this to retrieve the subsequent page.
|
|
359
|
+
// When paginating, all other parameters provided to `ListConsumers` must
|
|
360
|
+
// match the call that provided the page token.
|
|
361
|
+
pageToken: string | undefined;
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
// ListConsumersResponse is the response message for ListConsumers.
|
|
365
|
+
export type ListConsumersResponse = {
|
|
366
|
+
// The consumers from the specified request.
|
|
367
|
+
consumers: routercommonv1_Consumer[] | undefined;
|
|
368
|
+
// A token to retrieve the next page of results.
|
|
369
|
+
// Pass this value in the `page_token` field of a subsequent `ListConsumers`
|
|
370
|
+
// request to retrieve the next page of results.
|
|
371
|
+
// If this field is omitted, there are no subsequent pages.
|
|
372
|
+
nextPageToken: string | undefined;
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// Consumer is the consumer message.
|
|
376
|
+
export type routercommonv1_Consumer = {
|
|
377
|
+
// The unique ID of the consumer.
|
|
378
|
+
id: string | undefined;
|
|
379
|
+
// The user ID of the consumer.
|
|
380
|
+
userId: string | undefined;
|
|
381
|
+
// The name of the consumer.
|
|
382
|
+
name: string | undefined;
|
|
383
|
+
// The API key of the consumer.
|
|
384
|
+
apiKey: string | undefined;
|
|
385
|
+
// Whether the consumer is enabled.
|
|
386
|
+
enabled: boolean | undefined;
|
|
387
|
+
// The latest timestamp at which the consumer accessed the system.
|
|
388
|
+
lastAccess: wellKnownTimestamp | undefined;
|
|
389
|
+
// The timestamp at which the consumer was created.
|
|
390
|
+
createdAt: wellKnownTimestamp | undefined;
|
|
391
|
+
// The latest timestamp at which the consumer was updated.
|
|
392
|
+
updatedAt: wellKnownTimestamp | undefined;
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
// UpdateConsumerRequest is the request message for UpdateConsumer.
|
|
396
|
+
export type UpdateConsumerRequest = {
|
|
397
|
+
// Required. The consumer to update.
|
|
398
|
+
//
|
|
399
|
+
// Behaviors: REQUIRED
|
|
400
|
+
consumer: routercommonv1_Consumer | undefined;
|
|
401
|
+
// Required. Mask of fields to update.
|
|
402
|
+
//
|
|
403
|
+
// Behaviors: REQUIRED
|
|
404
|
+
updateMask: wellKnownFieldMask | undefined;
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// In JSON, a field mask is encoded as a single string where paths are
|
|
408
|
+
// separated by a comma. Fields name in each path are converted
|
|
409
|
+
// to/from lower-camel naming conventions.
|
|
410
|
+
// As an example, consider the following message declarations:
|
|
411
|
+
//
|
|
412
|
+
// message Profile {
|
|
413
|
+
// User user = 1;
|
|
414
|
+
// Photo photo = 2;
|
|
415
|
+
// }
|
|
416
|
+
// message User {
|
|
417
|
+
// string display_name = 1;
|
|
418
|
+
// string address = 2;
|
|
419
|
+
// }
|
|
420
|
+
//
|
|
421
|
+
// In proto a field mask for `Profile` may look as such:
|
|
422
|
+
//
|
|
423
|
+
// mask {
|
|
424
|
+
// paths: "user.display_name"
|
|
425
|
+
// paths: "photo"
|
|
426
|
+
// }
|
|
427
|
+
//
|
|
428
|
+
// In JSON, the same mask is represented as below:
|
|
429
|
+
//
|
|
430
|
+
// {
|
|
431
|
+
// mask: "user.displayName,photo"
|
|
432
|
+
// }
|
|
433
|
+
type wellKnownFieldMask = string;
|
|
434
|
+
|
|
435
|
+
// DeleteConsumerRequest is the request message for DeleteConsumer.
|
|
436
|
+
export type DeleteConsumerRequest = {
|
|
437
|
+
// Required. The id of the consumer to delete.
|
|
438
|
+
//
|
|
439
|
+
// Behaviors: REQUIRED
|
|
440
|
+
id: string | undefined;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
// ConsumerService is the consumer service definition.
|
|
444
|
+
export interface ConsumerService {
|
|
445
|
+
// CreateConsumer creates a new consumer.
|
|
446
|
+
CreateConsumer(request: CreateConsumerRequest): Promise<routercommonv1_Consumer>;
|
|
447
|
+
// UpdateConsumer updates a consumer.
|
|
448
|
+
UpdateConsumer(request: UpdateConsumerRequest): Promise<routercommonv1_Consumer>;
|
|
449
|
+
// DeleteConsumer deletes a consumer by id.
|
|
450
|
+
DeleteConsumer(request: DeleteConsumerRequest): Promise<wellKnownEmpty>;
|
|
451
|
+
// ListConsumers lists consumers by user.
|
|
452
|
+
ListConsumers(request: ListConsumersRequest): Promise<ListConsumersResponse>;
|
|
453
|
+
// GetConsumer retrieves a consumer by id.
|
|
454
|
+
GetConsumer(request: GetConsumerRequest): Promise<routercommonv1_Consumer>;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export function createConsumerServiceClient(
|
|
458
|
+
handler: RequestHandler
|
|
459
|
+
): ConsumerService {
|
|
460
|
+
return {
|
|
461
|
+
CreateConsumer(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
462
|
+
const path = `v1/dashboard/consumers/create`; // eslint-disable-line quotes
|
|
463
|
+
const body = JSON.stringify(request);
|
|
464
|
+
const queryParams: string[] = [];
|
|
465
|
+
let uri = path;
|
|
466
|
+
if (queryParams.length > 0) {
|
|
467
|
+
uri += `?${queryParams.join("&")}`
|
|
468
|
+
}
|
|
469
|
+
return handler({
|
|
470
|
+
path: uri,
|
|
471
|
+
method: "POST",
|
|
472
|
+
body,
|
|
473
|
+
}, {
|
|
474
|
+
service: "ConsumerService",
|
|
475
|
+
method: "CreateConsumer",
|
|
476
|
+
}) as Promise<routercommonv1_Consumer>;
|
|
477
|
+
},
|
|
478
|
+
UpdateConsumer(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
479
|
+
const path = `v1/dashboard/consumers/update`; // eslint-disable-line quotes
|
|
480
|
+
const body = JSON.stringify(request?.consumer ?? {});
|
|
481
|
+
const queryParams: string[] = [];
|
|
482
|
+
if (request.updateMask) {
|
|
483
|
+
queryParams.push(`updateMask=${encodeURIComponent(request.updateMask.toString())}`)
|
|
484
|
+
}
|
|
485
|
+
let uri = path;
|
|
486
|
+
if (queryParams.length > 0) {
|
|
487
|
+
uri += `?${queryParams.join("&")}`
|
|
488
|
+
}
|
|
489
|
+
return handler({
|
|
490
|
+
path: uri,
|
|
491
|
+
method: "PUT",
|
|
492
|
+
body,
|
|
493
|
+
}, {
|
|
494
|
+
service: "ConsumerService",
|
|
495
|
+
method: "UpdateConsumer",
|
|
496
|
+
}) as Promise<routercommonv1_Consumer>;
|
|
497
|
+
},
|
|
498
|
+
DeleteConsumer(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
499
|
+
if (!request.id) {
|
|
500
|
+
throw new Error("missing required field request.id");
|
|
501
|
+
}
|
|
502
|
+
const path = `v1/dashboard/consumers/${request.id}`; // eslint-disable-line quotes
|
|
503
|
+
const body = null;
|
|
504
|
+
const queryParams: string[] = [];
|
|
505
|
+
let uri = path;
|
|
506
|
+
if (queryParams.length > 0) {
|
|
507
|
+
uri += `?${queryParams.join("&")}`
|
|
508
|
+
}
|
|
509
|
+
return handler({
|
|
510
|
+
path: uri,
|
|
511
|
+
method: "DELETE",
|
|
512
|
+
body,
|
|
513
|
+
}, {
|
|
514
|
+
service: "ConsumerService",
|
|
515
|
+
method: "DeleteConsumer",
|
|
516
|
+
}) as Promise<wellKnownEmpty>;
|
|
517
|
+
},
|
|
518
|
+
ListConsumers(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
519
|
+
const path = `v1/dashboard/consumers`; // eslint-disable-line quotes
|
|
520
|
+
const body = null;
|
|
521
|
+
const queryParams: string[] = [];
|
|
522
|
+
if (request.pageSize) {
|
|
523
|
+
queryParams.push(`pageSize=${encodeURIComponent(request.pageSize.toString())}`)
|
|
524
|
+
}
|
|
525
|
+
if (request.pageToken) {
|
|
526
|
+
queryParams.push(`pageToken=${encodeURIComponent(request.pageToken.toString())}`)
|
|
527
|
+
}
|
|
528
|
+
let uri = path;
|
|
529
|
+
if (queryParams.length > 0) {
|
|
530
|
+
uri += `?${queryParams.join("&")}`
|
|
531
|
+
}
|
|
532
|
+
return handler({
|
|
533
|
+
path: uri,
|
|
534
|
+
method: "GET",
|
|
535
|
+
body,
|
|
536
|
+
}, {
|
|
537
|
+
service: "ConsumerService",
|
|
538
|
+
method: "ListConsumers",
|
|
539
|
+
}) as Promise<ListConsumersResponse>;
|
|
540
|
+
},
|
|
541
|
+
GetConsumer(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
542
|
+
if (!request.id) {
|
|
543
|
+
throw new Error("missing required field request.id");
|
|
544
|
+
}
|
|
545
|
+
const path = `v1/dashboard/consumers/${request.id}`; // eslint-disable-line quotes
|
|
546
|
+
const body = null;
|
|
547
|
+
const queryParams: string[] = [];
|
|
548
|
+
let uri = path;
|
|
549
|
+
if (queryParams.length > 0) {
|
|
550
|
+
uri += `?${queryParams.join("&")}`
|
|
551
|
+
}
|
|
552
|
+
return handler({
|
|
553
|
+
path: uri,
|
|
554
|
+
method: "GET",
|
|
555
|
+
body,
|
|
556
|
+
}, {
|
|
557
|
+
service: "ConsumerService",
|
|
558
|
+
method: "GetConsumer",
|
|
559
|
+
}) as Promise<routercommonv1_Consumer>;
|
|
560
|
+
},
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
// ActivatePromotionRequest is the request message for ActivatePromotion.
|
|
564
|
+
export type ActivatePromotionRequest = {
|
|
565
|
+
// The promotion code to activate.
|
|
566
|
+
//
|
|
567
|
+
// Behaviors: REQUIRED
|
|
568
|
+
code: string | undefined;
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
// PromotionService is the subscription service definition.
|
|
572
|
+
export interface PromotionService {
|
|
573
|
+
ActivatePromotion(request: ActivatePromotionRequest): Promise<routercommonv1_Promotion>;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export function createPromotionServiceClient(
|
|
577
|
+
handler: RequestHandler
|
|
578
|
+
): PromotionService {
|
|
579
|
+
return {
|
|
580
|
+
ActivatePromotion(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
581
|
+
const path = `v1/promotion/activate`; // eslint-disable-line quotes
|
|
582
|
+
const body = JSON.stringify(request);
|
|
583
|
+
const queryParams: string[] = [];
|
|
584
|
+
let uri = path;
|
|
585
|
+
if (queryParams.length > 0) {
|
|
586
|
+
uri += `?${queryParams.join("&")}`
|
|
587
|
+
}
|
|
588
|
+
return handler({
|
|
589
|
+
path: uri,
|
|
590
|
+
method: "POST",
|
|
591
|
+
body,
|
|
592
|
+
}, {
|
|
593
|
+
service: "PromotionService",
|
|
594
|
+
method: "ActivatePromotion",
|
|
595
|
+
}) as Promise<routercommonv1_Promotion>;
|
|
596
|
+
},
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
// Promotion represents a promotional offer with its details.
|
|
600
|
+
export type routercommonv1_Promotion = {
|
|
601
|
+
// Unique identifier for the promotion.
|
|
602
|
+
id: string | undefined;
|
|
603
|
+
// Human-entered promotion code.
|
|
604
|
+
code: string | undefined;
|
|
605
|
+
// Associated plan id for the promotion.
|
|
606
|
+
planId: string | undefined;
|
|
607
|
+
// Associated user id (recipient/owner).
|
|
608
|
+
userId: string | undefined;
|
|
609
|
+
// Current status of the promotion.
|
|
610
|
+
status: routercommonv1_Promotion_Status | undefined;
|
|
611
|
+
// Timestamp when the promotion was redeemed.
|
|
612
|
+
redeemedAt: wellKnownTimestamp | undefined;
|
|
613
|
+
// Timestamps for creation and last update.
|
|
614
|
+
createdAt: wellKnownTimestamp | undefined;
|
|
615
|
+
// Timestamp for the last update.
|
|
616
|
+
updatedAt: wellKnownTimestamp | undefined;
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
export type routercommonv1_Promotion_Status =
|
|
620
|
+
| "STATUS_UNSPECIFIED"
|
|
621
|
+
// Promotion is available and not redeemed yet.
|
|
622
|
+
| "AVAILABLE"
|
|
623
|
+
// Promotion has been redeemed/used.
|
|
624
|
+
| "REDEEMED"
|
|
625
|
+
// Promotion has expired.
|
|
626
|
+
| "EXPIRED"
|
|
627
|
+
// Promotion has been revoked.
|
|
628
|
+
| "REVOKED";
|
|
629
|
+
// AuthToken is the authentication token message.
|
|
630
|
+
export type AuthToken = {
|
|
631
|
+
// Required. The access token.
|
|
632
|
+
accessToken: string | undefined;
|
|
633
|
+
// Required. The refresh token.
|
|
634
|
+
refreshToken: string | undefined;
|
|
635
|
+
// Required. The token type.
|
|
636
|
+
expiresAt: wellKnownTimestamp | undefined;
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
// AuthorizeRequest is the request message for AuthToken.
|
|
640
|
+
export type AuthorizeRequest = {
|
|
641
|
+
// Required. The OAuth code to exchange for tokens.
|
|
642
|
+
//
|
|
643
|
+
// Behaviors: REQUIRED
|
|
644
|
+
code: string | undefined;
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
// CreateAuthRequest is the request message for CreateAuth.
|
|
648
|
+
export type CreateAuthRequest = {
|
|
649
|
+
// Required. The OAuth code to exchange for tokens.
|
|
650
|
+
//
|
|
651
|
+
// Behaviors: REQUIRED
|
|
652
|
+
code: string | undefined;
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
// RefreshTokenRequest is the request message for RefreshToken.
|
|
656
|
+
export type RefreshTokenRequest = {
|
|
657
|
+
// Required. The refresh token.
|
|
658
|
+
//
|
|
659
|
+
// Behaviors: REQUIRED
|
|
660
|
+
refreshToken: string | undefined;
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
// AuthService is the authentication service definition.
|
|
664
|
+
export interface AuthService {
|
|
665
|
+
// Authorize exchanges an OAuth code for access and refresh tokens.
|
|
666
|
+
Authorize(request: AuthorizeRequest): Promise<AuthToken>;
|
|
667
|
+
// CreateAuth exchanges an OAuth code for access and refresh tokens.
|
|
668
|
+
CreateAuth(request: CreateAuthRequest): Promise<wellKnownEmpty>;
|
|
669
|
+
// RefreshToken refreshes the access token using a refresh token.
|
|
670
|
+
RefreshToken(request: RefreshTokenRequest): Promise<AuthToken>;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
export function createAuthServiceClient(
|
|
674
|
+
handler: RequestHandler
|
|
675
|
+
): AuthService {
|
|
676
|
+
return {
|
|
677
|
+
Authorize(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
678
|
+
const path = `v1/dashboard/auth/authorize`; // eslint-disable-line quotes
|
|
679
|
+
const body = JSON.stringify(request);
|
|
680
|
+
const queryParams: string[] = [];
|
|
681
|
+
let uri = path;
|
|
682
|
+
if (queryParams.length > 0) {
|
|
683
|
+
uri += `?${queryParams.join("&")}`
|
|
684
|
+
}
|
|
685
|
+
return handler({
|
|
686
|
+
path: uri,
|
|
687
|
+
method: "POST",
|
|
688
|
+
body,
|
|
689
|
+
}, {
|
|
690
|
+
service: "AuthService",
|
|
691
|
+
method: "Authorize",
|
|
692
|
+
}) as Promise<AuthToken>;
|
|
693
|
+
},
|
|
694
|
+
CreateAuth(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
695
|
+
const path = `v1/dashboard/auth/create`; // eslint-disable-line quotes
|
|
696
|
+
const body = JSON.stringify(request);
|
|
697
|
+
const queryParams: string[] = [];
|
|
698
|
+
let uri = path;
|
|
699
|
+
if (queryParams.length > 0) {
|
|
700
|
+
uri += `?${queryParams.join("&")}`
|
|
701
|
+
}
|
|
702
|
+
return handler({
|
|
703
|
+
path: uri,
|
|
704
|
+
method: "POST",
|
|
705
|
+
body,
|
|
706
|
+
}, {
|
|
707
|
+
service: "AuthService",
|
|
708
|
+
method: "CreateAuth",
|
|
709
|
+
}) as Promise<wellKnownEmpty>;
|
|
710
|
+
},
|
|
711
|
+
RefreshToken(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
712
|
+
const path = `v1/dashboard/auth/token`; // eslint-disable-line quotes
|
|
713
|
+
const body = JSON.stringify(request);
|
|
714
|
+
const queryParams: string[] = [];
|
|
715
|
+
let uri = path;
|
|
716
|
+
if (queryParams.length > 0) {
|
|
717
|
+
uri += `?${queryParams.join("&")}`
|
|
718
|
+
}
|
|
719
|
+
return handler({
|
|
720
|
+
path: uri,
|
|
721
|
+
method: "POST",
|
|
722
|
+
body,
|
|
723
|
+
}, {
|
|
724
|
+
service: "AuthService",
|
|
725
|
+
method: "RefreshToken",
|
|
726
|
+
}) as Promise<AuthToken>;
|
|
727
|
+
},
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
// ListModelsResponse is the response message for ListModels.
|
|
731
|
+
export type ListModelsRequest = {
|
|
732
|
+
// The maximum number of models to return. The service may return fewer than
|
|
733
|
+
// this value, even if more models exist.
|
|
734
|
+
pageSize: number | undefined;
|
|
735
|
+
// A page token, received from a previous `ListModels` call.
|
|
736
|
+
// Provide this to retrieve the subsequent page.
|
|
737
|
+
// When paginating, all other parameters provided to `ListModels` must
|
|
738
|
+
// match the call that provided the page token.
|
|
739
|
+
pageToken: string | undefined;
|
|
740
|
+
// Optional. The standard list filter.
|
|
741
|
+
// Supported fields:
|
|
742
|
+
// * `name` (i.e. `name="gpt-5"`)
|
|
743
|
+
// * `author` (i.e. `author="openai"`)
|
|
744
|
+
// More detail in [AIP-160](https://google.aip.dev/160).
|
|
745
|
+
filter: string | undefined;
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
// ListModelsResponse is the response message for ListModels.
|
|
749
|
+
export type ListModelsResponse = {
|
|
750
|
+
// The list of models.
|
|
751
|
+
models: routercommonv1_Model[] | undefined;
|
|
752
|
+
// A token to retrieve the next page of results.
|
|
753
|
+
// Pass this value in the `page_token` field of a subsequent `ListModels`
|
|
754
|
+
// request to retrieve the next page of results.
|
|
755
|
+
// If this field is omitted, there are no subsequent pages.
|
|
756
|
+
nextPageToken: string | undefined;
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
// Model represents a machine learning model with its metadata.
|
|
760
|
+
export type routercommonv1_Model = {
|
|
761
|
+
// Unique identifier for the model. (e.g., gpt-5.2-2025-12-11)
|
|
762
|
+
id: string | undefined;
|
|
763
|
+
// Name of the model. (e.g., GPT-5.2)
|
|
764
|
+
name: string | undefined;
|
|
765
|
+
// Icon representing the model.
|
|
766
|
+
icon: string | undefined;
|
|
767
|
+
// Author of the model.
|
|
768
|
+
author: string | undefined;
|
|
769
|
+
// Website associated with the model.
|
|
770
|
+
website: string | undefined;
|
|
771
|
+
// Description of the model.
|
|
772
|
+
description: string | undefined;
|
|
773
|
+
// Indicates if the model is enabled.
|
|
774
|
+
enabled: boolean | undefined;
|
|
775
|
+
// Timestamps for model creation and last update.
|
|
776
|
+
createdAt: wellKnownTimestamp | undefined;
|
|
777
|
+
// Timestamp for the last update of the model.
|
|
778
|
+
updatedAt: wellKnownTimestamp | undefined;
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
export interface ModelService {
|
|
782
|
+
ListModels(request: ListModelsRequest): Promise<ListModelsResponse>;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
export function createModelServiceClient(
|
|
786
|
+
handler: RequestHandler
|
|
787
|
+
): ModelService {
|
|
788
|
+
return {
|
|
789
|
+
ListModels(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
790
|
+
const path = `v1/dashboard/models`; // eslint-disable-line quotes
|
|
791
|
+
const body = null;
|
|
792
|
+
const queryParams: string[] = [];
|
|
793
|
+
if (request.pageSize) {
|
|
794
|
+
queryParams.push(`pageSize=${encodeURIComponent(request.pageSize.toString())}`)
|
|
795
|
+
}
|
|
796
|
+
if (request.pageToken) {
|
|
797
|
+
queryParams.push(`pageToken=${encodeURIComponent(request.pageToken.toString())}`)
|
|
798
|
+
}
|
|
799
|
+
if (request.filter) {
|
|
800
|
+
queryParams.push(`filter=${encodeURIComponent(request.filter.toString())}`)
|
|
801
|
+
}
|
|
802
|
+
let uri = path;
|
|
803
|
+
if (queryParams.length > 0) {
|
|
804
|
+
uri += `?${queryParams.join("&")}`
|
|
805
|
+
}
|
|
806
|
+
return handler({
|
|
807
|
+
path: uri,
|
|
808
|
+
method: "GET",
|
|
809
|
+
body,
|
|
810
|
+
}, {
|
|
811
|
+
service: "ModelService",
|
|
812
|
+
method: "ListModels",
|
|
813
|
+
}) as Promise<ListModelsResponse>;
|
|
814
|
+
},
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
export type ListProvidersRequest = {
|
|
818
|
+
// The maximum number of providers to return. The service may return fewer than
|
|
819
|
+
// this value, even if more providers exist.
|
|
820
|
+
pageSize: number | undefined;
|
|
821
|
+
// A page token, received from a previous `ListProviders` call.
|
|
822
|
+
// Provide this to retrieve the subsequent page.
|
|
823
|
+
// When paginating, all other parameters provided to `ListProviders` must
|
|
824
|
+
// match the call that provided the page token.
|
|
825
|
+
pageToken: string | undefined;
|
|
826
|
+
// Optional. The standard list filter.
|
|
827
|
+
// Supported fields:
|
|
828
|
+
// * `name` (i.e. `name="openai"`)
|
|
829
|
+
// More detail in [AIP-160](https://google.aip.dev/160).
|
|
830
|
+
filter: string | undefined;
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
// ListProvidersResponse is the response message for ListProviders.
|
|
834
|
+
export type ListProvidersResponse = {
|
|
835
|
+
// The list of providers.
|
|
836
|
+
providers: routercommonv1_Provider[] | undefined;
|
|
837
|
+
// A token to retrieve the next page of results.
|
|
838
|
+
nextPageToken: string | undefined;
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
// Provider represents a service provider in the system.
|
|
842
|
+
export type routercommonv1_Provider = {
|
|
843
|
+
// The unique ID of the provider.
|
|
844
|
+
id: string | undefined;
|
|
845
|
+
// The name of the provider.
|
|
846
|
+
name: string | undefined;
|
|
847
|
+
// The description of the provider.
|
|
848
|
+
description: string | undefined;
|
|
849
|
+
// The model name of the provider.
|
|
850
|
+
modelId: string | undefined;
|
|
851
|
+
// The upstream model of the provider.
|
|
852
|
+
upstreamModel: string | undefined;
|
|
853
|
+
// The base URL for the provider.
|
|
854
|
+
baseUrl: string | undefined;
|
|
855
|
+
// The API key for the provider.
|
|
856
|
+
apiKey: string | undefined;
|
|
857
|
+
// The context window size for the provider.
|
|
858
|
+
contextWindow: number | undefined;
|
|
859
|
+
// The maximum number of tokens for the provider.
|
|
860
|
+
maxTokens: number | undefined;
|
|
861
|
+
// Whether the provider is enabled.
|
|
862
|
+
enabled: boolean | undefined;
|
|
863
|
+
// The timeout duration for requests to the provider.
|
|
864
|
+
timeout: wellKnownDuration | undefined;
|
|
865
|
+
// The timestamp at which the provider was created.
|
|
866
|
+
createdAt: wellKnownTimestamp | undefined;
|
|
867
|
+
// The latest timestamp at which the provider was updated.
|
|
868
|
+
updatedAt: wellKnownTimestamp | undefined;
|
|
869
|
+
// The model type of the provider.
|
|
870
|
+
model: routercommonv1_Model | undefined;
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
// Generated output always contains 0, 3, 6, or 9 fractional digits,
|
|
874
|
+
// depending on required precision, followed by the suffix "s".
|
|
875
|
+
// Accepted are any fractional digits (also none) as long as they fit
|
|
876
|
+
// into nano-seconds precision and the suffix "s" is required.
|
|
877
|
+
type wellKnownDuration = string;
|
|
878
|
+
|
|
879
|
+
// ListProvidersRequest is the request message for ListProviders.
|
|
880
|
+
export interface ProviderService {
|
|
881
|
+
// ListProviders lists all available providers.
|
|
882
|
+
ListProviders(request: ListProvidersRequest): Promise<ListProvidersResponse>;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
export function createProviderServiceClient(
|
|
886
|
+
handler: RequestHandler
|
|
887
|
+
): ProviderService {
|
|
888
|
+
return {
|
|
889
|
+
ListProviders(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
890
|
+
const path = `v1/dashboard/providers`; // eslint-disable-line quotes
|
|
891
|
+
const body = null;
|
|
892
|
+
const queryParams: string[] = [];
|
|
893
|
+
if (request.pageSize) {
|
|
894
|
+
queryParams.push(`pageSize=${encodeURIComponent(request.pageSize.toString())}`)
|
|
895
|
+
}
|
|
896
|
+
if (request.pageToken) {
|
|
897
|
+
queryParams.push(`pageToken=${encodeURIComponent(request.pageToken.toString())}`)
|
|
898
|
+
}
|
|
899
|
+
if (request.filter) {
|
|
900
|
+
queryParams.push(`filter=${encodeURIComponent(request.filter.toString())}`)
|
|
901
|
+
}
|
|
902
|
+
let uri = path;
|
|
903
|
+
if (queryParams.length > 0) {
|
|
904
|
+
uri += `?${queryParams.join("&")}`
|
|
905
|
+
}
|
|
906
|
+
return handler({
|
|
907
|
+
path: uri,
|
|
908
|
+
method: "GET",
|
|
909
|
+
body,
|
|
910
|
+
}, {
|
|
911
|
+
service: "ProviderService",
|
|
912
|
+
method: "ListProviders",
|
|
913
|
+
}) as Promise<ListProvidersResponse>;
|
|
914
|
+
},
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
// ListPlansRequest is the request message for ListPlans.
|
|
918
|
+
export type ListPlansRequest = {
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
// ListPlansResponse is the response message for ListPlans.
|
|
922
|
+
export type ListPlansResponse = {
|
|
923
|
+
// The list of plans.
|
|
924
|
+
plans: routercommonv1_Plan[] | undefined;
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
// PlanService defines the service for managing plans.
|
|
928
|
+
export interface PlanService {
|
|
929
|
+
// ListPlans lists all available plans.
|
|
930
|
+
ListPlans(request: ListPlansRequest): Promise<ListPlansResponse>;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
export function createPlanServiceClient(
|
|
934
|
+
handler: RequestHandler
|
|
935
|
+
): PlanService {
|
|
936
|
+
return {
|
|
937
|
+
ListPlans(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
938
|
+
const path = `v1/dashboard/plans`; // eslint-disable-line quotes
|
|
939
|
+
const body = null;
|
|
940
|
+
const queryParams: string[] = [];
|
|
941
|
+
let uri = path;
|
|
942
|
+
if (queryParams.length > 0) {
|
|
943
|
+
uri += `?${queryParams.join("&")}`
|
|
944
|
+
}
|
|
945
|
+
return handler({
|
|
946
|
+
path: uri,
|
|
947
|
+
method: "GET",
|
|
948
|
+
body,
|
|
949
|
+
}, {
|
|
950
|
+
service: "PlanService",
|
|
951
|
+
method: "ListPlans",
|
|
952
|
+
}) as Promise<ListPlansResponse>;
|
|
953
|
+
},
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
// UpdateUserRequest is the request message for the UpdateUser method.
|
|
957
|
+
export type UpdateUserRequest = {
|
|
958
|
+
// Required. The user to update.
|
|
959
|
+
//
|
|
960
|
+
// Behaviors: REQUIRED
|
|
961
|
+
user: routercommonv1_User | undefined;
|
|
962
|
+
// Required. Mask of fields to update.
|
|
963
|
+
//
|
|
964
|
+
// Behaviors: REQUIRED
|
|
965
|
+
updateMask: wellKnownFieldMask | undefined;
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
// UserService is the user service definition.
|
|
969
|
+
export interface UserService {
|
|
970
|
+
// Current returns the currently authenticated user.
|
|
971
|
+
CurrentUser(request: wellKnownEmpty): Promise<routercommonv1_User>;
|
|
972
|
+
// UpdateUser updates an existing user.
|
|
973
|
+
UpdateUser(request: UpdateUserRequest): Promise<routercommonv1_User>;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
export function createUserServiceClient(
|
|
977
|
+
handler: RequestHandler
|
|
978
|
+
): UserService {
|
|
979
|
+
return {
|
|
980
|
+
CurrentUser(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
981
|
+
const path = `v1/dashboard/users/current`; // eslint-disable-line quotes
|
|
982
|
+
const body = null;
|
|
983
|
+
const queryParams: string[] = [];
|
|
984
|
+
let uri = path;
|
|
985
|
+
if (queryParams.length > 0) {
|
|
986
|
+
uri += `?${queryParams.join("&")}`
|
|
987
|
+
}
|
|
988
|
+
return handler({
|
|
989
|
+
path: uri,
|
|
990
|
+
method: "GET",
|
|
991
|
+
body,
|
|
992
|
+
}, {
|
|
993
|
+
service: "UserService",
|
|
994
|
+
method: "CurrentUser",
|
|
995
|
+
}) as Promise<routercommonv1_User>;
|
|
996
|
+
},
|
|
997
|
+
UpdateUser(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
998
|
+
const path = `v1/dashboard/users/update`; // eslint-disable-line quotes
|
|
999
|
+
const body = JSON.stringify(request?.user ?? {});
|
|
1000
|
+
const queryParams: string[] = [];
|
|
1001
|
+
if (request.updateMask) {
|
|
1002
|
+
queryParams.push(`updateMask=${encodeURIComponent(request.updateMask.toString())}`)
|
|
1003
|
+
}
|
|
1004
|
+
let uri = path;
|
|
1005
|
+
if (queryParams.length > 0) {
|
|
1006
|
+
uri += `?${queryParams.join("&")}`
|
|
1007
|
+
}
|
|
1008
|
+
return handler({
|
|
1009
|
+
path: uri,
|
|
1010
|
+
method: "PUT",
|
|
1011
|
+
body,
|
|
1012
|
+
}, {
|
|
1013
|
+
service: "UserService",
|
|
1014
|
+
method: "UpdateUser",
|
|
1015
|
+
}) as Promise<routercommonv1_User>;
|
|
1016
|
+
},
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
// ListUsagesRequest is the request message for ListUsages.
|
|
1021
|
+
export type ListUsagesRequest = {
|
|
1022
|
+
// The maximum number of usages to return. The service may return fewer than
|
|
1023
|
+
// this value, even if more usages exist.
|
|
1024
|
+
pageSize: number | undefined;
|
|
1025
|
+
// A page token, received from a previous `ListUsages` call.
|
|
1026
|
+
// Provide this to retrieve the subsequent page.
|
|
1027
|
+
// When paginating, all other parameters provided to `ListUsages` must
|
|
1028
|
+
// match the call that provided the page token.
|
|
1029
|
+
pageToken: string | undefined;
|
|
1030
|
+
};
|
|
1031
|
+
|
|
1032
|
+
// ListUsagesResponse is the response message for ListUsages.
|
|
1033
|
+
export type ListUsagesResponse = {
|
|
1034
|
+
// The list of usages.
|
|
1035
|
+
usages: routercommonv1_Usage[] | undefined;
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
// Usage represents token usage statistics for a model.
|
|
1039
|
+
export type routercommonv1_Usage = {
|
|
1040
|
+
// Unique identifier for the usage record.
|
|
1041
|
+
id: string | undefined;
|
|
1042
|
+
// Identifier of the user associated with this usage.
|
|
1043
|
+
userId: string | undefined;
|
|
1044
|
+
// Identifier of the model associated with this usage.
|
|
1045
|
+
modelId: string | undefined;
|
|
1046
|
+
// Unique identifier for the consumer.
|
|
1047
|
+
consumerId: string | undefined;
|
|
1048
|
+
// Identifier of the provider.
|
|
1049
|
+
providerId: string | undefined;
|
|
1050
|
+
// Unique identifier for the request associated with this usage.
|
|
1051
|
+
requestId: string | undefined;
|
|
1052
|
+
// Detailed usage information in JSON format.
|
|
1053
|
+
// e.g. {"input_tokens":11,"input_tokens_details":{"cached_tokens":0},"output_tokens":149,"output_tokens_details":{"reasoning_tokens":128},"total_tokens":160}
|
|
1054
|
+
tokensDetails: string | undefined;
|
|
1055
|
+
// Number of input tokens used.
|
|
1056
|
+
inputTokens: number | undefined;
|
|
1057
|
+
// Number of output tokens generated.
|
|
1058
|
+
outputTokens: number | undefined;
|
|
1059
|
+
// Total number of tokens used.
|
|
1060
|
+
totalTokens: number | undefined;
|
|
1061
|
+
// Timestamps for usage record creation and last update.
|
|
1062
|
+
createdAt: wellKnownTimestamp | undefined;
|
|
1063
|
+
// Timestamp for the last update of the usage record.
|
|
1064
|
+
updatedAt: wellKnownTimestamp | undefined;
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
// UsageService defines the usage-related RPCs.
|
|
1068
|
+
export interface UsageService {
|
|
1069
|
+
// ListUsages lists the usage statistics.
|
|
1070
|
+
// Implement aggregation queries grouped by day.
|
|
1071
|
+
ListUsage(request: ListUsagesRequest): Promise<ListUsagesResponse>;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
export function createUsageServiceClient(
|
|
1075
|
+
handler: RequestHandler
|
|
1076
|
+
): UsageService {
|
|
1077
|
+
return {
|
|
1078
|
+
ListUsage(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
1079
|
+
const path = `v1/dashboard/usages`; // eslint-disable-line quotes
|
|
1080
|
+
const body = null;
|
|
1081
|
+
const queryParams: string[] = [];
|
|
1082
|
+
if (request.pageSize) {
|
|
1083
|
+
queryParams.push(`pageSize=${encodeURIComponent(request.pageSize.toString())}`)
|
|
1084
|
+
}
|
|
1085
|
+
if (request.pageToken) {
|
|
1086
|
+
queryParams.push(`pageToken=${encodeURIComponent(request.pageToken.toString())}`)
|
|
1087
|
+
}
|
|
1088
|
+
let uri = path;
|
|
1089
|
+
if (queryParams.length > 0) {
|
|
1090
|
+
uri += `?${queryParams.join("&")}`
|
|
1091
|
+
}
|
|
1092
|
+
return handler({
|
|
1093
|
+
path: uri,
|
|
1094
|
+
method: "GET",
|
|
1095
|
+
body,
|
|
1096
|
+
}, {
|
|
1097
|
+
service: "UsageService",
|
|
1098
|
+
method: "ListUsage",
|
|
1099
|
+
}) as Promise<ListUsagesResponse>;
|
|
1100
|
+
},
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
// @@protoc_insertion_point(typescript-http-eof)
|