@camunda/ccma-api 1.0.1 → 1.2.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/dist/index.d.ts +6 -4
- package/dist/index.js +6 -0
- package/dist/index.js.map +2 -2
- package/dist/services/accounts/hdp.service.d.ts +15 -0
- package/dist/services/accounts/hdp.service.js +42 -0
- package/dist/services/accounts/hdp.service.js.map +2 -2
- package/dist/services/accounts/orgs.service.d.ts +8 -1
- package/dist/services/accounts/orgs.service.js.map +2 -2
- package/dist/services/accounts/orgs.v2.service.js +23 -7
- package/dist/services/accounts/orgs.v2.service.js.map +2 -2
- package/dist/services/accounts/orgs.v2.service.spec.d.ts +1 -0
- package/dist/services/console/console.admin.service.d.ts +31 -0
- package/dist/services/console/console.admin.service.js +42 -0
- package/dist/services/console/console.admin.service.js.map +2 -2
- package/dist/services/console/console.cluster.service.d.ts +46 -0
- package/dist/services/console/console.cluster.service.js +32 -0
- package/dist/services/console/console.cluster.service.js.map +2 -2
- package/dist/services/console/console.cluster.v2.service.d.ts +11 -3
- package/dist/services/console/console.cluster.v2.service.js +57 -8
- package/dist/services/console/console.cluster.v2.service.js.map +2 -2
- package/dist/services/console/console.cluster.v2.service.spec.d.ts +1 -0
- package/dist/services/external/external.accounts.service.d.ts +21 -1
- package/dist/services/external/external.accounts.service.js +41 -0
- package/dist/services/external/external.accounts.service.js.map +2 -2
- package/dist/services/openrouter/openrouter.service.d.ts +200 -0
- package/dist/services/openrouter/openrouter.service.js +227 -0
- package/dist/services/openrouter/openrouter.service.js.map +7 -0
- package/dist/services/openrouter/openrouter.service.spec.d.ts +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { RequestBaseParams } from '../../types/general.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Fields that every key management route of OpenRouter returns for a key.
|
|
4
|
+
*
|
|
5
|
+
* OpenRouter addresses a key by its `hash`, never by the key itself. The key
|
|
6
|
+
* comes back exactly once, from the create route. Thus the caller must persist
|
|
7
|
+
* the hash together with the key. Without the hash, the key cannot be read,
|
|
8
|
+
* disabled or deleted.
|
|
9
|
+
*
|
|
10
|
+
* `usage` and `limit` hold USD credits. They are the OpenRouter names for the
|
|
11
|
+
* `spend` and `max_budget` of LiteLLM.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Number of keys that `GET /keys` gives back in one page.
|
|
15
|
+
*
|
|
16
|
+
* A caller that scans for a key must step `offset` by this number. The
|
|
17
|
+
* integration writes one key per org, so a real account holds more keys than
|
|
18
|
+
* one page.
|
|
19
|
+
*/
|
|
20
|
+
export declare const OPENROUTER_KEY_PAGE_SIZE = 100;
|
|
21
|
+
export interface OpenRouterKeyData {
|
|
22
|
+
/** Identifier of the key for every management route. */
|
|
23
|
+
hash: string;
|
|
24
|
+
/** Name of the key. This service writes `org-<orgId>` into it. */
|
|
25
|
+
name?: string;
|
|
26
|
+
/** Label of the key, which OpenRouter derives from the name. */
|
|
27
|
+
label?: string;
|
|
28
|
+
/** Credit limit in USD. `null` means no limit. */
|
|
29
|
+
limit?: number | null;
|
|
30
|
+
/** Credits spent in USD. */
|
|
31
|
+
usage?: number;
|
|
32
|
+
/** True when the key is disabled and rejects inference requests. */
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
created_at?: string;
|
|
35
|
+
updated_at?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Fields that OpenRouter sends and this service does not model, such as
|
|
38
|
+
* `limit_remaining` and the `usage_daily` family. `unknown` keeps them
|
|
39
|
+
* readable and makes a caller narrow the type first.
|
|
40
|
+
*/
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Common options of every key management request.
|
|
45
|
+
*
|
|
46
|
+
* The token is a Provisioning API key. An inference key cannot read or write
|
|
47
|
+
* other keys.
|
|
48
|
+
*/
|
|
49
|
+
interface OpenRouterRequestOptions {
|
|
50
|
+
/** Base URL of the OpenRouter API, including the `/api/v1` prefix. */
|
|
51
|
+
openRouterApiBaseUrl: string;
|
|
52
|
+
/** Provisioning API key for authentication. */
|
|
53
|
+
apiToken: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Request to create a key
|
|
57
|
+
* POST /keys
|
|
58
|
+
*/
|
|
59
|
+
export interface CreateOpenRouterKeyRequest extends RequestBaseParams {
|
|
60
|
+
options: OpenRouterRequestOptions & {
|
|
61
|
+
/** Name of the key. Used to find the key again if the hash is lost. */
|
|
62
|
+
name: string;
|
|
63
|
+
/** Credit limit in USD. */
|
|
64
|
+
limit?: number;
|
|
65
|
+
/** When false, credits of a customer-owned provider key do not count. */
|
|
66
|
+
include_byok_in_limit?: boolean;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Response from creating a key.
|
|
71
|
+
*
|
|
72
|
+
* `key` holds the inference credential and OpenRouter returns it only here.
|
|
73
|
+
* `data.hash` is the handle for every later request about this key.
|
|
74
|
+
*/
|
|
75
|
+
export interface CreateOpenRouterKeyResponse {
|
|
76
|
+
key: string;
|
|
77
|
+
data: OpenRouterKeyData;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Request to read one key
|
|
81
|
+
* GET /keys/{hash}
|
|
82
|
+
*/
|
|
83
|
+
export interface GetOpenRouterKeyRequest extends RequestBaseParams {
|
|
84
|
+
options: OpenRouterRequestOptions & {
|
|
85
|
+
/** Hash of the key to read. */
|
|
86
|
+
hash: string;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Response from reading one key
|
|
91
|
+
*/
|
|
92
|
+
export interface GetOpenRouterKeyResponse {
|
|
93
|
+
data: OpenRouterKeyData;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Request to update a key
|
|
97
|
+
* PATCH /keys/{hash}
|
|
98
|
+
*/
|
|
99
|
+
export interface UpdateOpenRouterKeyRequest extends RequestBaseParams {
|
|
100
|
+
options: OpenRouterRequestOptions & {
|
|
101
|
+
/** Hash of the key to update. */
|
|
102
|
+
hash: string;
|
|
103
|
+
/** New name of the key. */
|
|
104
|
+
name?: string;
|
|
105
|
+
/** True disables the key. False enables it again. */
|
|
106
|
+
disabled?: boolean;
|
|
107
|
+
/** New credit limit in USD. */
|
|
108
|
+
limit?: number;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Response from updating a key
|
|
113
|
+
*/
|
|
114
|
+
export interface UpdateOpenRouterKeyResponse {
|
|
115
|
+
data: OpenRouterKeyData;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Request to delete a key
|
|
119
|
+
* DELETE /keys/{hash}
|
|
120
|
+
*/
|
|
121
|
+
export interface DeleteOpenRouterKeyRequest extends RequestBaseParams {
|
|
122
|
+
options: OpenRouterRequestOptions & {
|
|
123
|
+
/** Hash of the key to delete. */
|
|
124
|
+
hash: string;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Response from deleting a key
|
|
129
|
+
*/
|
|
130
|
+
export interface DeleteOpenRouterKeyResponse {
|
|
131
|
+
/** True when OpenRouter removed the key. */
|
|
132
|
+
deleted?: boolean;
|
|
133
|
+
/** Fields that OpenRouter sends and this service does not model. */
|
|
134
|
+
[key: string]: unknown;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Request to list keys
|
|
138
|
+
* GET /keys
|
|
139
|
+
*/
|
|
140
|
+
export interface ListOpenRouterKeysRequest extends RequestBaseParams {
|
|
141
|
+
options: OpenRouterRequestOptions & {
|
|
142
|
+
/** Number of keys to skip. OpenRouter returns 100 keys per page. */
|
|
143
|
+
offset?: number;
|
|
144
|
+
/** When true, disabled keys are part of the result. */
|
|
145
|
+
includeDisabled?: boolean;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Response from listing keys
|
|
150
|
+
*/
|
|
151
|
+
export interface ListOpenRouterKeysResponse {
|
|
152
|
+
data: OpenRouterKeyData[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Service for the key management API of OpenRouter.
|
|
156
|
+
*
|
|
157
|
+
* API documentation: https://openrouter.ai/docs/features/provisioning-api-keys
|
|
158
|
+
*
|
|
159
|
+
* This is the OpenRouter counterpart of `LiteLLMService`. Two differences
|
|
160
|
+
* shape every method:
|
|
161
|
+
*
|
|
162
|
+
* - OpenRouter has no teams. One key per org carries the whole budget, and
|
|
163
|
+
* the name of the key holds the org id.
|
|
164
|
+
* - OpenRouter addresses a key by hash. LiteLLM addressed a key by its value.
|
|
165
|
+
*/
|
|
166
|
+
export declare class OpenRouterService {
|
|
167
|
+
/**
|
|
168
|
+
* Create a key
|
|
169
|
+
* POST /keys
|
|
170
|
+
*/
|
|
171
|
+
static createKey(params: CreateOpenRouterKeyRequest): Promise<CreateOpenRouterKeyResponse>;
|
|
172
|
+
/**
|
|
173
|
+
* Read one key, with its credit usage and limit
|
|
174
|
+
* GET /keys/{hash}
|
|
175
|
+
*/
|
|
176
|
+
static getKey(params: GetOpenRouterKeyRequest): Promise<GetOpenRouterKeyResponse>;
|
|
177
|
+
/**
|
|
178
|
+
* Update the name, the disabled state or the credit limit of a key.
|
|
179
|
+
*
|
|
180
|
+
* OpenRouter has no separate block, unblock or budget route. All three are
|
|
181
|
+
* this one PATCH with a different field.
|
|
182
|
+
* PATCH /keys/{hash}
|
|
183
|
+
*/
|
|
184
|
+
static updateKey(params: UpdateOpenRouterKeyRequest): Promise<UpdateOpenRouterKeyResponse>;
|
|
185
|
+
/**
|
|
186
|
+
* Delete a key
|
|
187
|
+
* DELETE /keys/{hash}
|
|
188
|
+
*/
|
|
189
|
+
static deleteKey(params: DeleteOpenRouterKeyRequest): Promise<DeleteOpenRouterKeyResponse>;
|
|
190
|
+
/**
|
|
191
|
+
* List keys, newest first.
|
|
192
|
+
*
|
|
193
|
+
* This is the recovery path for a key whose hash is not in the metadata of
|
|
194
|
+
* the org. The name of the key holds the org id, so a caller can match on
|
|
195
|
+
* it. OpenRouter returns 100 keys per page. Use `offset` for the next page.
|
|
196
|
+
* GET /keys
|
|
197
|
+
*/
|
|
198
|
+
static listKeys(params: ListOpenRouterKeysRequest): Promise<ListOpenRouterKeysResponse>;
|
|
199
|
+
}
|
|
200
|
+
export {};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { request } from "../../utils/api.js";
|
|
2
|
+
import { HttpError } from "../../utils/errors.js";
|
|
3
|
+
const OPENROUTER_KEY_PAGE_SIZE = 100;
|
|
4
|
+
class OpenRouterService {
|
|
5
|
+
/**
|
|
6
|
+
* Create a key
|
|
7
|
+
* POST /keys
|
|
8
|
+
*/
|
|
9
|
+
static async createKey(params) {
|
|
10
|
+
const serviceContext = {
|
|
11
|
+
method: {
|
|
12
|
+
name: "OpenRouterService.createKey",
|
|
13
|
+
url: `${params.options.openRouterApiBaseUrl}/keys`,
|
|
14
|
+
normalizedUrl: "/keys",
|
|
15
|
+
type: "post"
|
|
16
|
+
},
|
|
17
|
+
source: params.config.metrics?.source || "unset",
|
|
18
|
+
target: {
|
|
19
|
+
name: "openrouter",
|
|
20
|
+
type: "external"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const body = {
|
|
24
|
+
name: params.options.name,
|
|
25
|
+
...params.options.limit !== void 0 && {
|
|
26
|
+
limit: params.options.limit
|
|
27
|
+
},
|
|
28
|
+
...params.options.include_byok_in_limit !== void 0 && {
|
|
29
|
+
include_byok_in_limit: params.options.include_byok_in_limit
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const response = await request({
|
|
33
|
+
config: params.config,
|
|
34
|
+
url: serviceContext.method.url,
|
|
35
|
+
method: serviceContext.method.type,
|
|
36
|
+
metricsDetails: serviceContext,
|
|
37
|
+
type: "json",
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Bearer ${params.options.apiToken}`
|
|
40
|
+
},
|
|
41
|
+
body
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
throw new HttpError(
|
|
45
|
+
`${serviceContext.method.name}: ${response.status} ${response.statusText}`,
|
|
46
|
+
response.status,
|
|
47
|
+
response.statusText
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return response.body;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Read one key, with its credit usage and limit
|
|
54
|
+
* GET /keys/{hash}
|
|
55
|
+
*/
|
|
56
|
+
static async getKey(params) {
|
|
57
|
+
const serviceContext = {
|
|
58
|
+
method: {
|
|
59
|
+
name: "OpenRouterService.getKey",
|
|
60
|
+
url: `${params.options.openRouterApiBaseUrl}/keys/${encodeURIComponent(params.options.hash)}`,
|
|
61
|
+
normalizedUrl: "/keys/:hash",
|
|
62
|
+
type: "get"
|
|
63
|
+
},
|
|
64
|
+
source: params.config.metrics?.source || "unset",
|
|
65
|
+
target: {
|
|
66
|
+
name: "openrouter",
|
|
67
|
+
type: "external"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const response = await request({
|
|
71
|
+
config: params.config,
|
|
72
|
+
url: serviceContext.method.url,
|
|
73
|
+
method: serviceContext.method.type,
|
|
74
|
+
metricsDetails: serviceContext,
|
|
75
|
+
headers: {
|
|
76
|
+
Authorization: `Bearer ${params.options.apiToken}`
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
throw new HttpError(
|
|
81
|
+
`${serviceContext.method.name}: ${response.status} ${response.statusText}`,
|
|
82
|
+
response.status,
|
|
83
|
+
response.statusText
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return response.body;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Update the name, the disabled state or the credit limit of a key.
|
|
90
|
+
*
|
|
91
|
+
* OpenRouter has no separate block, unblock or budget route. All three are
|
|
92
|
+
* this one PATCH with a different field.
|
|
93
|
+
* PATCH /keys/{hash}
|
|
94
|
+
*/
|
|
95
|
+
static async updateKey(params) {
|
|
96
|
+
const serviceContext = {
|
|
97
|
+
method: {
|
|
98
|
+
name: "OpenRouterService.updateKey",
|
|
99
|
+
url: `${params.options.openRouterApiBaseUrl}/keys/${encodeURIComponent(params.options.hash)}`,
|
|
100
|
+
normalizedUrl: "/keys/:hash",
|
|
101
|
+
type: "patch"
|
|
102
|
+
},
|
|
103
|
+
source: params.config.metrics?.source || "unset",
|
|
104
|
+
target: {
|
|
105
|
+
name: "openrouter",
|
|
106
|
+
type: "external"
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const body = {
|
|
110
|
+
...params.options.name !== void 0 && { name: params.options.name },
|
|
111
|
+
...params.options.disabled !== void 0 && {
|
|
112
|
+
disabled: params.options.disabled
|
|
113
|
+
},
|
|
114
|
+
...params.options.limit !== void 0 && {
|
|
115
|
+
limit: params.options.limit
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const response = await request({
|
|
119
|
+
config: params.config,
|
|
120
|
+
url: serviceContext.method.url,
|
|
121
|
+
method: serviceContext.method.type,
|
|
122
|
+
metricsDetails: serviceContext,
|
|
123
|
+
type: "json",
|
|
124
|
+
headers: {
|
|
125
|
+
Authorization: `Bearer ${params.options.apiToken}`
|
|
126
|
+
},
|
|
127
|
+
body
|
|
128
|
+
});
|
|
129
|
+
if (!response.ok) {
|
|
130
|
+
throw new HttpError(
|
|
131
|
+
`${serviceContext.method.name}: ${response.status} ${response.statusText}`,
|
|
132
|
+
response.status,
|
|
133
|
+
response.statusText
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
return response.body;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Delete a key
|
|
140
|
+
* DELETE /keys/{hash}
|
|
141
|
+
*/
|
|
142
|
+
static async deleteKey(params) {
|
|
143
|
+
const serviceContext = {
|
|
144
|
+
method: {
|
|
145
|
+
name: "OpenRouterService.deleteKey",
|
|
146
|
+
url: `${params.options.openRouterApiBaseUrl}/keys/${encodeURIComponent(params.options.hash)}`,
|
|
147
|
+
normalizedUrl: "/keys/:hash",
|
|
148
|
+
type: "delete"
|
|
149
|
+
},
|
|
150
|
+
source: params.config.metrics?.source || "unset",
|
|
151
|
+
target: {
|
|
152
|
+
name: "openrouter",
|
|
153
|
+
type: "external"
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const response = await request({
|
|
157
|
+
config: params.config,
|
|
158
|
+
url: serviceContext.method.url,
|
|
159
|
+
method: serviceContext.method.type,
|
|
160
|
+
metricsDetails: serviceContext,
|
|
161
|
+
headers: {
|
|
162
|
+
Authorization: `Bearer ${params.options.apiToken}`
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
if (!response.ok) {
|
|
166
|
+
throw new HttpError(
|
|
167
|
+
`${serviceContext.method.name}: ${response.status} ${response.statusText}`,
|
|
168
|
+
response.status,
|
|
169
|
+
response.statusText
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
return response.body ?? {};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* List keys, newest first.
|
|
176
|
+
*
|
|
177
|
+
* This is the recovery path for a key whose hash is not in the metadata of
|
|
178
|
+
* the org. The name of the key holds the org id, so a caller can match on
|
|
179
|
+
* it. OpenRouter returns 100 keys per page. Use `offset` for the next page.
|
|
180
|
+
* GET /keys
|
|
181
|
+
*/
|
|
182
|
+
static async listKeys(params) {
|
|
183
|
+
const query = new URLSearchParams();
|
|
184
|
+
if (params.options.offset !== void 0) {
|
|
185
|
+
query.set("offset", String(params.options.offset));
|
|
186
|
+
}
|
|
187
|
+
if (params.options.includeDisabled) {
|
|
188
|
+
query.set("include_disabled", "true");
|
|
189
|
+
}
|
|
190
|
+
const queryString = query.toString();
|
|
191
|
+
const serviceContext = {
|
|
192
|
+
method: {
|
|
193
|
+
name: "OpenRouterService.listKeys",
|
|
194
|
+
url: `${params.options.openRouterApiBaseUrl}/keys${queryString ? `?${queryString}` : ""}`,
|
|
195
|
+
normalizedUrl: "/keys",
|
|
196
|
+
type: "get"
|
|
197
|
+
},
|
|
198
|
+
source: params.config.metrics?.source || "unset",
|
|
199
|
+
target: {
|
|
200
|
+
name: "openrouter",
|
|
201
|
+
type: "external"
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
const response = await request({
|
|
205
|
+
config: params.config,
|
|
206
|
+
url: serviceContext.method.url,
|
|
207
|
+
method: serviceContext.method.type,
|
|
208
|
+
metricsDetails: serviceContext,
|
|
209
|
+
headers: {
|
|
210
|
+
Authorization: `Bearer ${params.options.apiToken}`
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
if (!response.ok) {
|
|
214
|
+
throw new HttpError(
|
|
215
|
+
`${serviceContext.method.name}: ${response.status} ${response.statusText}`,
|
|
216
|
+
response.status,
|
|
217
|
+
response.statusText
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
return response.body;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
export {
|
|
224
|
+
OPENROUTER_KEY_PAGE_SIZE,
|
|
225
|
+
OpenRouterService
|
|
226
|
+
};
|
|
227
|
+
//# sourceMappingURL=openrouter.service.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/services/openrouter/openrouter.service.ts"],
|
|
4
|
+
"sourcesContent": ["/*\n * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH\n * under one or more contributor license agreements. Licensed under a commercial license.\n * You may not use this file except in compliance with the commercial license.\n */\n\nimport type {\n RequestBaseParams,\n RequestBaseServiceContext,\n} from '../../types/general.types.js'\nimport { request } from '../../utils/api.js'\nimport { HttpError } from '../../utils/errors.js'\n\n/**\n * Fields that every key management route of OpenRouter returns for a key.\n *\n * OpenRouter addresses a key by its `hash`, never by the key itself. The key\n * comes back exactly once, from the create route. Thus the caller must persist\n * the hash together with the key. Without the hash, the key cannot be read,\n * disabled or deleted.\n *\n * `usage` and `limit` hold USD credits. They are the OpenRouter names for the\n * `spend` and `max_budget` of LiteLLM.\n */\n/**\n * Number of keys that `GET /keys` gives back in one page.\n *\n * A caller that scans for a key must step `offset` by this number. The\n * integration writes one key per org, so a real account holds more keys than\n * one page.\n */\nexport const OPENROUTER_KEY_PAGE_SIZE = 100\n\nexport interface OpenRouterKeyData {\n /** Identifier of the key for every management route. */\n hash: string\n /** Name of the key. This service writes `org-<orgId>` into it. */\n name?: string\n /** Label of the key, which OpenRouter derives from the name. */\n label?: string\n /** Credit limit in USD. `null` means no limit. */\n limit?: number | null\n /** Credits spent in USD. */\n usage?: number\n /** True when the key is disabled and rejects inference requests. */\n disabled?: boolean\n created_at?: string\n updated_at?: string\n /**\n * Fields that OpenRouter sends and this service does not model, such as\n * `limit_remaining` and the `usage_daily` family. `unknown` keeps them\n * readable and makes a caller narrow the type first.\n */\n [key: string]: unknown\n}\n\n/**\n * Common options of every key management request.\n *\n * The token is a Provisioning API key. An inference key cannot read or write\n * other keys.\n */\ninterface OpenRouterRequestOptions {\n /** Base URL of the OpenRouter API, including the `/api/v1` prefix. */\n openRouterApiBaseUrl: string\n /** Provisioning API key for authentication. */\n apiToken: string\n}\n\n/**\n * Request to create a key\n * POST /keys\n */\nexport interface CreateOpenRouterKeyRequest extends RequestBaseParams {\n options: OpenRouterRequestOptions & {\n /** Name of the key. Used to find the key again if the hash is lost. */\n name: string\n /** Credit limit in USD. */\n limit?: number\n /** When false, credits of a customer-owned provider key do not count. */\n include_byok_in_limit?: boolean\n }\n}\n\n/**\n * Response from creating a key.\n *\n * `key` holds the inference credential and OpenRouter returns it only here.\n * `data.hash` is the handle for every later request about this key.\n */\nexport interface CreateOpenRouterKeyResponse {\n key: string\n data: OpenRouterKeyData\n}\n\n/**\n * Request to read one key\n * GET /keys/{hash}\n */\nexport interface GetOpenRouterKeyRequest extends RequestBaseParams {\n options: OpenRouterRequestOptions & {\n /** Hash of the key to read. */\n hash: string\n }\n}\n\n/**\n * Response from reading one key\n */\nexport interface GetOpenRouterKeyResponse {\n data: OpenRouterKeyData\n}\n\n/**\n * Request to update a key\n * PATCH /keys/{hash}\n */\nexport interface UpdateOpenRouterKeyRequest extends RequestBaseParams {\n options: OpenRouterRequestOptions & {\n /** Hash of the key to update. */\n hash: string\n /** New name of the key. */\n name?: string\n /** True disables the key. False enables it again. */\n disabled?: boolean\n /** New credit limit in USD. */\n limit?: number\n }\n}\n\n/**\n * Response from updating a key\n */\nexport interface UpdateOpenRouterKeyResponse {\n data: OpenRouterKeyData\n}\n\n/**\n * Request to delete a key\n * DELETE /keys/{hash}\n */\nexport interface DeleteOpenRouterKeyRequest extends RequestBaseParams {\n options: OpenRouterRequestOptions & {\n /** Hash of the key to delete. */\n hash: string\n }\n}\n\n/**\n * Response from deleting a key\n */\nexport interface DeleteOpenRouterKeyResponse {\n /** True when OpenRouter removed the key. */\n deleted?: boolean\n /** Fields that OpenRouter sends and this service does not model. */\n [key: string]: unknown\n}\n\n/**\n * Request to list keys\n * GET /keys\n */\nexport interface ListOpenRouterKeysRequest extends RequestBaseParams {\n options: OpenRouterRequestOptions & {\n /** Number of keys to skip. OpenRouter returns 100 keys per page. */\n offset?: number\n /** When true, disabled keys are part of the result. */\n includeDisabled?: boolean\n }\n}\n\n/**\n * Response from listing keys\n */\nexport interface ListOpenRouterKeysResponse {\n data: OpenRouterKeyData[]\n}\n\n/**\n * Service for the key management API of OpenRouter.\n *\n * API documentation: https://openrouter.ai/docs/features/provisioning-api-keys\n *\n * This is the OpenRouter counterpart of `LiteLLMService`. Two differences\n * shape every method:\n *\n * - OpenRouter has no teams. One key per org carries the whole budget, and\n * the name of the key holds the org id.\n * - OpenRouter addresses a key by hash. LiteLLM addressed a key by its value.\n */\nexport class OpenRouterService {\n /**\n * Create a key\n * POST /keys\n */\n public static async createKey(\n params: CreateOpenRouterKeyRequest,\n ): Promise<CreateOpenRouterKeyResponse> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'OpenRouterService.createKey',\n url: `${params.options.openRouterApiBaseUrl}/keys`,\n normalizedUrl: '/keys',\n type: 'post',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'openrouter',\n type: 'external',\n },\n }\n\n const body = {\n name: params.options.name,\n ...(params.options.limit !== undefined && {\n limit: params.options.limit,\n }),\n ...(params.options.include_byok_in_limit !== undefined && {\n include_byok_in_limit: params.options.include_byok_in_limit,\n }),\n }\n\n const response = await request<CreateOpenRouterKeyResponse>({\n config: params.config,\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n type: 'json',\n headers: {\n Authorization: `Bearer ${params.options.apiToken}`,\n },\n body,\n })\n\n if (!response.ok) {\n throw new HttpError(\n `${serviceContext.method.name}: ${response.status} ${response.statusText}`,\n response.status,\n response.statusText,\n )\n }\n\n return response.body!\n }\n\n /**\n * Read one key, with its credit usage and limit\n * GET /keys/{hash}\n */\n public static async getKey(\n params: GetOpenRouterKeyRequest,\n ): Promise<GetOpenRouterKeyResponse> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'OpenRouterService.getKey',\n url: `${params.options.openRouterApiBaseUrl}/keys/${encodeURIComponent(params.options.hash)}`,\n normalizedUrl: '/keys/:hash',\n type: 'get',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'openrouter',\n type: 'external',\n },\n }\n\n const response = await request<GetOpenRouterKeyResponse>({\n config: params.config,\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n headers: {\n Authorization: `Bearer ${params.options.apiToken}`,\n },\n })\n\n if (!response.ok) {\n throw new HttpError(\n `${serviceContext.method.name}: ${response.status} ${response.statusText}`,\n response.status,\n response.statusText,\n )\n }\n\n return response.body!\n }\n\n /**\n * Update the name, the disabled state or the credit limit of a key.\n *\n * OpenRouter has no separate block, unblock or budget route. All three are\n * this one PATCH with a different field.\n * PATCH /keys/{hash}\n */\n public static async updateKey(\n params: UpdateOpenRouterKeyRequest,\n ): Promise<UpdateOpenRouterKeyResponse> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'OpenRouterService.updateKey',\n url: `${params.options.openRouterApiBaseUrl}/keys/${encodeURIComponent(params.options.hash)}`,\n normalizedUrl: '/keys/:hash',\n type: 'patch',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'openrouter',\n type: 'external',\n },\n }\n\n const body = {\n ...(params.options.name !== undefined && { name: params.options.name }),\n ...(params.options.disabled !== undefined && {\n disabled: params.options.disabled,\n }),\n ...(params.options.limit !== undefined && {\n limit: params.options.limit,\n }),\n }\n\n const response = await request<UpdateOpenRouterKeyResponse>({\n config: params.config,\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n type: 'json',\n headers: {\n Authorization: `Bearer ${params.options.apiToken}`,\n },\n body,\n })\n\n if (!response.ok) {\n throw new HttpError(\n `${serviceContext.method.name}: ${response.status} ${response.statusText}`,\n response.status,\n response.statusText,\n )\n }\n\n return response.body!\n }\n\n /**\n * Delete a key\n * DELETE /keys/{hash}\n */\n public static async deleteKey(\n params: DeleteOpenRouterKeyRequest,\n ): Promise<DeleteOpenRouterKeyResponse> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'OpenRouterService.deleteKey',\n url: `${params.options.openRouterApiBaseUrl}/keys/${encodeURIComponent(params.options.hash)}`,\n normalizedUrl: '/keys/:hash',\n type: 'delete',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'openrouter',\n type: 'external',\n },\n }\n\n const response = await request<DeleteOpenRouterKeyResponse>({\n config: params.config,\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n headers: {\n Authorization: `Bearer ${params.options.apiToken}`,\n },\n })\n\n if (!response.ok) {\n throw new HttpError(\n `${serviceContext.method.name}: ${response.status} ${response.statusText}`,\n response.status,\n response.statusText,\n )\n }\n\n return response.body ?? {}\n }\n\n /**\n * List keys, newest first.\n *\n * This is the recovery path for a key whose hash is not in the metadata of\n * the org. The name of the key holds the org id, so a caller can match on\n * it. OpenRouter returns 100 keys per page. Use `offset` for the next page.\n * GET /keys\n */\n public static async listKeys(\n params: ListOpenRouterKeysRequest,\n ): Promise<ListOpenRouterKeysResponse> {\n const query = new URLSearchParams()\n if (params.options.offset !== undefined) {\n query.set('offset', String(params.options.offset))\n }\n if (params.options.includeDisabled) {\n query.set('include_disabled', 'true')\n }\n const queryString = query.toString()\n\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'OpenRouterService.listKeys',\n url: `${params.options.openRouterApiBaseUrl}/keys${queryString ? `?${queryString}` : ''}`,\n normalizedUrl: '/keys',\n type: 'get',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'openrouter',\n type: 'external',\n },\n }\n\n const response = await request<ListOpenRouterKeysResponse>({\n config: params.config,\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n headers: {\n Authorization: `Bearer ${params.options.apiToken}`,\n },\n })\n\n if (!response.ok) {\n throw new HttpError(\n `${serviceContext.method.name}: ${response.status} ${response.statusText}`,\n response.status,\n response.statusText,\n )\n }\n\n return response.body!\n }\n}\n"],
|
|
5
|
+
"mappings": "AAUA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAoBnB,MAAM,2BAA2B;AA+JjC,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA,EAK7B,aAAoB,UAClB,QACsC;AACtC,UAAM,iBAA4C;AAAA,MAChD,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,KAAK,GAAG,OAAO,QAAQ,oBAAoB;AAAA,QAC3C,eAAe;AAAA,QACf,MAAM;AAAA,MACR;AAAA,MACA,QAAQ,OAAO,OAAO,SAAS,UAAU;AAAA,MACzC,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAEA,UAAM,OAAO;AAAA,MACX,MAAM,OAAO,QAAQ;AAAA,MACrB,GAAI,OAAO,QAAQ,UAAU,UAAa;AAA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ACN,MAAM;AAAA,QACN,KAAK,GAAG,OAAO,QAAQ,oBAAoB,QAAQ,cAAc,IAAI,WAAW,KAAK,EAAE;AAAA,QACvF,eAAe;AAAA,QACf,MAAM;AAAA,MACR;AAAA,MACA,QAAQ,OAAO,OAAO,SAAS,UAAU;AAAA,MACzC,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAAoC;AAAA,MACzD,QAAQ,OAAO;AAAA,MACf,KAAK,eAAe,OAAO;AAAA,MAC3B,QAAQ,eAAe,OAAO;AAAA,MAC9B,gBAAgB;AAAA,MAChB,SAAS;AAAA,QACP,eAAe,UAAU,OAAO,QAAQ,QAAQ;AAAA,MAClD;AAAA,IACF,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI;AAAA,QACR,GAAG,eAAe,OAAO,IAAI,KAAK,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,QACxE,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,IACF;AAEA,WAAO,SAAS;AAAA,EAClB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camunda/ccma-api",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Centralized API service layer for Camunda Cloud Management Apps",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/camunda/camunda-cloud-management-apps/issues"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@camunda/ccma-shared-types": "1.
|
|
44
|
+
"@camunda/ccma-shared-types": "1.2.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "node esbuild.mjs && tsc --emitDeclarationOnly --outDir dist",
|