@botpress/api 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gen/state.d.ts +288 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +414 -32
- package/package.json +2 -2
- package/src/gen/metadata.json +1 -1
- package/src/gen/openapi.json +1 -1
- package/src/gen/state.ts +360 -2
package/dist/index.js
CHANGED
|
@@ -68575,7 +68575,7 @@ var require_api2 = __commonJS({
|
|
|
68575
68575
|
var QUOTE$1 = '"';
|
|
68576
68576
|
var SLASH = "/";
|
|
68577
68577
|
var STAR = "*";
|
|
68578
|
-
var
|
|
68578
|
+
var DEFAULT_OPTIONS2 = {
|
|
68579
68579
|
comments: false,
|
|
68580
68580
|
ranges: false
|
|
68581
68581
|
};
|
|
@@ -68599,7 +68599,7 @@ var require_api2 = __commonJS({
|
|
|
68599
68599
|
}
|
|
68600
68600
|
function tokenize(text, options) {
|
|
68601
68601
|
options = Object.freeze({
|
|
68602
|
-
...
|
|
68602
|
+
...DEFAULT_OPTIONS2,
|
|
68603
68603
|
...options
|
|
68604
68604
|
});
|
|
68605
68605
|
let offset = -1;
|
|
@@ -258872,7 +258872,7 @@ __export(src_exports, {
|
|
|
258872
258872
|
});
|
|
258873
258873
|
module.exports = __toCommonJS(src_exports);
|
|
258874
258874
|
|
|
258875
|
-
// ../../node_modules/.pnpm/@bpinternal+opapi@0.
|
|
258875
|
+
// ../../node_modules/.pnpm/@bpinternal+opapi@0.5.1_openapi-types@12.1.0/node_modules/@bpinternal/opapi/dist/index.mjs
|
|
258876
258876
|
var import_zod_openapi = __toESM(require_src(), 1);
|
|
258877
258877
|
var import_zod_openapi2 = __toESM(require_src(), 1);
|
|
258878
258878
|
var import_chalk = __toESM(require_source(), 1);
|
|
@@ -258916,7 +258916,7 @@ var title = (str2) => {
|
|
|
258916
258916
|
return str2.split(/(?=[A-Z])|[\.\-\s_]/).map((s) => s.trim()).filter((s) => !!s).map((s) => capitalize(s.toLowerCase())).join(" ");
|
|
258917
258917
|
};
|
|
258918
258918
|
|
|
258919
|
-
// ../../node_modules/.pnpm/@bpinternal+opapi@0.
|
|
258919
|
+
// ../../node_modules/.pnpm/@bpinternal+opapi@0.5.1_openapi-types@12.1.0/node_modules/@bpinternal/opapi/dist/index.mjs
|
|
258920
258920
|
var import_decompress = __toESM(require_decompress(), 1);
|
|
258921
258921
|
var import_fs2 = __toESM(require("fs"), 1);
|
|
258922
258922
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
@@ -265905,7 +265905,7 @@ async function openapiTS(schema3, options = {}) {
|
|
|
265905
265905
|
}
|
|
265906
265906
|
var dist_default = openapiTS;
|
|
265907
265907
|
|
|
265908
|
-
// ../../node_modules/.pnpm/@bpinternal+opapi@0.
|
|
265908
|
+
// ../../node_modules/.pnpm/@bpinternal+opapi@0.5.1_openapi-types@12.1.0/node_modules/@bpinternal/opapi/dist/index.mjs
|
|
265909
265909
|
var import_zod_openapi3 = __toESM(require_src(), 1);
|
|
265910
265910
|
var import_openapi3_ts = __toESM(require_dist3(), 1);
|
|
265911
265911
|
var import_verror2 = __toESM(require_verror(), 1);
|
|
@@ -269500,7 +269500,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
269500
269500
|
ZodError
|
|
269501
269501
|
});
|
|
269502
269502
|
|
|
269503
|
-
// ../../node_modules/.pnpm/@bpinternal+opapi@0.
|
|
269503
|
+
// ../../node_modules/.pnpm/@bpinternal+opapi@0.5.1_openapi-types@12.1.0/node_modules/@bpinternal/opapi/dist/index.mjs
|
|
269504
269504
|
var import_openapi_parser = __toESM(require_lib11(), 1);
|
|
269505
269505
|
var import_json_schema_to_typescript = __toESM(require_src3(), 1);
|
|
269506
269506
|
var import_zod_openapi4 = __toESM(require_src(), 1);
|
|
@@ -424918,7 +424918,7 @@ function generateErrors(errors) {
|
|
|
424918
424918
|
const types2 = errors.map((error2) => error2.type);
|
|
424919
424919
|
return `
|
|
424920
424920
|
import crypto from 'crypto'
|
|
424921
|
-
|
|
424921
|
+
|
|
424922
424922
|
const codes = {
|
|
424923
424923
|
${Object.entries(codes).map(([name, code]) => ` ${name}: ${code},`).join("\n")}
|
|
424924
424924
|
} as const
|
|
@@ -424961,6 +424961,10 @@ abstract class BaseApiError<Code extends ErrorCode, Type extends string, Descrip
|
|
|
424961
424961
|
}
|
|
424962
424962
|
}
|
|
424963
424963
|
|
|
424964
|
+
format() {
|
|
424965
|
+
return \`[\${this.type}] \${this.message} (Error ID: \${this.id})\`
|
|
424966
|
+
}
|
|
424967
|
+
|
|
424964
424968
|
toJSON() {
|
|
424965
424969
|
return {
|
|
424966
424970
|
id: this.id,
|
|
@@ -424969,7 +424973,7 @@ abstract class BaseApiError<Code extends ErrorCode, Type extends string, Descrip
|
|
|
424969
424973
|
message: this.message,
|
|
424970
424974
|
}
|
|
424971
424975
|
}
|
|
424972
|
-
|
|
424976
|
+
|
|
424973
424977
|
static generateId() {
|
|
424974
424978
|
const randomSuffixByteLength = 4
|
|
424975
424979
|
const randomHexSuffix = Array.from(cryptoLib.getRandomValues(new Uint8Array(randomSuffixByteLength)))
|
|
@@ -425012,7 +425016,7 @@ function getApiErrorFromObject(err: any) {
|
|
|
425012
425016
|
if (!ErrorClass) {
|
|
425013
425017
|
return new UnknownError(\`An unclassified API error occurred: \${err.message} (Type: \${err.type}, Code: \${err.code})\`)
|
|
425014
425018
|
}
|
|
425015
|
-
|
|
425019
|
+
|
|
425016
425020
|
return new ErrorClass(err.message, undefined, <string>err.id || 'UNKNOWN') // If error ID was not received do not pass undefined to generate a new one, flag it as UNKNOWN so we can fix the issue.
|
|
425017
425021
|
}
|
|
425018
425022
|
|
|
@@ -425077,12 +425081,23 @@ function removeFromArray(array, item) {
|
|
|
425077
425081
|
array.splice(index, 1);
|
|
425078
425082
|
}
|
|
425079
425083
|
}
|
|
425080
|
-
|
|
425081
|
-
const
|
|
425082
|
-
|
|
425084
|
+
function uniqueBy(array, k) {
|
|
425085
|
+
const seen = /* @__PURE__ */ new Set();
|
|
425086
|
+
return array.filter((item) => {
|
|
425087
|
+
const v = item[k];
|
|
425088
|
+
if (seen.has(v)) {
|
|
425089
|
+
return false;
|
|
425090
|
+
}
|
|
425091
|
+
seen.add(v);
|
|
425092
|
+
return true;
|
|
425093
|
+
});
|
|
425094
|
+
}
|
|
425095
|
+
var generateSchemaFromZod = (zodRef, opts) => {
|
|
425096
|
+
const jsonSchema = (0, import_zod_openapi3.generateSchema)(zodRef, opts == null ? void 0 : opts.useOutput);
|
|
425097
|
+
formatJsonSchema(jsonSchema, (opts == null ? void 0 : opts.allowUnions) ?? false);
|
|
425083
425098
|
return jsonSchema;
|
|
425084
425099
|
};
|
|
425085
|
-
var formatJsonSchema = (jsonSchema) => {
|
|
425100
|
+
var formatJsonSchema = (jsonSchema, allowUnions) => {
|
|
425086
425101
|
if (jsonSchema.type === "object") {
|
|
425087
425102
|
if (jsonSchema.additionalProperties === void 0) {
|
|
425088
425103
|
jsonSchema.additionalProperties = false;
|
|
@@ -425094,11 +425109,11 @@ var formatJsonSchema = (jsonSchema) => {
|
|
|
425094
425109
|
delete jsonSchema.required;
|
|
425095
425110
|
}
|
|
425096
425111
|
if (typeof jsonSchema.additionalProperties === "object") {
|
|
425097
|
-
formatJsonSchema(jsonSchema.additionalProperties);
|
|
425112
|
+
formatJsonSchema(jsonSchema.additionalProperties, allowUnions);
|
|
425098
425113
|
}
|
|
425099
|
-
Object.entries(jsonSchema.properties ?? {}).forEach(([_, value]) => formatJsonSchema(value));
|
|
425114
|
+
Object.entries(jsonSchema.properties ?? {}).forEach(([_, value]) => formatJsonSchema(value, allowUnions));
|
|
425100
425115
|
}
|
|
425101
|
-
if (jsonSchema.allOf || jsonSchema.anyOf || jsonSchema.oneOf) {
|
|
425116
|
+
if (!allowUnions && (jsonSchema.allOf || jsonSchema.anyOf || jsonSchema.oneOf)) {
|
|
425102
425117
|
throw new Error("allOf, anyOf and oneOf are not supported");
|
|
425103
425118
|
}
|
|
425104
425119
|
};
|
|
@@ -425125,6 +425140,7 @@ var objects;
|
|
|
425125
425140
|
return result;
|
|
425126
425141
|
};
|
|
425127
425142
|
})(objects || (objects = {}));
|
|
425143
|
+
var DEFAULT_OPTIONS = { allowUnions: false };
|
|
425128
425144
|
var unknownError = {
|
|
425129
425145
|
status: 500,
|
|
425130
425146
|
type: "Unknown",
|
|
@@ -425142,7 +425158,8 @@ function isOperationWithBodyProps(operation) {
|
|
|
425142
425158
|
} else
|
|
425143
425159
|
return false;
|
|
425144
425160
|
}
|
|
425145
|
-
function createState(props) {
|
|
425161
|
+
function createState(props, opts = {}) {
|
|
425162
|
+
const options = { ...DEFAULT_OPTIONS, ...opts };
|
|
425146
425163
|
const schemaEntries = props.schemas ? Object.entries(props.schemas).map(([name, data]) => ({
|
|
425147
425164
|
name,
|
|
425148
425165
|
schema: data.schema,
|
|
@@ -425175,17 +425192,14 @@ function createState(props) {
|
|
|
425175
425192
|
}
|
|
425176
425193
|
schemas[name] = {
|
|
425177
425194
|
section: schemaEntry.section,
|
|
425178
|
-
schema: generateSchemaFromZod(schemaEntry.schema)
|
|
425195
|
+
schema: generateSchemaFromZod(schemaEntry.schema, options)
|
|
425179
425196
|
};
|
|
425180
425197
|
refs.schemas[name] = true;
|
|
425181
425198
|
});
|
|
425182
|
-
const
|
|
425183
|
-
const
|
|
425199
|
+
const userErrors = props.errors ?? [];
|
|
425200
|
+
const defaultErrors = [unknownError, internalError];
|
|
425201
|
+
const errors = uniqueBy([...defaultErrors, ...userErrors], "type");
|
|
425184
425202
|
errors.forEach((error2) => {
|
|
425185
|
-
if (existingErrors.has(error2.type)) {
|
|
425186
|
-
throw new import_verror3.VError(`Error ${error2.type} already exists`);
|
|
425187
|
-
}
|
|
425188
|
-
existingErrors.add(error2.type);
|
|
425189
425203
|
if (!isCapitalAlphabetical(error2.type)) {
|
|
425190
425204
|
throw new import_verror3.VError(`Invalid error type ${error2.type}. It must be alphabetical and start with a capital letter`);
|
|
425191
425205
|
}
|
|
@@ -425204,7 +425218,8 @@ function createState(props) {
|
|
|
425204
425218
|
errors,
|
|
425205
425219
|
refs,
|
|
425206
425220
|
schemas,
|
|
425207
|
-
sections
|
|
425221
|
+
sections,
|
|
425222
|
+
options
|
|
425208
425223
|
};
|
|
425209
425224
|
}
|
|
425210
425225
|
function getRef(state2, type2, name) {
|
|
@@ -425397,6 +425412,16 @@ var composeFilesFromBlocks = (blocks, targetDirectory) => {
|
|
|
425397
425412
|
}
|
|
425398
425413
|
});
|
|
425399
425414
|
};
|
|
425415
|
+
var generateSectionsFile = (state2, targetDirectory) => {
|
|
425416
|
+
log_default.info("Generating sections file");
|
|
425417
|
+
const sections = state2.sections.map((section) => section.name);
|
|
425418
|
+
saveFile(
|
|
425419
|
+
targetDirectory,
|
|
425420
|
+
"sections.ts",
|
|
425421
|
+
`export const sections = ${JSON.stringify(sections)} as const;
|
|
425422
|
+
export type Sections = typeof sections[number];`
|
|
425423
|
+
);
|
|
425424
|
+
};
|
|
425400
425425
|
var getImportsForDependencies = (block, blocks) => {
|
|
425401
425426
|
let content = "";
|
|
425402
425427
|
if (Boolean(block.dependencies.length)) {
|
|
@@ -425574,6 +425599,7 @@ async function generateTypesBySection(state2, targetDirectory) {
|
|
|
425574
425599
|
allBlocks.push(...blocks);
|
|
425575
425600
|
}
|
|
425576
425601
|
composeFilesFromBlocks(allBlocks, targetDirectory);
|
|
425602
|
+
generateSectionsFile(state2, targetDirectory);
|
|
425577
425603
|
}
|
|
425578
425604
|
var generateServer = async (state2, dir, useExpressTypes) => {
|
|
425579
425605
|
initDirectory(dir);
|
|
@@ -425740,7 +425766,7 @@ var addOperation = (state2, operationProps) => {
|
|
|
425740
425766
|
const response = {
|
|
425741
425767
|
description: operationProps.response.description,
|
|
425742
425768
|
status: operationProps.response.status,
|
|
425743
|
-
schema: generateSchemaFromZod((0, import_zod_openapi4.extendApi)(operationProps.response.schema, { title: responseName }))
|
|
425769
|
+
schema: generateSchemaFromZod((0, import_zod_openapi4.extendApi)(operationProps.response.schema, { title: responseName }), state2.options)
|
|
425744
425770
|
};
|
|
425745
425771
|
let operation;
|
|
425746
425772
|
if (isOperationWithBodyProps(operationProps)) {
|
|
@@ -425752,7 +425778,7 @@ var addOperation = (state2, operationProps) => {
|
|
|
425752
425778
|
response,
|
|
425753
425779
|
requestBody: {
|
|
425754
425780
|
description: operationProps.requestBody.description,
|
|
425755
|
-
schema: generateSchemaFromZod((0, import_zod_openapi4.extendApi)(operationProps.requestBody.schema, { title: bodyName }))
|
|
425781
|
+
schema: generateSchemaFromZod((0, import_zod_openapi4.extendApi)(operationProps.requestBody.schema, { title: bodyName }), state2.options)
|
|
425756
425782
|
}
|
|
425757
425783
|
};
|
|
425758
425784
|
} else {
|
|
@@ -425836,6 +425862,7 @@ var exportStateAsTypescript = (state2, dir) => {
|
|
|
425836
425862
|
var schema2 = import_zod_openapi2.extendApi;
|
|
425837
425863
|
var createOpapiFromState = (state2) => {
|
|
425838
425864
|
return {
|
|
425865
|
+
getState: () => state2,
|
|
425839
425866
|
getModelRef: (name) => getRef(state2, "schemas", name),
|
|
425840
425867
|
addOperation: (operationProps) => addOperation(state2, operationProps),
|
|
425841
425868
|
exportClient: (dir = ".", openapiGeneratorEndpoint, postProcessors) => generateClient(state2, dir, openapiGeneratorEndpoint, postProcessors),
|
|
@@ -425846,8 +425873,8 @@ var createOpapiFromState = (state2) => {
|
|
|
425846
425873
|
exportErrors: (dir = ".") => generateErrorsFile(state2.errors ?? [], dir)
|
|
425847
425874
|
};
|
|
425848
425875
|
};
|
|
425849
|
-
function OpenApi(props) {
|
|
425850
|
-
const state2 = createState(props);
|
|
425876
|
+
function OpenApi(props, opts = {}) {
|
|
425877
|
+
const state2 = createState(props, opts);
|
|
425851
425878
|
return createOpapiFromState(state2);
|
|
425852
425879
|
}
|
|
425853
425880
|
((OpenApi2) => {
|
|
@@ -428322,6 +428349,206 @@ var state = {
|
|
|
428322
428349
|
}
|
|
428323
428350
|
}
|
|
428324
428351
|
},
|
|
428352
|
+
listWorkspaceUsages: {
|
|
428353
|
+
name: "listWorkspaceUsages",
|
|
428354
|
+
description: "List workspace usages",
|
|
428355
|
+
section: "workspace",
|
|
428356
|
+
method: "get",
|
|
428357
|
+
path: "/v1/admin/workspaces/{id}/usages",
|
|
428358
|
+
disableDefaultParameters: {
|
|
428359
|
+
"x-workspace-id": true
|
|
428360
|
+
},
|
|
428361
|
+
parameters: {
|
|
428362
|
+
id: {
|
|
428363
|
+
type: "string",
|
|
428364
|
+
description: "Workspace ID",
|
|
428365
|
+
in: "path"
|
|
428366
|
+
},
|
|
428367
|
+
type: {
|
|
428368
|
+
in: "query",
|
|
428369
|
+
description: "Type of usage",
|
|
428370
|
+
type: "string",
|
|
428371
|
+
enum: [
|
|
428372
|
+
"invocation_timeout",
|
|
428373
|
+
"invocation_calls",
|
|
428374
|
+
"storage_count",
|
|
428375
|
+
"bot_count",
|
|
428376
|
+
"knowledgebase_vector_count",
|
|
428377
|
+
"bot_ratelimit",
|
|
428378
|
+
"table_row_count",
|
|
428379
|
+
"workspace_member_count"
|
|
428380
|
+
],
|
|
428381
|
+
required: true
|
|
428382
|
+
},
|
|
428383
|
+
period: {
|
|
428384
|
+
in: "query",
|
|
428385
|
+
description: "Period to get",
|
|
428386
|
+
type: "string",
|
|
428387
|
+
required: false
|
|
428388
|
+
}
|
|
428389
|
+
},
|
|
428390
|
+
response: {
|
|
428391
|
+
description: "Success",
|
|
428392
|
+
schema: {
|
|
428393
|
+
type: "object",
|
|
428394
|
+
properties: {
|
|
428395
|
+
usages: {
|
|
428396
|
+
type: "array",
|
|
428397
|
+
items: {
|
|
428398
|
+
$ref: "#/components/schemas/Usage"
|
|
428399
|
+
}
|
|
428400
|
+
}
|
|
428401
|
+
},
|
|
428402
|
+
required: ["usages"],
|
|
428403
|
+
title: "listWorkspaceUsagesResponse",
|
|
428404
|
+
additionalProperties: false
|
|
428405
|
+
}
|
|
428406
|
+
}
|
|
428407
|
+
},
|
|
428408
|
+
getWorkspaceQuota: {
|
|
428409
|
+
name: "getWorkspaceQuota",
|
|
428410
|
+
description: "Get workspace quota",
|
|
428411
|
+
section: "workspace",
|
|
428412
|
+
method: "get",
|
|
428413
|
+
path: "/v1/admin/workspaces/{id}/quota",
|
|
428414
|
+
disableDefaultParameters: {
|
|
428415
|
+
"x-workspace-id": true
|
|
428416
|
+
},
|
|
428417
|
+
parameters: {
|
|
428418
|
+
id: {
|
|
428419
|
+
type: "string",
|
|
428420
|
+
description: "Workspace ID",
|
|
428421
|
+
in: "path"
|
|
428422
|
+
},
|
|
428423
|
+
type: {
|
|
428424
|
+
in: "query",
|
|
428425
|
+
description: "Type of usage",
|
|
428426
|
+
type: "string",
|
|
428427
|
+
enum: [
|
|
428428
|
+
"invocation_timeout",
|
|
428429
|
+
"invocation_calls",
|
|
428430
|
+
"storage_count",
|
|
428431
|
+
"bot_count",
|
|
428432
|
+
"knowledgebase_vector_count",
|
|
428433
|
+
"bot_ratelimit",
|
|
428434
|
+
"table_row_count",
|
|
428435
|
+
"workspace_member_count"
|
|
428436
|
+
],
|
|
428437
|
+
required: true
|
|
428438
|
+
},
|
|
428439
|
+
period: {
|
|
428440
|
+
in: "query",
|
|
428441
|
+
description: "Period to get",
|
|
428442
|
+
type: "string",
|
|
428443
|
+
required: false
|
|
428444
|
+
}
|
|
428445
|
+
},
|
|
428446
|
+
response: {
|
|
428447
|
+
description: "Success",
|
|
428448
|
+
schema: {
|
|
428449
|
+
type: "object",
|
|
428450
|
+
properties: {
|
|
428451
|
+
quota: {
|
|
428452
|
+
type: "object",
|
|
428453
|
+
properties: {
|
|
428454
|
+
period: {
|
|
428455
|
+
type: "string",
|
|
428456
|
+
description: "Period of the quota that it is applied to"
|
|
428457
|
+
},
|
|
428458
|
+
value: {
|
|
428459
|
+
type: "number",
|
|
428460
|
+
description: "Value of the quota that is used"
|
|
428461
|
+
},
|
|
428462
|
+
type: {
|
|
428463
|
+
type: "string",
|
|
428464
|
+
enum: [
|
|
428465
|
+
"invocation_timeout",
|
|
428466
|
+
"invocation_calls",
|
|
428467
|
+
"storage_count",
|
|
428468
|
+
"bot_count",
|
|
428469
|
+
"knowledgebase_vector_count",
|
|
428470
|
+
"bot_ratelimit",
|
|
428471
|
+
"table_row_count",
|
|
428472
|
+
"workspace_member_count"
|
|
428473
|
+
],
|
|
428474
|
+
description: "Usage type that can be used"
|
|
428475
|
+
}
|
|
428476
|
+
},
|
|
428477
|
+
required: ["period", "value", "type"],
|
|
428478
|
+
additionalProperties: false
|
|
428479
|
+
}
|
|
428480
|
+
},
|
|
428481
|
+
required: ["quota"],
|
|
428482
|
+
title: "getWorkspaceQuotaResponse",
|
|
428483
|
+
additionalProperties: false
|
|
428484
|
+
}
|
|
428485
|
+
}
|
|
428486
|
+
},
|
|
428487
|
+
listWorkspaceQuotas: {
|
|
428488
|
+
name: "listWorkspaceQuotas",
|
|
428489
|
+
description: "List workspace quotas",
|
|
428490
|
+
section: "workspace",
|
|
428491
|
+
method: "get",
|
|
428492
|
+
path: "/v1/admin/workspaces/{id}/quotas",
|
|
428493
|
+
disableDefaultParameters: {
|
|
428494
|
+
"x-workspace-id": true
|
|
428495
|
+
},
|
|
428496
|
+
parameters: {
|
|
428497
|
+
id: {
|
|
428498
|
+
type: "string",
|
|
428499
|
+
description: "Workspace ID",
|
|
428500
|
+
in: "path"
|
|
428501
|
+
},
|
|
428502
|
+
period: {
|
|
428503
|
+
in: "query",
|
|
428504
|
+
description: "Period to get",
|
|
428505
|
+
type: "string",
|
|
428506
|
+
required: false
|
|
428507
|
+
}
|
|
428508
|
+
},
|
|
428509
|
+
response: {
|
|
428510
|
+
description: "Success",
|
|
428511
|
+
schema: {
|
|
428512
|
+
type: "object",
|
|
428513
|
+
properties: {
|
|
428514
|
+
quotas: {
|
|
428515
|
+
type: "array",
|
|
428516
|
+
items: {
|
|
428517
|
+
type: "object",
|
|
428518
|
+
properties: {
|
|
428519
|
+
period: {
|
|
428520
|
+
type: "string",
|
|
428521
|
+
description: "Period of the quota that it is applied to"
|
|
428522
|
+
},
|
|
428523
|
+
value: {
|
|
428524
|
+
type: "number",
|
|
428525
|
+
description: "Value of the quota that is used"
|
|
428526
|
+
},
|
|
428527
|
+
type: {
|
|
428528
|
+
type: "string",
|
|
428529
|
+
enum: [
|
|
428530
|
+
"invocation_timeout",
|
|
428531
|
+
"invocation_calls",
|
|
428532
|
+
"storage_count",
|
|
428533
|
+
"bot_count",
|
|
428534
|
+
"knowledgebase_vector_count",
|
|
428535
|
+
"bot_ratelimit",
|
|
428536
|
+
"table_row_count",
|
|
428537
|
+
"workspace_member_count"
|
|
428538
|
+
],
|
|
428539
|
+
description: "Usage type that can be used"
|
|
428540
|
+
}
|
|
428541
|
+
},
|
|
428542
|
+
required: ["period", "value", "type"]
|
|
428543
|
+
}
|
|
428544
|
+
}
|
|
428545
|
+
},
|
|
428546
|
+
required: ["quotas"],
|
|
428547
|
+
title: "listWorkspaceQuotasResponse",
|
|
428548
|
+
additionalProperties: false
|
|
428549
|
+
}
|
|
428550
|
+
}
|
|
428551
|
+
},
|
|
428325
428552
|
updateWorkspace: {
|
|
428326
428553
|
name: "updateWorkspace",
|
|
428327
428554
|
description: "Update workspace",
|
|
@@ -429825,6 +430052,102 @@ var state = {
|
|
|
429825
430052
|
}
|
|
429826
430053
|
}
|
|
429827
430054
|
},
|
|
430055
|
+
getUsage: {
|
|
430056
|
+
name: "getUsage",
|
|
430057
|
+
path: "/v1/admin/usages/{id}",
|
|
430058
|
+
description: "Get usage",
|
|
430059
|
+
method: "get",
|
|
430060
|
+
section: "usage",
|
|
430061
|
+
parameters: {
|
|
430062
|
+
type: {
|
|
430063
|
+
in: "query",
|
|
430064
|
+
description: "Type of usage",
|
|
430065
|
+
type: "string",
|
|
430066
|
+
enum: [
|
|
430067
|
+
"invocation_timeout",
|
|
430068
|
+
"invocation_calls",
|
|
430069
|
+
"storage_count",
|
|
430070
|
+
"bot_count",
|
|
430071
|
+
"knowledgebase_vector_count",
|
|
430072
|
+
"bot_ratelimit",
|
|
430073
|
+
"table_row_count",
|
|
430074
|
+
"workspace_member_count"
|
|
430075
|
+
],
|
|
430076
|
+
required: true
|
|
430077
|
+
},
|
|
430078
|
+
period: {
|
|
430079
|
+
in: "query",
|
|
430080
|
+
description: "Period to get",
|
|
430081
|
+
type: "string",
|
|
430082
|
+
required: false
|
|
430083
|
+
},
|
|
430084
|
+
id: {
|
|
430085
|
+
type: "string",
|
|
430086
|
+
description: "id of a bot or a workspace depending on the usage type",
|
|
430087
|
+
in: "path"
|
|
430088
|
+
}
|
|
430089
|
+
},
|
|
430090
|
+
response: {
|
|
430091
|
+
description: "Success",
|
|
430092
|
+
schema: {
|
|
430093
|
+
type: "object",
|
|
430094
|
+
properties: {
|
|
430095
|
+
usage: {
|
|
430096
|
+
$ref: "#/components/schemas/Usage"
|
|
430097
|
+
}
|
|
430098
|
+
},
|
|
430099
|
+
required: ["usage"],
|
|
430100
|
+
title: "getUsageResponse",
|
|
430101
|
+
additionalProperties: false
|
|
430102
|
+
}
|
|
430103
|
+
}
|
|
430104
|
+
},
|
|
430105
|
+
listUsageHistory: {
|
|
430106
|
+
name: "listUsageHistory",
|
|
430107
|
+
path: "/v1/admin/usages/{id}/history",
|
|
430108
|
+
method: "get",
|
|
430109
|
+
description: "Get usage history",
|
|
430110
|
+
parameters: {
|
|
430111
|
+
type: {
|
|
430112
|
+
in: "query",
|
|
430113
|
+
description: "Type of usage",
|
|
430114
|
+
type: "string",
|
|
430115
|
+
enum: [
|
|
430116
|
+
"invocation_timeout",
|
|
430117
|
+
"invocation_calls",
|
|
430118
|
+
"storage_count",
|
|
430119
|
+
"bot_count",
|
|
430120
|
+
"knowledgebase_vector_count",
|
|
430121
|
+
"bot_ratelimit",
|
|
430122
|
+
"table_row_count",
|
|
430123
|
+
"workspace_member_count"
|
|
430124
|
+
],
|
|
430125
|
+
required: true
|
|
430126
|
+
},
|
|
430127
|
+
id: {
|
|
430128
|
+
type: "string",
|
|
430129
|
+
description: "id of a bot or a workspace depending on the usage type",
|
|
430130
|
+
in: "path"
|
|
430131
|
+
}
|
|
430132
|
+
},
|
|
430133
|
+
response: {
|
|
430134
|
+
description: "Success",
|
|
430135
|
+
schema: {
|
|
430136
|
+
type: "object",
|
|
430137
|
+
properties: {
|
|
430138
|
+
usages: {
|
|
430139
|
+
type: "array",
|
|
430140
|
+
items: {
|
|
430141
|
+
$ref: "#/components/schemas/Usage"
|
|
430142
|
+
}
|
|
430143
|
+
}
|
|
430144
|
+
},
|
|
430145
|
+
required: ["usages"],
|
|
430146
|
+
title: "listUsageHistoryResponse",
|
|
430147
|
+
additionalProperties: false
|
|
430148
|
+
}
|
|
430149
|
+
}
|
|
430150
|
+
},
|
|
429828
430151
|
introspect: {
|
|
429829
430152
|
name: "introspect",
|
|
429830
430153
|
description: "Introspect the API",
|
|
@@ -430043,7 +430366,7 @@ var state = {
|
|
|
430043
430366
|
title: "Botpress API",
|
|
430044
430367
|
description: "API for Botpress Cloud",
|
|
430045
430368
|
server: "https://api.botpress.cloud",
|
|
430046
|
-
version: "0.7.
|
|
430369
|
+
version: "0.7.3",
|
|
430047
430370
|
prefix: "v1"
|
|
430048
430371
|
},
|
|
430049
430372
|
errors: [
|
|
@@ -430143,7 +430466,7 @@ var state = {
|
|
|
430143
430466
|
description: "A payment is required to perform this request."
|
|
430144
430467
|
},
|
|
430145
430468
|
{
|
|
430146
|
-
status:
|
|
430469
|
+
status: 403,
|
|
430147
430470
|
type: "QuotaExceeded",
|
|
430148
430471
|
description: "The request exceeds the allowed quota. Quotas are a soft limit that can be increased."
|
|
430149
430472
|
},
|
|
@@ -430229,6 +430552,9 @@ var state = {
|
|
|
430229
430552
|
getBotAnalyticsResponse: true,
|
|
430230
430553
|
createWorkspaceResponse: true,
|
|
430231
430554
|
getWorkspaceResponse: true,
|
|
430555
|
+
listWorkspaceUsagesResponse: true,
|
|
430556
|
+
getWorkspaceQuotaResponse: true,
|
|
430557
|
+
listWorkspaceQuotasResponse: true,
|
|
430232
430558
|
updateWorkspaceResponse: true,
|
|
430233
430559
|
listWorkspacesResponse: true,
|
|
430234
430560
|
changeWorkspacePlanResponse: true,
|
|
@@ -430245,6 +430571,8 @@ var state = {
|
|
|
430245
430571
|
getIntegrationLogsResponse: true,
|
|
430246
430572
|
getIntegrationByNameResponse: true,
|
|
430247
430573
|
deleteIntegrationResponse: true,
|
|
430574
|
+
getUsageResponse: true,
|
|
430575
|
+
listUsageHistoryResponse: true,
|
|
430248
430576
|
introspectResponse: true,
|
|
430249
430577
|
createFileResponse: true,
|
|
430250
430578
|
getFileResponse: true,
|
|
@@ -430258,6 +430586,7 @@ var state = {
|
|
|
430258
430586
|
Workspace: true,
|
|
430259
430587
|
WorkspaceMember: true,
|
|
430260
430588
|
Account: true,
|
|
430589
|
+
Usage: true,
|
|
430261
430590
|
User: true,
|
|
430262
430591
|
Conversation: true,
|
|
430263
430592
|
Event: true,
|
|
@@ -431048,6 +431377,46 @@ var state = {
|
|
|
431048
431377
|
additionalProperties: false
|
|
431049
431378
|
}
|
|
431050
431379
|
},
|
|
431380
|
+
Usage: {
|
|
431381
|
+
section: "usage",
|
|
431382
|
+
schema: {
|
|
431383
|
+
type: "object",
|
|
431384
|
+
properties: {
|
|
431385
|
+
id: {
|
|
431386
|
+
type: "string",
|
|
431387
|
+
description: "Id of the usage that it is linked to. It can either be a workspace id or a bot id"
|
|
431388
|
+
},
|
|
431389
|
+
period: {
|
|
431390
|
+
type: "string",
|
|
431391
|
+
description: "Period of the quota that it is applied to"
|
|
431392
|
+
},
|
|
431393
|
+
value: {
|
|
431394
|
+
type: "number",
|
|
431395
|
+
description: "Value of the current usage"
|
|
431396
|
+
},
|
|
431397
|
+
quota: {
|
|
431398
|
+
type: "number",
|
|
431399
|
+
description: "Quota of the current usage"
|
|
431400
|
+
},
|
|
431401
|
+
type: {
|
|
431402
|
+
type: "string",
|
|
431403
|
+
enum: [
|
|
431404
|
+
"invocation_timeout",
|
|
431405
|
+
"invocation_calls",
|
|
431406
|
+
"storage_count",
|
|
431407
|
+
"bot_count",
|
|
431408
|
+
"knowledgebase_vector_count",
|
|
431409
|
+
"bot_ratelimit",
|
|
431410
|
+
"table_row_count",
|
|
431411
|
+
"workspace_member_count"
|
|
431412
|
+
],
|
|
431413
|
+
description: "Usage type that can be used"
|
|
431414
|
+
}
|
|
431415
|
+
},
|
|
431416
|
+
required: ["id", "period", "value", "quota", "type"],
|
|
431417
|
+
additionalProperties: false
|
|
431418
|
+
}
|
|
431419
|
+
},
|
|
431051
431420
|
User: {
|
|
431052
431421
|
section: "user",
|
|
431053
431422
|
schema: {
|
|
@@ -431439,6 +431808,9 @@ var state = {
|
|
|
431439
431808
|
operations: [
|
|
431440
431809
|
"createWorkspace",
|
|
431441
431810
|
"getWorkspace",
|
|
431811
|
+
"listWorkspaceUsages",
|
|
431812
|
+
"getWorkspaceQuota",
|
|
431813
|
+
"listWorkspaceQuotas",
|
|
431442
431814
|
"updateWorkspace",
|
|
431443
431815
|
"listWorkspaces",
|
|
431444
431816
|
"changeWorkspacePlan",
|
|
@@ -431470,8 +431842,18 @@ var state = {
|
|
|
431470
431842
|
"deletePersonalAccessToken"
|
|
431471
431843
|
],
|
|
431472
431844
|
schema: "Account"
|
|
431845
|
+
},
|
|
431846
|
+
{
|
|
431847
|
+
description: "",
|
|
431848
|
+
title: "Usage",
|
|
431849
|
+
name: "usage",
|
|
431850
|
+
operations: ["getUsage"],
|
|
431851
|
+
schema: "Usage"
|
|
431473
431852
|
}
|
|
431474
|
-
]
|
|
431853
|
+
],
|
|
431854
|
+
options: {
|
|
431855
|
+
allowUnions: false
|
|
431856
|
+
}
|
|
431475
431857
|
};
|
|
431476
431858
|
|
|
431477
431859
|
// src/index.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/api",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"zod": "^3.20.6"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@bpinternal/opapi": "0.
|
|
25
|
+
"@bpinternal/opapi": "^0.5.1"
|
|
26
26
|
}
|
|
27
27
|
}
|