@bpinternal/const 0.2.2 → 0.3.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/tags.js ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tags = void 0;
4
+ exports.Tags = {
5
+ bot: {},
6
+ conversation: {
7
+ upstream: {
8
+ description: 'Used for HITL as a convention. The upstream conversation ID, ie. the conversation ID of the original conversation',
9
+ },
10
+ downstream: {
11
+ description: 'Used for HITL as a convention. The downstream conversation ID, ie. the conversation ID of conversation in HITL channel',
12
+ },
13
+ },
14
+ message: {
15
+ origin: {
16
+ description: 'The origin location of the message in the bot, eg. "workflow://[id]/node/[id]"',
17
+ },
18
+ iteration: {
19
+ description: 'The LLMz iteration ID of the message, for tracking and debugging purposes',
20
+ },
21
+ },
22
+ event: {},
23
+ workflow: {},
24
+ user: {},
25
+ file: {
26
+ system: {
27
+ type: 'boolean',
28
+ description: 'System files are managed by Botpress and should not be modified',
29
+ },
30
+ purpose: {
31
+ description: 'The purpose of the file, eg. "swap"',
32
+ },
33
+ source: {
34
+ description: 'The source of the file, eg. "knowledge-base"',
35
+ },
36
+ kbId: {
37
+ description: 'The ID of the knowledge base',
38
+ },
39
+ favicon: {
40
+ description: 'The favicon URL to display for the file, eg. "https://example.com/favicon.ico"',
41
+ },
42
+ pageUrl: {
43
+ description: 'The original page URL of the file, eg. "https://example.com/page"',
44
+ },
45
+ integrationName: {
46
+ description: 'The name of the integration that created the file',
47
+ },
48
+ webchatInjectConfigVersion: {
49
+ description: 'The version of the webchat inject configuration (used by the dashboard)',
50
+ },
51
+ },
52
+ table: {
53
+ system: {
54
+ type: 'boolean',
55
+ description: 'System tables are managed by Botpress and should not be modified',
56
+ },
57
+ 'x-studio-title': {
58
+ description: 'Overrides the table title in the Studio',
59
+ },
60
+ 'x-studio-readonly': {
61
+ type: 'boolean',
62
+ description: 'Prevents the table from being modified by the user in the Studio',
63
+ },
64
+ 'x-studio-icon': {
65
+ description: 'Overrides the table icon in the Studio. The value can be a lucide icon URL, eg. "lucide://atom"',
66
+ },
67
+ 'x-studio-color': {
68
+ description: 'Overrides the table color in the Studio.',
69
+ },
70
+ 'x-studio-folder': {
71
+ description: 'Groups the table in a folder in the Studio',
72
+ },
73
+ 'x-studio-deletable': {
74
+ type: 'boolean',
75
+ description: 'Prevents the table from being deleted by the user in the Studio',
76
+ },
77
+ },
78
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Usage metadata definitions for v4 billing system
3
+ * These define the dimensions we want to track for each feature
4
+ */
5
+ export type UsageEvent = {
6
+ transactionId: string;
7
+ amount: number;
8
+ feature: string;
9
+ workspaceId: string;
10
+ timestamp: number;
11
+ meta: Record<string, unknown>;
12
+ };
13
+ export type UsageMetadataConfig = {
14
+ feature: string;
15
+ dimensions: Record<string, {
16
+ description: string;
17
+ required: boolean;
18
+ type: 'string' | 'number' | 'boolean';
19
+ }>;
20
+ };
21
+ export declare const usageMetadataConfigs: Record<string, UsageMetadataConfig>;
22
+ export declare const validateUsageEvent: (event: UsageEvent) => boolean;
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ /**
3
+ * Usage metadata definitions for v4 billing system
4
+ * These define the dimensions we want to track for each feature
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.validateUsageEvent = exports.usageMetadataConfigs = void 0;
8
+ exports.usageMetadataConfigs = {
9
+ incoming_messages_events: {
10
+ feature: 'incoming_messages_events',
11
+ dimensions: {
12
+ botId: {
13
+ description: 'The ID of the bot that processed the message/event',
14
+ required: true,
15
+ type: 'string',
16
+ },
17
+ type: {
18
+ description: 'Whether this is a message or an event',
19
+ required: true,
20
+ type: 'string',
21
+ },
22
+ channel: {
23
+ description: 'The channel where the message/event originated',
24
+ required: false,
25
+ type: 'string',
26
+ },
27
+ },
28
+ },
29
+ integration_spend: {
30
+ feature: 'integration_spend',
31
+ dimensions: {
32
+ botId: {
33
+ description: 'The ID of the bot that used the integration',
34
+ required: true,
35
+ type: 'string',
36
+ },
37
+ integrationVersionId: {
38
+ description: 'The version ID of the integration used',
39
+ required: true,
40
+ type: 'string',
41
+ },
42
+ actionName: {
43
+ description: 'The specific action that was called',
44
+ required: true,
45
+ type: 'string',
46
+ },
47
+ provider: {
48
+ description: 'The provider of the integration (e.g., openai, anthropic)',
49
+ required: false,
50
+ type: 'string',
51
+ },
52
+ model: {
53
+ description: 'The specific model used (for AI integrations)',
54
+ required: false,
55
+ type: 'string',
56
+ },
57
+ },
58
+ },
59
+ table_rows: {
60
+ feature: 'table_rows',
61
+ dimensions: {
62
+ botId: {
63
+ description: 'The ID of the bot that owns the table',
64
+ required: true,
65
+ type: 'string',
66
+ },
67
+ tableId: {
68
+ description: 'The ID of the table',
69
+ required: true,
70
+ type: 'string',
71
+ },
72
+ operation: {
73
+ description: 'The operation performed (create, update, delete)',
74
+ required: true,
75
+ type: 'string',
76
+ },
77
+ },
78
+ },
79
+ file_storage: {
80
+ feature: 'file_storage',
81
+ dimensions: {
82
+ botId: {
83
+ description: 'The ID of the bot that owns the file',
84
+ required: true,
85
+ type: 'string',
86
+ },
87
+ fileId: {
88
+ description: 'The ID of the file',
89
+ required: true,
90
+ type: 'string',
91
+ },
92
+ operation: {
93
+ description: 'The operation performed (upload, delete)',
94
+ required: true,
95
+ type: 'string',
96
+ },
97
+ fileType: {
98
+ description: 'The type/extension of the file',
99
+ required: false,
100
+ type: 'string',
101
+ },
102
+ },
103
+ },
104
+ vector_db_storage: {
105
+ feature: 'vector_db_storage',
106
+ dimensions: {
107
+ botId: {
108
+ description: 'The ID of the bot that owns the vectors',
109
+ required: true,
110
+ type: 'string',
111
+ },
112
+ collectionId: {
113
+ description: 'The ID of the vector collection',
114
+ required: true,
115
+ type: 'string',
116
+ },
117
+ operation: {
118
+ description: 'The operation performed (insert, delete)',
119
+ required: true,
120
+ type: 'string',
121
+ },
122
+ },
123
+ },
124
+ };
125
+ const validateUsageEvent = (event) => {
126
+ const config = exports.usageMetadataConfigs[event.feature];
127
+ if (!config) {
128
+ return false;
129
+ }
130
+ // Check required dimensions
131
+ for (const [dimName, dimConfig] of Object.entries(config.dimensions)) {
132
+ if (dimConfig.required && !(dimName in event.meta)) {
133
+ return false;
134
+ }
135
+ }
136
+ return true;
137
+ };
138
+ exports.validateUsageEvent = validateUsageEvent;
package/package.json CHANGED
@@ -1,29 +1,19 @@
1
1
  {
2
2
  "name": "@bpinternal/const",
3
- "version": "0.2.2",
4
- "description": "Constant utilities for Botpress",
5
- "main": "./dist/index.cjs",
6
- "browser": "./dist/index.mjs",
7
- "types": "./src/index.ts",
8
- "license": "MIT",
3
+ "version": "0.3.0",
4
+ "description": "Shared constants for Skynet billing refactor (vendored copy of upstream packages/const)",
5
+ "license": "UNLICENSED",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
9
8
  "scripts": {
10
- "check:type": "tsc --noEmit",
11
- "build:nodejs": "esbuild src/index.ts --bundle --platform=node --target=node16 --outfile=dist/index.cjs",
12
- "build:browser": "esbuild src/index.ts --bundle --platform=browser --target=es2017 --format=esm --outfile=dist/index.mjs",
13
- "build": "npm run build:nodejs && npm run build:browser",
14
- "test": "vitest run"
9
+ "build": "tsc -b tsconfig.json",
10
+ "dev": "tsc -w",
11
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
15
12
  },
16
- "dependencies": {},
13
+ "files": [
14
+ "dist"
15
+ ],
17
16
  "devDependencies": {
18
- "@tsconfig/node18-strictest": "^1.0.0",
19
- "esbuild": "^0.25.0",
20
- "ts-node": "^10.9.1",
21
- "typescript": "5.8.3",
22
- "vitest": "1.6.0"
23
- },
24
- "engines": {
25
- "node": ">=16.0.0",
26
- "pnpm": "8.6.2"
27
- },
28
- "packageManager": "pnpm@8.6.2"
17
+ "typescript": "^5.3.3"
18
+ }
29
19
  }