@bpinternal/const 0.0.1
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.cjs +99 -0
- package/dist/index.mjs +71 -0
- package/package.json +25 -0
- package/src/index.ts +1 -0
- package/src/prefixes.ts +74 -0
- package/test/prefix.test.ts +12 -0
- package/tsconfig.json +19 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
objectToPrefixMap: () => objectToPrefixMap,
|
|
24
|
+
prefixToObjectMap: () => prefixToObjectMap
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
|
|
28
|
+
// src/prefixes.ts
|
|
29
|
+
var prefixToObjectMap = {
|
|
30
|
+
action: "action",
|
|
31
|
+
anlytic: "analytics",
|
|
32
|
+
audit: "audit",
|
|
33
|
+
bak: "botApiKey",
|
|
34
|
+
bot: "bot",
|
|
35
|
+
card: "card",
|
|
36
|
+
cfg: "configuration",
|
|
37
|
+
channel: "channel",
|
|
38
|
+
conv: "conversation",
|
|
39
|
+
evt: "event",
|
|
40
|
+
file: "file",
|
|
41
|
+
flow: "flow",
|
|
42
|
+
iak: "integrationApiKey",
|
|
43
|
+
integ: "integration",
|
|
44
|
+
kb: "knowledgeBase",
|
|
45
|
+
limit: "limit",
|
|
46
|
+
media: "media",
|
|
47
|
+
msg: "message",
|
|
48
|
+
node: "node",
|
|
49
|
+
pat: "personalAccessToken",
|
|
50
|
+
quota: "quota",
|
|
51
|
+
recevt: "recurringEvent",
|
|
52
|
+
sandbox: "sandbox",
|
|
53
|
+
schema: "schema",
|
|
54
|
+
state: "state",
|
|
55
|
+
table: "table",
|
|
56
|
+
tag: "tag",
|
|
57
|
+
usage: "usage",
|
|
58
|
+
user: "user",
|
|
59
|
+
webhook: "webhook",
|
|
60
|
+
wkspace: "workspace"
|
|
61
|
+
};
|
|
62
|
+
var objectToPrefixMap = {
|
|
63
|
+
action: "action",
|
|
64
|
+
analytics: "anlytic",
|
|
65
|
+
audit: "audit",
|
|
66
|
+
bot: "bot",
|
|
67
|
+
botApiKey: "bak",
|
|
68
|
+
card: "card",
|
|
69
|
+
channel: "channel",
|
|
70
|
+
configuration: "cfg",
|
|
71
|
+
conversation: "conv",
|
|
72
|
+
event: "evt",
|
|
73
|
+
file: "file",
|
|
74
|
+
flow: "flow",
|
|
75
|
+
integration: "integ",
|
|
76
|
+
integrationApiKey: "iak",
|
|
77
|
+
knowledgeBase: "kb",
|
|
78
|
+
limit: "limit",
|
|
79
|
+
media: "media",
|
|
80
|
+
message: "msg",
|
|
81
|
+
node: "node",
|
|
82
|
+
personalAccessToken: "pat",
|
|
83
|
+
quota: "quota",
|
|
84
|
+
recurringEvent: "recevt",
|
|
85
|
+
sandbox: "sandbox",
|
|
86
|
+
schema: "schema",
|
|
87
|
+
state: "state",
|
|
88
|
+
table: "table",
|
|
89
|
+
tag: "tag",
|
|
90
|
+
usage: "usage",
|
|
91
|
+
user: "user",
|
|
92
|
+
webhook: "webhook",
|
|
93
|
+
workspace: "wkspace"
|
|
94
|
+
};
|
|
95
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
+
0 && (module.exports = {
|
|
97
|
+
objectToPrefixMap,
|
|
98
|
+
prefixToObjectMap
|
|
99
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/prefixes.ts
|
|
2
|
+
var prefixToObjectMap = {
|
|
3
|
+
action: "action",
|
|
4
|
+
anlytic: "analytics",
|
|
5
|
+
audit: "audit",
|
|
6
|
+
bak: "botApiKey",
|
|
7
|
+
bot: "bot",
|
|
8
|
+
card: "card",
|
|
9
|
+
cfg: "configuration",
|
|
10
|
+
channel: "channel",
|
|
11
|
+
conv: "conversation",
|
|
12
|
+
evt: "event",
|
|
13
|
+
file: "file",
|
|
14
|
+
flow: "flow",
|
|
15
|
+
iak: "integrationApiKey",
|
|
16
|
+
integ: "integration",
|
|
17
|
+
kb: "knowledgeBase",
|
|
18
|
+
limit: "limit",
|
|
19
|
+
media: "media",
|
|
20
|
+
msg: "message",
|
|
21
|
+
node: "node",
|
|
22
|
+
pat: "personalAccessToken",
|
|
23
|
+
quota: "quota",
|
|
24
|
+
recevt: "recurringEvent",
|
|
25
|
+
sandbox: "sandbox",
|
|
26
|
+
schema: "schema",
|
|
27
|
+
state: "state",
|
|
28
|
+
table: "table",
|
|
29
|
+
tag: "tag",
|
|
30
|
+
usage: "usage",
|
|
31
|
+
user: "user",
|
|
32
|
+
webhook: "webhook",
|
|
33
|
+
wkspace: "workspace"
|
|
34
|
+
};
|
|
35
|
+
var objectToPrefixMap = {
|
|
36
|
+
action: "action",
|
|
37
|
+
analytics: "anlytic",
|
|
38
|
+
audit: "audit",
|
|
39
|
+
bot: "bot",
|
|
40
|
+
botApiKey: "bak",
|
|
41
|
+
card: "card",
|
|
42
|
+
channel: "channel",
|
|
43
|
+
configuration: "cfg",
|
|
44
|
+
conversation: "conv",
|
|
45
|
+
event: "evt",
|
|
46
|
+
file: "file",
|
|
47
|
+
flow: "flow",
|
|
48
|
+
integration: "integ",
|
|
49
|
+
integrationApiKey: "iak",
|
|
50
|
+
knowledgeBase: "kb",
|
|
51
|
+
limit: "limit",
|
|
52
|
+
media: "media",
|
|
53
|
+
message: "msg",
|
|
54
|
+
node: "node",
|
|
55
|
+
personalAccessToken: "pat",
|
|
56
|
+
quota: "quota",
|
|
57
|
+
recurringEvent: "recevt",
|
|
58
|
+
sandbox: "sandbox",
|
|
59
|
+
schema: "schema",
|
|
60
|
+
state: "state",
|
|
61
|
+
table: "table",
|
|
62
|
+
tag: "tag",
|
|
63
|
+
usage: "usage",
|
|
64
|
+
user: "user",
|
|
65
|
+
webhook: "webhook",
|
|
66
|
+
workspace: "wkspace"
|
|
67
|
+
};
|
|
68
|
+
export {
|
|
69
|
+
objectToPrefixMap,
|
|
70
|
+
prefixToObjectMap
|
|
71
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bpinternal/const",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Constant utilities for Botpress",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"browser": "./dist/index.mjs",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"type-check": "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"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"vitest": "^0.34.4"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@tsconfig/node18-strictest": "^1.0.0",
|
|
21
|
+
"esbuild": "^0.19.2",
|
|
22
|
+
"ts-node": "^10.9.1",
|
|
23
|
+
"typescript": "^5.1.6"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './prefixes';
|
package/src/prefixes.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export const prefixToObjectMap = {
|
|
2
|
+
action: 'action',
|
|
3
|
+
anlytic: 'analytics',
|
|
4
|
+
audit: 'audit',
|
|
5
|
+
bak: 'botApiKey',
|
|
6
|
+
bot: 'bot',
|
|
7
|
+
card: 'card',
|
|
8
|
+
cfg: 'configuration',
|
|
9
|
+
channel: 'channel',
|
|
10
|
+
conv: 'conversation',
|
|
11
|
+
evt: 'event',
|
|
12
|
+
file: 'file',
|
|
13
|
+
flow: 'flow',
|
|
14
|
+
iak: 'integrationApiKey',
|
|
15
|
+
integ: 'integration',
|
|
16
|
+
kb: 'knowledgeBase',
|
|
17
|
+
limit: 'limit',
|
|
18
|
+
media: 'media',
|
|
19
|
+
msg: 'message',
|
|
20
|
+
node: 'node',
|
|
21
|
+
pat: 'personalAccessToken',
|
|
22
|
+
quota: 'quota',
|
|
23
|
+
recevt: 'recurringEvent',
|
|
24
|
+
sandbox: 'sandbox',
|
|
25
|
+
schema: 'schema',
|
|
26
|
+
state: 'state',
|
|
27
|
+
table: 'table',
|
|
28
|
+
tag: 'tag',
|
|
29
|
+
usage: 'usage',
|
|
30
|
+
user: 'user',
|
|
31
|
+
webhook: 'webhook',
|
|
32
|
+
wkspace: 'workspace'
|
|
33
|
+
} as const
|
|
34
|
+
|
|
35
|
+
export const objectToPrefixMap: Reverser<typeof prefixToObjectMap> = {
|
|
36
|
+
action: 'action',
|
|
37
|
+
analytics: 'anlytic',
|
|
38
|
+
audit: 'audit',
|
|
39
|
+
bot: 'bot',
|
|
40
|
+
botApiKey: 'bak',
|
|
41
|
+
card: 'card',
|
|
42
|
+
channel: 'channel',
|
|
43
|
+
configuration: 'cfg',
|
|
44
|
+
conversation: 'conv',
|
|
45
|
+
event: 'evt',
|
|
46
|
+
file: 'file',
|
|
47
|
+
flow: 'flow',
|
|
48
|
+
integration: 'integ',
|
|
49
|
+
integrationApiKey: 'iak',
|
|
50
|
+
knowledgeBase: 'kb',
|
|
51
|
+
limit: 'limit',
|
|
52
|
+
media: 'media',
|
|
53
|
+
message: 'msg',
|
|
54
|
+
node: 'node',
|
|
55
|
+
personalAccessToken: 'pat',
|
|
56
|
+
quota: 'quota',
|
|
57
|
+
recurringEvent: 'recevt',
|
|
58
|
+
sandbox: 'sandbox',
|
|
59
|
+
schema: 'schema',
|
|
60
|
+
state: 'state',
|
|
61
|
+
table: 'table',
|
|
62
|
+
tag: 'tag',
|
|
63
|
+
usage: 'usage',
|
|
64
|
+
user: 'user',
|
|
65
|
+
webhook: 'webhook',
|
|
66
|
+
workspace: 'wkspace',
|
|
67
|
+
} as const
|
|
68
|
+
|
|
69
|
+
export type Prefixes = typeof objectToPrefixMap[keyof typeof objectToPrefixMap]
|
|
70
|
+
export type Objects = keyof typeof objectToPrefixMap
|
|
71
|
+
|
|
72
|
+
type Reverser<T extends Record<PropertyKey, PropertyKey>> = {
|
|
73
|
+
[P in keyof T as T[P]]: P
|
|
74
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { prefixToObjectMap } from '../src'
|
|
3
|
+
|
|
4
|
+
describe('prefix', () => {
|
|
5
|
+
it('should be at most 7 characters long', () => {
|
|
6
|
+
const keys = Object.keys(prefixToObjectMap)
|
|
7
|
+
|
|
8
|
+
for (const key of keys) {
|
|
9
|
+
expect(key.length, `Prefix "${key}" is too long`).toBeLessThanOrEqual(7)
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
})
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@tsconfig/node18-strictest/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"rootDir": "src",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"composite": true,
|
|
8
|
+
"incremental": true,
|
|
9
|
+
"exactOptionalPropertyTypes": false,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"noPropertyAccessFromIndexSignature": false,
|
|
12
|
+
"noUnusedLocals": false,
|
|
13
|
+
"importsNotUsedAsValues": "remove",
|
|
14
|
+
"noImplicitOverride": false,
|
|
15
|
+
"checkJs": false
|
|
16
|
+
},
|
|
17
|
+
"exclude": ["node_modules"],
|
|
18
|
+
"include": ["src/**/*"]
|
|
19
|
+
}
|