@acosmi/sdk-ts 1.5.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +168 -1
- package/README.md +20 -1
- package/dist/browser/index.mjs +426 -6
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.mjs +426 -6
- package/dist/index.mjs.map +1 -1
- package/dist/node/adapters/anthropic.cjs +11 -2
- package/dist/node/adapters/anthropic.cjs.map +1 -1
- package/dist/node/adapters/anthropic.d.cts +1 -1
- package/dist/node/adapters/anthropic.d.ts +1 -1
- package/dist/node/adapters/anthropic.mjs +11 -2
- package/dist/node/adapters/anthropic.mjs.map +1 -1
- package/dist/node/adapters/openai.cjs +3 -0
- package/dist/node/adapters/openai.cjs.map +1 -1
- package/dist/node/adapters/openai.d.cts +2 -2
- package/dist/node/adapters/openai.d.ts +2 -2
- package/dist/node/adapters/openai.mjs +3 -0
- package/dist/node/adapters/openai.mjs.map +1 -1
- package/dist/node/{index-nvLKgCm9.d.cts → index-Bah9A83R.d.cts} +1 -1
- package/dist/node/{index-nvLKgCm9.d.ts → index-Bah9A83R.d.ts} +1 -1
- package/dist/node/{index-DEA6LXw6.d.cts → index-C9X5Yuyk.d.cts} +10 -1
- package/dist/node/{index-DEA6LXw6.d.ts → index-C9X5Yuyk.d.ts} +10 -1
- package/dist/node/index.cjs +432 -5
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +644 -7
- package/dist/node/index.d.ts +644 -7
- package/dist/node/index.mjs +426 -6
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{openai-vfUUgdvL.d.ts → openai-BqKAhbSc.d.ts} +2 -2
- package/dist/node/{openai-BDodfhsG.d.cts → openai-C_UKadSX.d.cts} +2 -2
- package/dist/node/sanitize/index.d.cts +1 -1
- package/dist/node/sanitize/index.d.ts +1 -1
- package/package.json +2 -2
package/dist/node/index.cjs
CHANGED
|
@@ -367,8 +367,17 @@ var init_anthropic = __esm({
|
|
|
367
367
|
body["effort"] = req.effort;
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
|
-
if (req.metadata) {
|
|
371
|
-
|
|
370
|
+
if (req.metadata || req.endUserId && req.endUserId !== "") {
|
|
371
|
+
const meta = {};
|
|
372
|
+
if (req.metadata) {
|
|
373
|
+
for (const [k, v] of Object.entries(req.metadata)) {
|
|
374
|
+
meta[k] = v;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (req.endUserId && req.endUserId !== "" && meta["user_id"] === void 0) {
|
|
378
|
+
meta["user_id"] = req.endUserId;
|
|
379
|
+
}
|
|
380
|
+
body["metadata"] = meta;
|
|
372
381
|
}
|
|
373
382
|
const allTools = [];
|
|
374
383
|
if (req.tools != null) {
|
|
@@ -712,6 +721,9 @@ var init_openai = __esm({
|
|
|
712
721
|
body[k] = v;
|
|
713
722
|
}
|
|
714
723
|
}
|
|
724
|
+
if (req.endUserId && req.endUserId !== "") {
|
|
725
|
+
body["user_id"] = req.endUserId;
|
|
726
|
+
}
|
|
715
727
|
if (req.stream === true) {
|
|
716
728
|
body["stream_options"] = { include_usage: true };
|
|
717
729
|
}
|
|
@@ -1775,6 +1787,30 @@ function extractAnthropicBlockMeta(eventType, data, blockTypeMap) {
|
|
|
1775
1787
|
// src/core/client.ts
|
|
1776
1788
|
init_openai();
|
|
1777
1789
|
|
|
1790
|
+
// src/models/enduser.ts
|
|
1791
|
+
var maxEndUserIdLength = 512;
|
|
1792
|
+
function validateEndUserId(s) {
|
|
1793
|
+
if (!s) return null;
|
|
1794
|
+
if (s.length > maxEndUserIdLength) {
|
|
1795
|
+
return `endUserId length ${s.length} > ${maxEndUserIdLength}`;
|
|
1796
|
+
}
|
|
1797
|
+
for (let i = 0; i < s.length; i++) {
|
|
1798
|
+
const c = s.charCodeAt(i);
|
|
1799
|
+
const ok = c >= 97 && c <= 122 || // a-z
|
|
1800
|
+
c >= 65 && c <= 90 || // A-Z
|
|
1801
|
+
c >= 48 && c <= 57 || // 0-9
|
|
1802
|
+
c === 95 || // _
|
|
1803
|
+
c === 45;
|
|
1804
|
+
if (!ok) {
|
|
1805
|
+
return `endUserId contains invalid char code 0x${c.toString(16)} at offset ${i} (allowed: [a-zA-Z0-9_-])`;
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
return null;
|
|
1809
|
+
}
|
|
1810
|
+
function isSSECommentLine(line) {
|
|
1811
|
+
return line.length > 0 && line.charCodeAt(0) === 58;
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1778
1814
|
// src/core/http.ts
|
|
1779
1815
|
init_errors();
|
|
1780
1816
|
var maxDownloadSize = 50 * 1024 * 1024;
|
|
@@ -1965,6 +2001,7 @@ var FilterStatusUnknown = "";
|
|
|
1965
2001
|
var ErrOAuthCORSBlocked = "oauth_cors_blocked";
|
|
1966
2002
|
var ErrRefreshProxyFailed = "refresh_proxy_failed";
|
|
1967
2003
|
var ErrTokenExpired = "token_expired";
|
|
2004
|
+
var CHAT_REQUEST_TIMEOUT_MS = 11 * 60 * 1e3;
|
|
1968
2005
|
function newDeferred() {
|
|
1969
2006
|
let resolve;
|
|
1970
2007
|
let reject;
|
|
@@ -2558,7 +2595,7 @@ var Client = class _Client {
|
|
|
2558
2595
|
*/
|
|
2559
2596
|
async chat(modelID, req, signal) {
|
|
2560
2597
|
req.stream = false;
|
|
2561
|
-
const ctl = withRequestTimeout(
|
|
2598
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2562
2599
|
try {
|
|
2563
2600
|
const { body, adapter } = await this.buildChatRequest(modelID, req, ctl.signal);
|
|
2564
2601
|
const endpoint = `/managed-models/${encodeURIComponent(modelID)}${adapter.endpointSuffix()}`;
|
|
@@ -2605,7 +2642,7 @@ var Client = class _Client {
|
|
|
2605
2642
|
}
|
|
2606
2643
|
async chatMessagesAnthropic(modelID, req, adapter, signal) {
|
|
2607
2644
|
req.stream = false;
|
|
2608
|
-
const ctl = withRequestTimeout(
|
|
2645
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2609
2646
|
try {
|
|
2610
2647
|
const caps = this.getCachedCapabilities(modelID) ?? zeroModelCapabilities();
|
|
2611
2648
|
const body = adapter.buildRequestBody(caps, req);
|
|
@@ -2642,7 +2679,7 @@ var Client = class _Client {
|
|
|
2642
2679
|
}
|
|
2643
2680
|
async chatMessagesOpenAI(modelID, req, adapter, signal) {
|
|
2644
2681
|
req.stream = false;
|
|
2645
|
-
const ctl = withRequestTimeout(
|
|
2682
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2646
2683
|
try {
|
|
2647
2684
|
const caps = this.getCachedCapabilities(modelID) ?? zeroModelCapabilities();
|
|
2648
2685
|
const body = adapter.buildRequestBody(caps, req);
|
|
@@ -2723,6 +2760,7 @@ var Client = class _Client {
|
|
|
2723
2760
|
}
|
|
2724
2761
|
let currentEvent = "";
|
|
2725
2762
|
for await (const line of iterSSELines(resp.body)) {
|
|
2763
|
+
if (isSSECommentLine(line)) continue;
|
|
2726
2764
|
if (line.startsWith("event:")) {
|
|
2727
2765
|
currentEvent = line.slice("event:".length).trim();
|
|
2728
2766
|
} else if (line.startsWith("data:")) {
|
|
@@ -2788,6 +2826,7 @@ var Client = class _Client {
|
|
|
2788
2826
|
if (adapter.format() === 1 /* OpenAI */) {
|
|
2789
2827
|
const converter = newOpenAIStreamConverter();
|
|
2790
2828
|
for await (const line of iterSSELines(resp.body)) {
|
|
2829
|
+
if (isSSECommentLine(line)) continue;
|
|
2791
2830
|
if (line.startsWith("event:")) {
|
|
2792
2831
|
line.slice("event:".length).trim();
|
|
2793
2832
|
} else if (line.startsWith("data:")) {
|
|
@@ -2801,6 +2840,7 @@ var Client = class _Client {
|
|
|
2801
2840
|
const blockTypeMap = /* @__PURE__ */ new Map();
|
|
2802
2841
|
let currentEvent = "";
|
|
2803
2842
|
for await (const line of iterSSELines(resp.body)) {
|
|
2843
|
+
if (isSSECommentLine(line)) continue;
|
|
2804
2844
|
if (line.startsWith("event:")) {
|
|
2805
2845
|
currentEvent = line.slice("event:".length).trim();
|
|
2806
2846
|
} else if (line.startsWith("data:")) {
|
|
@@ -6088,8 +6128,390 @@ Client.prototype.getBugReport = async function(bugID, signal) {
|
|
|
6088
6128
|
return resp.data;
|
|
6089
6129
|
};
|
|
6090
6130
|
|
|
6131
|
+
// src/subscription/client.ts
|
|
6132
|
+
Client.prototype.listPlans = async function(audience, signal) {
|
|
6133
|
+
const query = audience ? `?audience=${encodeURIComponent(audience)}` : "";
|
|
6134
|
+
const resp = await this.doJSON(
|
|
6135
|
+
"GET",
|
|
6136
|
+
`/distribution/public/pricing/plans${query}`,
|
|
6137
|
+
null,
|
|
6138
|
+
signal
|
|
6139
|
+
);
|
|
6140
|
+
return Array.isArray(resp.data) ? resp.data : [];
|
|
6141
|
+
};
|
|
6142
|
+
Client.prototype.listUserSubscriptions = async function(signal) {
|
|
6143
|
+
const resp = await this.doJSON(
|
|
6144
|
+
"GET",
|
|
6145
|
+
"/distribution/user/subscriptions",
|
|
6146
|
+
null,
|
|
6147
|
+
signal
|
|
6148
|
+
);
|
|
6149
|
+
return Array.isArray(resp.data) ? resp.data : [];
|
|
6150
|
+
};
|
|
6151
|
+
|
|
6152
|
+
// src/pricing/client.ts
|
|
6153
|
+
Client.prototype.getPricingConfig = async function(key, signal) {
|
|
6154
|
+
const query = key ? `?key=${encodeURIComponent(key)}` : "";
|
|
6155
|
+
const resp = await this.doJSON(
|
|
6156
|
+
"GET",
|
|
6157
|
+
`/distribution/public/pricing/config${query}`,
|
|
6158
|
+
null,
|
|
6159
|
+
signal
|
|
6160
|
+
);
|
|
6161
|
+
return resp.data ?? {};
|
|
6162
|
+
};
|
|
6163
|
+
Client.prototype.listPublicModels = async function(signal) {
|
|
6164
|
+
const resp = await this.doJSON(
|
|
6165
|
+
"GET",
|
|
6166
|
+
"/distribution/public/pricing/models",
|
|
6167
|
+
null,
|
|
6168
|
+
signal
|
|
6169
|
+
);
|
|
6170
|
+
return Array.isArray(resp.data) ? resp.data : [];
|
|
6171
|
+
};
|
|
6172
|
+
Client.prototype.listComplianceSkus = async function(region, signal) {
|
|
6173
|
+
const query = region ? `?region=${encodeURIComponent(region)}` : "";
|
|
6174
|
+
const resp = await this.doJSON(
|
|
6175
|
+
"GET",
|
|
6176
|
+
`/distribution/public/compliance/skus${query}`,
|
|
6177
|
+
null,
|
|
6178
|
+
signal
|
|
6179
|
+
);
|
|
6180
|
+
return Array.isArray(resp.data) ? resp.data : [];
|
|
6181
|
+
};
|
|
6182
|
+
Client.prototype.quoteCompliance = async function(skuCode, quantity, region, signal) {
|
|
6183
|
+
if (!skuCode) {
|
|
6184
|
+
throw new Error("quoteCompliance: skuCode is required");
|
|
6185
|
+
}
|
|
6186
|
+
const params = [`skuCode=${encodeURIComponent(skuCode)}`];
|
|
6187
|
+
if (quantity != null) params.push(`quantity=${quantity}`);
|
|
6188
|
+
if (region) params.push(`region=${encodeURIComponent(region)}`);
|
|
6189
|
+
const resp = await this.doJSON(
|
|
6190
|
+
"GET",
|
|
6191
|
+
`/distribution/public/compliance/quote?${params.join("&")}`,
|
|
6192
|
+
null,
|
|
6193
|
+
signal
|
|
6194
|
+
);
|
|
6195
|
+
return resp.data ?? { skuCode, available: false };
|
|
6196
|
+
};
|
|
6197
|
+
|
|
6198
|
+
// src/products/types.ts
|
|
6199
|
+
var ProductFamilyEnum = {
|
|
6200
|
+
MODEL_MEMBERSHIP: "MODEL_MEMBERSHIP",
|
|
6201
|
+
TOKEN_PACK: "TOKEN_PACK",
|
|
6202
|
+
COMPLIANCE: "COMPLIANCE",
|
|
6203
|
+
LEGAL: "LEGAL",
|
|
6204
|
+
DESIGN_AGENT: "DESIGN_AGENT",
|
|
6205
|
+
ENTERPRISE: "ENTERPRISE"
|
|
6206
|
+
};
|
|
6207
|
+
var AudienceEnum = {
|
|
6208
|
+
PERSONAL: "PERSONAL",
|
|
6209
|
+
ENTERPRISE: "ENTERPRISE",
|
|
6210
|
+
DEVELOPER: "DEVELOPER"
|
|
6211
|
+
};
|
|
6212
|
+
var BillingModeEnum = {
|
|
6213
|
+
ONE_TIME: "ONE_TIME",
|
|
6214
|
+
SUBSCRIPTION: "SUBSCRIPTION",
|
|
6215
|
+
METERED: "METERED",
|
|
6216
|
+
HYBRID: "HYBRID"
|
|
6217
|
+
};
|
|
6218
|
+
var RegionScopeEnum = {
|
|
6219
|
+
CN: "CN",
|
|
6220
|
+
OS: "OS",
|
|
6221
|
+
GLOBAL: "GLOBAL"
|
|
6222
|
+
};
|
|
6223
|
+
|
|
6224
|
+
// src/products/client.ts
|
|
6225
|
+
Client.prototype.listProductsByFamily = async function(family, audience, region, signal) {
|
|
6226
|
+
const params = [];
|
|
6227
|
+
if (family) params.push(`family=${encodeURIComponent(family)}`);
|
|
6228
|
+
if (audience) params.push(`audience=${encodeURIComponent(audience)}`);
|
|
6229
|
+
if (region) params.push(`region=${encodeURIComponent(region)}`);
|
|
6230
|
+
const query = params.length > 0 ? `?${params.join("&")}` : "";
|
|
6231
|
+
const resp = await this.doJSON(
|
|
6232
|
+
"GET",
|
|
6233
|
+
`/distribution/public/products/by-family${query}`,
|
|
6234
|
+
null,
|
|
6235
|
+
signal
|
|
6236
|
+
);
|
|
6237
|
+
return Array.isArray(resp.data) ? resp.data : [];
|
|
6238
|
+
};
|
|
6239
|
+
Client.prototype.getProductBySlug = async function(slug, region, signal) {
|
|
6240
|
+
if (!slug) {
|
|
6241
|
+
throw new Error("getProductBySlug: slug is required");
|
|
6242
|
+
}
|
|
6243
|
+
const query = region ? `?region=${encodeURIComponent(region)}` : "";
|
|
6244
|
+
const resp = await this.doJSON(
|
|
6245
|
+
"GET",
|
|
6246
|
+
`/distribution/public/products/by-slug/${encodeURIComponent(slug)}${query}`,
|
|
6247
|
+
null,
|
|
6248
|
+
signal
|
|
6249
|
+
);
|
|
6250
|
+
if (!resp.data) {
|
|
6251
|
+
throw new Error(`getProductBySlug: product not found (slug=${slug})`);
|
|
6252
|
+
}
|
|
6253
|
+
return resp.data;
|
|
6254
|
+
};
|
|
6255
|
+
|
|
6256
|
+
// src/casehall/client.ts
|
|
6257
|
+
Client.prototype.listLawyers = async function(params, signal) {
|
|
6258
|
+
const qs = new URLSearchParams();
|
|
6259
|
+
if (params?.practiceArea) qs.set("practiceArea", params.practiceArea);
|
|
6260
|
+
if (params?.location) qs.set("location", params.location);
|
|
6261
|
+
if (params?.pageNo != null) qs.set("pageNo", String(params.pageNo));
|
|
6262
|
+
if (params?.pageSize != null) qs.set("pageSize", String(params.pageSize));
|
|
6263
|
+
const q = qs.toString() ? `?${qs.toString()}` : "";
|
|
6264
|
+
const resp = await this.doJSON(
|
|
6265
|
+
"GET",
|
|
6266
|
+
`/casehall/app/lawyers${q}`,
|
|
6267
|
+
null,
|
|
6268
|
+
signal
|
|
6269
|
+
);
|
|
6270
|
+
return resp.data ?? [];
|
|
6271
|
+
};
|
|
6272
|
+
Client.prototype.getLawyer = async function(id, signal) {
|
|
6273
|
+
const resp = await this.doJSON(
|
|
6274
|
+
"GET",
|
|
6275
|
+
`/casehall/app/lawyers/${id}`,
|
|
6276
|
+
null,
|
|
6277
|
+
signal
|
|
6278
|
+
);
|
|
6279
|
+
if (!resp.data) throw new Error(`lawyer ${id} not found`);
|
|
6280
|
+
return resp.data;
|
|
6281
|
+
};
|
|
6282
|
+
Client.prototype.submitCaseLead = async function(req, signal) {
|
|
6283
|
+
const resp = await this.doJSON(
|
|
6284
|
+
"POST",
|
|
6285
|
+
`/casehall/me/case-leads`,
|
|
6286
|
+
req,
|
|
6287
|
+
signal
|
|
6288
|
+
);
|
|
6289
|
+
return resp.data ?? { id: 0 };
|
|
6290
|
+
};
|
|
6291
|
+
Client.prototype.listMyCaseLeads = async function(signal) {
|
|
6292
|
+
const resp = await this.doJSON(
|
|
6293
|
+
"GET",
|
|
6294
|
+
`/casehall/me/case-leads`,
|
|
6295
|
+
null,
|
|
6296
|
+
signal
|
|
6297
|
+
);
|
|
6298
|
+
return resp.data ?? [];
|
|
6299
|
+
};
|
|
6300
|
+
Client.prototype.getMyCases = async function(signal) {
|
|
6301
|
+
const resp = await this.doJSON(
|
|
6302
|
+
"GET",
|
|
6303
|
+
`/casehall/me/cases`,
|
|
6304
|
+
null,
|
|
6305
|
+
signal
|
|
6306
|
+
);
|
|
6307
|
+
return resp.data ?? [];
|
|
6308
|
+
};
|
|
6309
|
+
Client.prototype.bookConsultation = async function(req, signal) {
|
|
6310
|
+
const resp = await this.doJSON(
|
|
6311
|
+
"POST",
|
|
6312
|
+
`/casehall/me/consultations`,
|
|
6313
|
+
req,
|
|
6314
|
+
signal
|
|
6315
|
+
);
|
|
6316
|
+
return resp.data ?? { consultationId: 0 };
|
|
6317
|
+
};
|
|
6318
|
+
Client.prototype.listMyConsultations = async function(signal) {
|
|
6319
|
+
const resp = await this.doJSON(
|
|
6320
|
+
"GET",
|
|
6321
|
+
`/casehall/me/consultations`,
|
|
6322
|
+
null,
|
|
6323
|
+
signal
|
|
6324
|
+
);
|
|
6325
|
+
return resp.data ?? [];
|
|
6326
|
+
};
|
|
6327
|
+
Client.prototype.listMyLegalOrders = async function(signal) {
|
|
6328
|
+
const resp = await this.doJSON(
|
|
6329
|
+
"GET",
|
|
6330
|
+
`/casehall/me/orders`,
|
|
6331
|
+
null,
|
|
6332
|
+
signal
|
|
6333
|
+
);
|
|
6334
|
+
return resp.data ?? [];
|
|
6335
|
+
};
|
|
6336
|
+
Client.prototype.listLegalSKUs = async function(region, signal) {
|
|
6337
|
+
const q = region ? `?region=${encodeURIComponent(region)}&benefitType=LEGAL_SERVICE` : `?benefitType=LEGAL_SERVICE`;
|
|
6338
|
+
const resp = await this.doJSON(
|
|
6339
|
+
"GET",
|
|
6340
|
+
`/casehall/app/legal-skus${q}`,
|
|
6341
|
+
null,
|
|
6342
|
+
signal
|
|
6343
|
+
);
|
|
6344
|
+
return resp.data ?? [];
|
|
6345
|
+
};
|
|
6346
|
+
|
|
6347
|
+
// src/enterprise/client.ts
|
|
6348
|
+
Client.prototype.listMyEnterprises = async function(signal) {
|
|
6349
|
+
const resp = await this.doJSON(
|
|
6350
|
+
"GET",
|
|
6351
|
+
`/me/enterprises`,
|
|
6352
|
+
null,
|
|
6353
|
+
signal
|
|
6354
|
+
);
|
|
6355
|
+
return resp.data ?? [];
|
|
6356
|
+
};
|
|
6357
|
+
Client.prototype.getEnterprise = async function(id, signal) {
|
|
6358
|
+
const resp = await this.doJSON(
|
|
6359
|
+
"GET",
|
|
6360
|
+
`/api/admin/enterprises/${id}`,
|
|
6361
|
+
null,
|
|
6362
|
+
signal
|
|
6363
|
+
);
|
|
6364
|
+
if (!resp.data) throw new Error(`enterprise ${id} not found`);
|
|
6365
|
+
return resp.data;
|
|
6366
|
+
};
|
|
6367
|
+
Client.prototype.inviteMember = async function(req, signal) {
|
|
6368
|
+
const resp = await this.doJSON(
|
|
6369
|
+
"POST",
|
|
6370
|
+
`/api/admin/enterprise-members`,
|
|
6371
|
+
req,
|
|
6372
|
+
signal
|
|
6373
|
+
);
|
|
6374
|
+
if (!resp.data) throw new Error("invite member failed");
|
|
6375
|
+
return resp.data;
|
|
6376
|
+
};
|
|
6377
|
+
Client.prototype.listEnterpriseMembers = async function(enterpriseId, signal) {
|
|
6378
|
+
const resp = await this.doJSON(
|
|
6379
|
+
"GET",
|
|
6380
|
+
`/api/admin/enterprise-members/by-enterprise/${enterpriseId}`,
|
|
6381
|
+
null,
|
|
6382
|
+
signal
|
|
6383
|
+
);
|
|
6384
|
+
return resp.data ?? [];
|
|
6385
|
+
};
|
|
6386
|
+
Client.prototype.listOrgSubscriptions = async function(enterpriseId, signal) {
|
|
6387
|
+
const resp = await this.doJSON(
|
|
6388
|
+
"GET",
|
|
6389
|
+
`/api/admin/org-subscriptions/by-enterprise/${enterpriseId}`,
|
|
6390
|
+
null,
|
|
6391
|
+
signal
|
|
6392
|
+
);
|
|
6393
|
+
return resp.data ?? [];
|
|
6394
|
+
};
|
|
6395
|
+
Client.prototype.listSeats = async function(orgSubscriptionId, signal) {
|
|
6396
|
+
const resp = await this.doJSON(
|
|
6397
|
+
"GET",
|
|
6398
|
+
`/api/admin/org-seats/by-subscription/${orgSubscriptionId}`,
|
|
6399
|
+
null,
|
|
6400
|
+
signal
|
|
6401
|
+
);
|
|
6402
|
+
return resp.data ?? [];
|
|
6403
|
+
};
|
|
6404
|
+
Client.prototype.assignSeat = async function(req, signal) {
|
|
6405
|
+
const resp = await this.doJSON(
|
|
6406
|
+
"POST",
|
|
6407
|
+
`/api/admin/org-seats/assign`,
|
|
6408
|
+
req,
|
|
6409
|
+
signal
|
|
6410
|
+
);
|
|
6411
|
+
if (!resp.data) throw new Error("assign seat failed");
|
|
6412
|
+
return resp.data;
|
|
6413
|
+
};
|
|
6414
|
+
Client.prototype.revokeSeat = async function(seatId, note, signal) {
|
|
6415
|
+
const qs = note ? `?note=${encodeURIComponent(note)}` : "";
|
|
6416
|
+
await this.doJSON(
|
|
6417
|
+
"POST",
|
|
6418
|
+
`/api/admin/org-seats/${seatId}/revoke${qs}`,
|
|
6419
|
+
null,
|
|
6420
|
+
signal
|
|
6421
|
+
);
|
|
6422
|
+
};
|
|
6423
|
+
Client.prototype.getOrgConsumeReport = async function(enterpriseId, signal) {
|
|
6424
|
+
const resp = await this.doJSON(
|
|
6425
|
+
"GET",
|
|
6426
|
+
`/api/admin/enterprise-settlements/overview/${enterpriseId}`,
|
|
6427
|
+
null,
|
|
6428
|
+
signal
|
|
6429
|
+
);
|
|
6430
|
+
if (!resp.data) {
|
|
6431
|
+
return {
|
|
6432
|
+
enterpriseId,
|
|
6433
|
+
subscriptionCount: 0,
|
|
6434
|
+
totalPoolTk: 0,
|
|
6435
|
+
totalUsedTk: 0,
|
|
6436
|
+
totalPriceFen: 0
|
|
6437
|
+
};
|
|
6438
|
+
}
|
|
6439
|
+
return resp.data;
|
|
6440
|
+
};
|
|
6441
|
+
|
|
6442
|
+
// src/finance/client.ts
|
|
6443
|
+
Client.prototype.requestRefund = async function(req, signal) {
|
|
6444
|
+
const resp = await this.doJSON(
|
|
6445
|
+
"POST",
|
|
6446
|
+
`/api/distribution/finance/refund/request`,
|
|
6447
|
+
req,
|
|
6448
|
+
signal
|
|
6449
|
+
);
|
|
6450
|
+
if (!resp.data) throw new Error("refund/request: empty response");
|
|
6451
|
+
return resp.data;
|
|
6452
|
+
};
|
|
6453
|
+
Client.prototype.listMyRefunds = async function(signal) {
|
|
6454
|
+
const resp = await this.doJSON(
|
|
6455
|
+
"GET",
|
|
6456
|
+
`/api/distribution/finance/refund/my`,
|
|
6457
|
+
null,
|
|
6458
|
+
signal
|
|
6459
|
+
);
|
|
6460
|
+
return resp.data ?? [];
|
|
6461
|
+
};
|
|
6462
|
+
Client.prototype.requestInvoice = async function(req, signal) {
|
|
6463
|
+
const resp = await this.doJSON(
|
|
6464
|
+
"POST",
|
|
6465
|
+
`/api/distribution/finance/invoice/request`,
|
|
6466
|
+
req,
|
|
6467
|
+
signal
|
|
6468
|
+
);
|
|
6469
|
+
if (!resp.data) throw new Error("invoice/request: empty response");
|
|
6470
|
+
return resp.data;
|
|
6471
|
+
};
|
|
6472
|
+
Client.prototype.listMyInvoices = async function(signal) {
|
|
6473
|
+
const resp = await this.doJSON(
|
|
6474
|
+
"GET",
|
|
6475
|
+
`/api/distribution/finance/invoice/my`,
|
|
6476
|
+
null,
|
|
6477
|
+
signal
|
|
6478
|
+
);
|
|
6479
|
+
return resp.data ?? [];
|
|
6480
|
+
};
|
|
6481
|
+
Client.prototype.initiateCorporateTransfer = async function(req, signal) {
|
|
6482
|
+
const resp = await this.doJSON(
|
|
6483
|
+
"POST",
|
|
6484
|
+
`/api/distribution/finance/corporate-transfer/initiate`,
|
|
6485
|
+
req,
|
|
6486
|
+
signal
|
|
6487
|
+
);
|
|
6488
|
+
if (!resp.data) throw new Error("corporate-transfer/initiate: empty response");
|
|
6489
|
+
return resp.data;
|
|
6490
|
+
};
|
|
6491
|
+
Client.prototype.uploadCorporateTransferProof = async function(id, proofUrl, signal) {
|
|
6492
|
+
const qs = new URLSearchParams({ proofUrl });
|
|
6493
|
+
const resp = await this.doJSON(
|
|
6494
|
+
"POST",
|
|
6495
|
+
`/api/distribution/finance/corporate-transfer/${id}/upload-proof?${qs.toString()}`,
|
|
6496
|
+
null,
|
|
6497
|
+
signal
|
|
6498
|
+
);
|
|
6499
|
+
return resp.data ?? false;
|
|
6500
|
+
};
|
|
6501
|
+
Client.prototype.listMyCorporateTransfers = async function(signal) {
|
|
6502
|
+
const resp = await this.doJSON(
|
|
6503
|
+
"GET",
|
|
6504
|
+
`/api/distribution/finance/corporate-transfer/my`,
|
|
6505
|
+
null,
|
|
6506
|
+
signal
|
|
6507
|
+
);
|
|
6508
|
+
return resp.data ?? [];
|
|
6509
|
+
};
|
|
6510
|
+
|
|
6091
6511
|
exports.AgentRunStreamError = AgentRunStreamError;
|
|
6092
6512
|
exports.AgentRunsClient = AgentRunsClient;
|
|
6513
|
+
exports.AudienceEnum = AudienceEnum;
|
|
6514
|
+
exports.BillingModeEnum = BillingModeEnum;
|
|
6093
6515
|
exports.Client = Client;
|
|
6094
6516
|
exports.ComplianceClient = ComplianceClient;
|
|
6095
6517
|
exports.CompliancePollError = CompliancePollError;
|
|
@@ -6136,7 +6558,9 @@ exports.FilterStatusUnknown = FilterStatusUnknown;
|
|
|
6136
6558
|
exports.IdempotencyKeyHeader = IdempotencyKeyHeader;
|
|
6137
6559
|
exports.InMemoryTokenStore = InMemoryTokenStore;
|
|
6138
6560
|
exports.LocalStorageTokenStore = LocalStorageTokenStore;
|
|
6561
|
+
exports.ProductFamilyEnum = ProductFamilyEnum;
|
|
6139
6562
|
exports.RETRY_ADVICE_REASONS = RETRY_ADVICE_REASONS;
|
|
6563
|
+
exports.RegionScopeEnum = RegionScopeEnum;
|
|
6140
6564
|
exports.ScopeAI = ScopeAI;
|
|
6141
6565
|
exports.ScopeAccount = ScopeAccount;
|
|
6142
6566
|
exports.ScopeComplianceContractSigningRead = ScopeComplianceContractSigningRead;
|
|
@@ -6199,7 +6623,9 @@ exports.getAdapterForModel = getAdapterForModel;
|
|
|
6199
6623
|
exports.isBillingConfirmable = isBillingConfirmable;
|
|
6200
6624
|
exports.isComplianceBusinessError = isComplianceBusinessError;
|
|
6201
6625
|
exports.isComplianceTerminalError = isComplianceTerminalError;
|
|
6626
|
+
exports.isSSECommentLine = isSSECommentLine;
|
|
6202
6627
|
exports.isSSLError = isSSLError;
|
|
6628
|
+
exports.maxEndUserIdLength = maxEndUserIdLength;
|
|
6203
6629
|
exports.modelScopes = modelScopes;
|
|
6204
6630
|
exports.modelSupportsImageInput = modelSupportsImageInput;
|
|
6205
6631
|
exports.modelSupportsInputModality = modelSupportsInputModality;
|
|
@@ -6220,5 +6646,6 @@ exports.sanitize = sanitize_exports;
|
|
|
6220
6646
|
exports.skillScopes = skillScopes;
|
|
6221
6647
|
exports.tokenSetIsExpired = tokenSetIsExpired;
|
|
6222
6648
|
exports.uniqueMerge = uniqueMerge;
|
|
6649
|
+
exports.validateEndUserId = validateEndUserId;
|
|
6223
6650
|
//# sourceMappingURL=index.cjs.map
|
|
6224
6651
|
//# sourceMappingURL=index.cjs.map
|