@botpress/cli 4.17.14 → 4.17.16

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.
Files changed (205) hide show
  1. package/.turbo/turbo-build.log +16 -12
  2. package/bin.js +1 -1
  3. package/dist/api/bot-body.d.ts +5 -0
  4. package/dist/api/client.d.ts +50 -0
  5. package/dist/api/index.d.ts +6 -0
  6. package/dist/api/integration-body.d.ts +5 -0
  7. package/dist/api/interface-body.d.ts +7 -0
  8. package/dist/api/paging.d.ts +9 -0
  9. package/dist/api/plugin-body.d.ts +5 -0
  10. package/dist/api/retry.d.ts +2 -0
  11. package/dist/api/types.d.ts +62 -0
  12. package/dist/chat/index.d.ts +25 -0
  13. package/dist/cli.d.ts +1 -0
  14. package/dist/cli.js +51 -0
  15. package/dist/cli.js.map +7 -0
  16. package/dist/code-generation/bot-implementation/bot-implementation.d.ts +8 -0
  17. package/dist/code-generation/bot-implementation/bot-plugins/index.d.ts +7 -0
  18. package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.d.ts +13 -0
  19. package/dist/code-generation/bot-implementation/bot-typings/actions-module.d.ts +21 -0
  20. package/dist/code-generation/bot-implementation/bot-typings/events-module.d.ts +10 -0
  21. package/dist/code-generation/bot-implementation/bot-typings/index.d.ts +7 -0
  22. package/dist/code-generation/bot-implementation/bot-typings/states-module.d.ts +17 -0
  23. package/dist/code-generation/bot-implementation/bot-typings/tables-module.d.ts +10 -0
  24. package/dist/code-generation/bot-implementation/bot-typings/workflows-module.d.ts +27 -0
  25. package/dist/code-generation/bot-implementation/index.d.ts +3 -0
  26. package/dist/code-generation/consts.d.ts +5 -0
  27. package/dist/code-generation/generators.d.ts +10 -0
  28. package/dist/code-generation/index.d.ts +8 -0
  29. package/dist/code-generation/integration-implementation/index.d.ts +3 -0
  30. package/dist/code-generation/integration-implementation/integration-implementation.d.ts +7 -0
  31. package/dist/code-generation/integration-implementation/integration-secret.d.ts +8 -0
  32. package/dist/code-generation/integration-implementation/integration-typings/actions-module.d.ts +21 -0
  33. package/dist/code-generation/integration-implementation/integration-typings/channels-module.d.ts +5 -0
  34. package/dist/code-generation/integration-implementation/integration-typings/configuration-module.d.ts +7 -0
  35. package/dist/code-generation/integration-implementation/integration-typings/configurations-module.d.ts +10 -0
  36. package/dist/code-generation/integration-implementation/integration-typings/entities-module.d.ts +10 -0
  37. package/dist/code-generation/integration-implementation/integration-typings/events-module.d.ts +10 -0
  38. package/dist/code-generation/integration-implementation/integration-typings/index.d.ts +8 -0
  39. package/dist/code-generation/integration-implementation/integration-typings/states-module.d.ts +17 -0
  40. package/dist/code-generation/integration-package/index.d.ts +2 -0
  41. package/dist/code-generation/integration-package/integration-package-definition/actions-module.d.ts +21 -0
  42. package/dist/code-generation/integration-package/integration-package-definition/channels-module.d.ts +5 -0
  43. package/dist/code-generation/integration-package/integration-package-definition/configuration-module.d.ts +7 -0
  44. package/dist/code-generation/integration-package/integration-package-definition/configurations-module.d.ts +10 -0
  45. package/dist/code-generation/integration-package/integration-package-definition/entities-module.d.ts +10 -0
  46. package/dist/code-generation/integration-package/integration-package-definition/events-module.d.ts +10 -0
  47. package/dist/code-generation/integration-package/integration-package-definition/index.d.ts +8 -0
  48. package/dist/code-generation/integration-package/integration-package-definition/interfaces-module.d.ts +10 -0
  49. package/dist/code-generation/integration-package/integration-package-definition/states-module.d.ts +10 -0
  50. package/dist/code-generation/integration-package/integration-package-definition/typings.d.ts +10 -0
  51. package/dist/code-generation/interface-implementation/index.d.ts +4 -0
  52. package/dist/code-generation/interface-implementation/integration-typings/actions-module.d.ts +21 -0
  53. package/dist/code-generation/interface-implementation/integration-typings/channels-module.d.ts +5 -0
  54. package/dist/code-generation/interface-implementation/integration-typings/entities-module.d.ts +10 -0
  55. package/dist/code-generation/interface-implementation/integration-typings/events-module.d.ts +10 -0
  56. package/dist/code-generation/interface-implementation/integration-typings/index.d.ts +8 -0
  57. package/dist/code-generation/interface-package/index.d.ts +2 -0
  58. package/dist/code-generation/interface-package/interface-package-definition/actions-module.d.ts +21 -0
  59. package/dist/code-generation/interface-package/interface-package-definition/channels-module.d.ts +5 -0
  60. package/dist/code-generation/interface-package/interface-package-definition/entities-module.d.ts +10 -0
  61. package/dist/code-generation/interface-package/interface-package-definition/events-module.d.ts +10 -0
  62. package/dist/code-generation/interface-package/interface-package-definition/index.d.ts +8 -0
  63. package/dist/code-generation/interface-package/interface-package-definition/typings.d.ts +7 -0
  64. package/dist/code-generation/module.d.ts +49 -0
  65. package/dist/code-generation/plugin-implementation/index.d.ts +3 -0
  66. package/dist/code-generation/plugin-implementation/plugin-implementation.d.ts +7 -0
  67. package/dist/code-generation/plugin-implementation/plugin-typings/actions-module.d.ts +21 -0
  68. package/dist/code-generation/plugin-implementation/plugin-typings/configuration-module.d.ts +7 -0
  69. package/dist/code-generation/plugin-implementation/plugin-typings/events-module.d.ts +10 -0
  70. package/dist/code-generation/plugin-implementation/plugin-typings/index.d.ts +8 -0
  71. package/dist/code-generation/plugin-implementation/plugin-typings/states-module.d.ts +17 -0
  72. package/dist/code-generation/plugin-implementation/plugin-typings/tables-module.d.ts +10 -0
  73. package/dist/code-generation/plugin-implementation/plugin-typings/workflows-module.d.ts +27 -0
  74. package/dist/code-generation/plugin-package/index.d.ts +2 -0
  75. package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.d.ts +21 -0
  76. package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.d.ts +7 -0
  77. package/dist/code-generation/plugin-package/plugin-package-definition/events-module.d.ts +10 -0
  78. package/dist/code-generation/plugin-package/plugin-package-definition/index.d.ts +8 -0
  79. package/dist/code-generation/plugin-package/plugin-package-definition/interfaces-module.d.ts +7 -0
  80. package/dist/code-generation/plugin-package/plugin-package-definition/recurring-events-module.d.ts +5 -0
  81. package/dist/code-generation/plugin-package/plugin-package-definition/states-module.d.ts +10 -0
  82. package/dist/code-generation/plugin-package/plugin-package-definition/typings.d.ts +7 -0
  83. package/dist/code-generation/strings.d.ts +4 -0
  84. package/dist/code-generation/typings.d.ts +162 -0
  85. package/dist/code-generation/typings.test.d.ts +1 -0
  86. package/dist/command-definitions.d.ts +1480 -0
  87. package/dist/command-implementations/add-command.d.ts +15 -0
  88. package/dist/command-implementations/add-command.js +3 -2
  89. package/dist/command-implementations/add-command.js.map +2 -2
  90. package/dist/command-implementations/base-command.d.ts +13 -0
  91. package/dist/command-implementations/bot-commands.d.ts +20 -0
  92. package/dist/command-implementations/build-command.d.ts +9 -0
  93. package/dist/command-implementations/build-command.js +2 -4
  94. package/dist/command-implementations/build-command.js.map +2 -2
  95. package/dist/command-implementations/bundle-command.d.ts +10 -0
  96. package/dist/command-implementations/bundle-command.js +6 -5
  97. package/dist/command-implementations/bundle-command.js.map +2 -2
  98. package/dist/command-implementations/chat-command.d.ts +13 -0
  99. package/dist/command-implementations/deploy-command.d.ts +18 -0
  100. package/dist/command-implementations/deploy-command.js +9 -5
  101. package/dist/command-implementations/deploy-command.js.map +2 -2
  102. package/dist/command-implementations/dev-command.d.ts +21 -0
  103. package/dist/command-implementations/dev-command.js +9 -6
  104. package/dist/command-implementations/dev-command.js.map +2 -2
  105. package/dist/command-implementations/gen-command.d.ts +11 -0
  106. package/dist/command-implementations/gen-command.js +8 -5
  107. package/dist/command-implementations/gen-command.js.map +2 -2
  108. package/dist/command-implementations/global-command.d.ts +57 -0
  109. package/dist/command-implementations/index.d.ts +1534 -0
  110. package/dist/command-implementations/init-command.d.ts +17 -0
  111. package/dist/command-implementations/integration-commands.d.ts +15 -0
  112. package/dist/command-implementations/interface-commands.d.ts +14 -0
  113. package/dist/command-implementations/lint-command.d.ts +15 -0
  114. package/dist/command-implementations/lint-command.js +15 -8
  115. package/dist/command-implementations/lint-command.js.map +3 -3
  116. package/dist/command-implementations/login-command.d.ts +6 -0
  117. package/dist/command-implementations/logout-command.d.ts +6 -0
  118. package/dist/command-implementations/plugin-commands.d.ts +14 -0
  119. package/dist/command-implementations/profile-commands.d.ts +14 -0
  120. package/dist/command-implementations/project-command.d.ts +94 -0
  121. package/dist/command-implementations/project-command.js +54 -18
  122. package/dist/command-implementations/project-command.js.map +2 -2
  123. package/dist/command-implementations/read-command.d.ts +10 -0
  124. package/dist/command-implementations/read-command.js +9 -5
  125. package/dist/command-implementations/read-command.js.map +2 -2
  126. package/dist/command-implementations/serve-command.d.ts +6 -0
  127. package/dist/command-implementations/serve-command.js +5 -4
  128. package/dist/command-implementations/serve-command.js.map +2 -2
  129. package/dist/command-tree.d.ts +39 -0
  130. package/dist/config.d.ts +1441 -0
  131. package/dist/consts.d.ts +41 -0
  132. package/dist/errors.d.ts +56 -0
  133. package/dist/index.d.ts +1524 -0
  134. package/dist/index.js +50 -25
  135. package/dist/index.js.map +3 -3
  136. package/dist/init.d.ts +1 -0
  137. package/dist/linter/base-linter.d.ts +21 -0
  138. package/dist/linter/base-linter.test.d.ts +1 -0
  139. package/dist/linter/bot-linter.d.ts +5 -0
  140. package/dist/linter/integration-linter.d.ts +7 -0
  141. package/dist/linter/interface-linter.d.ts +5 -0
  142. package/dist/linter/ruleset-tests/bot.ruleset.test.d.ts +1 -0
  143. package/dist/linter/ruleset-tests/common.d.ts +9 -0
  144. package/dist/linter/ruleset-tests/integration.ruleset.test.d.ts +1 -0
  145. package/dist/linter/ruleset-tests/interface.ruleset.test.d.ts +1 -0
  146. package/dist/linter/rulesets/bot.ruleset.d.ts +165 -0
  147. package/dist/linter/rulesets/integration.ruleset.d.ts +390 -0
  148. package/dist/linter/rulesets/interface.ruleset.d.ts +141 -0
  149. package/dist/linter/spectral-functions.d.ts +11 -0
  150. package/dist/logger/base-logger.d.ts +43 -0
  151. package/dist/logger/index.d.ts +22 -0
  152. package/dist/logger/logger.test.d.ts +1 -0
  153. package/dist/package-ref.d.ts +22 -0
  154. package/dist/package-ref.test.d.ts +1 -0
  155. package/dist/project-templates.d.ts +42 -0
  156. package/dist/register-yargs.d.ts +4 -0
  157. package/dist/root.d.ts +7 -0
  158. package/dist/sdk/index.d.ts +2 -0
  159. package/dist/sdk/validate-bot.d.ts +2 -0
  160. package/dist/sdk/validate-bot.test.d.ts +1 -0
  161. package/dist/sdk/validate-integration.d.ts +2 -0
  162. package/dist/tables/index.d.ts +1 -0
  163. package/dist/tables/schemas.d.ts +1259 -0
  164. package/dist/tables/tables-publisher.d.ts +22 -0
  165. package/dist/typings.d.ts +27 -0
  166. package/dist/utils/attribute-utils.d.ts +10 -0
  167. package/dist/utils/cache-utils.d.ts +14 -0
  168. package/dist/utils/case-utils.d.ts +14 -0
  169. package/dist/utils/case-utils.test.d.ts +1 -0
  170. package/dist/utils/concurrency-utils.d.ts +1 -0
  171. package/dist/utils/concurrency-utils.test.d.ts +1 -0
  172. package/dist/utils/esbuild-utils.d.ts +29 -0
  173. package/dist/utils/event-emitter.d.ts +7 -0
  174. package/dist/utils/file-watcher.d.ts +17 -0
  175. package/dist/utils/guard-utils.d.ts +4 -0
  176. package/dist/utils/id-utils.d.ts +2 -0
  177. package/dist/utils/index.d.ts +22 -0
  178. package/dist/utils/object-utils.d.ts +1 -0
  179. package/dist/utils/path-utils.d.ts +28 -0
  180. package/dist/utils/path-utils.test.d.ts +1 -0
  181. package/dist/utils/pkgjson-utils.d.ts +17 -0
  182. package/dist/utils/promise-utils.d.ts +2 -0
  183. package/dist/utils/promise-utils.test.d.ts +1 -0
  184. package/dist/utils/prompt-utils.d.ts +33 -0
  185. package/dist/utils/record-utils.d.ts +8 -0
  186. package/dist/utils/record-utils.test.d.ts +1 -0
  187. package/dist/utils/require-utils.d.ts +2 -0
  188. package/dist/utils/require-utils.test.d.ts +1 -0
  189. package/dist/utils/schema-utils.d.ts +13 -0
  190. package/dist/utils/schema-utils.test.d.ts +1 -0
  191. package/dist/utils/semver-utils.d.ts +8 -0
  192. package/dist/utils/string-utils.d.ts +2 -0
  193. package/dist/utils/template-utils.d.ts +1 -0
  194. package/dist/utils/tunnel-utils.d.ts +49 -0
  195. package/dist/utils/type-utils.d.ts +19 -0
  196. package/dist/utils/url-utils.d.ts +19 -0
  197. package/dist/worker/child-entrypoint.d.ts +1 -0
  198. package/dist/worker/child-wrapper.d.ts +18 -0
  199. package/dist/worker/config.d.ts +28 -0
  200. package/dist/worker/index.d.ts +2 -0
  201. package/dist/worker/is-child.d.ts +14 -0
  202. package/dist/worker/worker-state.d.ts +30 -0
  203. package/dist/worker/worker.d.ts +20 -0
  204. package/package.json +6 -4
  205. package/tsconfig.build.json +14 -0
@@ -0,0 +1,22 @@
1
+ import * as sdk from '@botpress/sdk';
2
+ import * as apiUtils from '../api';
3
+ import * as logger from '../logger';
4
+ import * as utils from '../utils';
5
+ export declare class TablesPublisher {
6
+ private readonly _api;
7
+ private readonly _logger;
8
+ private readonly _prompt;
9
+ constructor({ api, logger, prompt, }: {
10
+ api: apiUtils.ApiClient;
11
+ logger: logger.Logger;
12
+ prompt: utils.prompt.CLIPrompt;
13
+ });
14
+ deployTables({ botId, botDefinition }: {
15
+ botId: string;
16
+ botDefinition: sdk.BotDefinition;
17
+ }): Promise<void>;
18
+ private _deployExistingTable;
19
+ private _parseTableColumns;
20
+ private _warnAndConfirm;
21
+ private _deployNewTable;
22
+ }
@@ -0,0 +1,27 @@
1
+ import type { default as yargs, YargsConfig, YargsSchema } from '@bpinternal/yargs-extra';
2
+ export type CommandPositionalOption = yargs.PositionalOptions & {
3
+ positional: true;
4
+ idx: number;
5
+ };
6
+ export type CommandNamedOption = YargsSchema[string] & {
7
+ positional?: false;
8
+ };
9
+ export type CommandOption = CommandPositionalOption | CommandNamedOption;
10
+ export type CommandSchema = Record<string, CommandOption>;
11
+ export type CommandArgv<C extends CommandDefinition = CommandDefinition> = YargsConfig<C['schema']> & {
12
+ /**
13
+ * Ignored: fixes weird typing issue
14
+ */
15
+ _?: string;
16
+ };
17
+ export type CommandDefinition<S extends CommandSchema = CommandSchema> = {
18
+ schema: S;
19
+ description?: string;
20
+ alias?: string;
21
+ };
22
+ export type CommandImplementation<C extends CommandDefinition = CommandDefinition> = (argv: CommandArgv<C>) => Promise<{
23
+ exitCode: number;
24
+ }>;
25
+ export type CommandLeaf<C extends CommandDefinition = CommandDefinition> = C & {
26
+ handler: CommandImplementation<C>;
27
+ };
@@ -0,0 +1,10 @@
1
+ type ItemsWithAttributes = Record<string, {
2
+ attributes?: {
3
+ [key: string]: string | null;
4
+ };
5
+ } | null>;
6
+ export declare const prepareAttributeUpdateBody: <TLocalItems extends ItemsWithAttributes>({ localItems, remoteItems, }: {
7
+ localItems: TLocalItems;
8
+ remoteItems: ItemsWithAttributes;
9
+ }) => TLocalItems;
10
+ export {};
@@ -0,0 +1,14 @@
1
+ export declare class FSKeyValueCache<T extends Object> {
2
+ private _filepath;
3
+ private _initialized;
4
+ constructor(_filepath: string);
5
+ init(): Promise<void>;
6
+ sync<K extends keyof T>(key: K, value: T[K] | undefined, prompt: (initial?: T[K]) => Promise<T[K]>): Promise<T[K]>;
7
+ has<K extends keyof T>(key: K): Promise<boolean>;
8
+ get<K extends keyof T>(key: K): Promise<T[K] | undefined>;
9
+ set<K extends keyof T>(key: K, value: T[K]): Promise<void>;
10
+ rm<K extends keyof T>(key: K): Promise<void>;
11
+ clear(): Promise<void>;
12
+ private _writeJSON;
13
+ private _readJSON;
14
+ }
@@ -0,0 +1,14 @@
1
+ export declare const to: {
2
+ pascalCase: (text: string) => string;
3
+ kebabCase: (text: string) => string;
4
+ snakeCase: (text: string) => string;
5
+ screamingSnakeCase: (text: string) => string;
6
+ camelCase: (text: string) => string;
7
+ };
8
+ export declare const is: {
9
+ pascalCase: (text: string) => boolean;
10
+ kebabCase: (text: string) => boolean;
11
+ snakeCase: (text: string) => boolean;
12
+ screamingSnakeCase: (text: string) => boolean;
13
+ camelCase: (text: string) => boolean;
14
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const debounceAsync: <TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => Promise<TReturn>, ms: number) => ((...args: TArgs) => Promise<TReturn>);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ import * as esb from 'esbuild';
2
+ export * from 'esbuild';
3
+ type BaseProps = {
4
+ absWorkingDir: string;
5
+ };
6
+ export type BuildCodeProps = BaseProps & {
7
+ code: string;
8
+ outfile: string;
9
+ };
10
+ export type BuildEntrypointProps = BaseProps & {
11
+ entrypoint: string;
12
+ };
13
+ export declare class IncrementalBuildContext {
14
+ private _context;
15
+ private _previousProps;
16
+ private _previousOpts;
17
+ private _createContext;
18
+ rebuild(props: BuildCodeProps, opts?: esb.BuildOptions): Promise<void>;
19
+ }
20
+ /**
21
+ * Bundles a string of typescript code and writes the output to a file
22
+ */
23
+ export declare function buildCode(props: BuildCodeProps, opts?: esb.BuildOptions): Promise<esb.BuildResult>;
24
+ /**
25
+ * Bundles a typescript file and returns the output as a string
26
+ */
27
+ export declare function buildEntrypoint(props: BuildEntrypointProps, opts?: esb.BuildOptions): Promise<esb.BuildResult & {
28
+ outputFiles: esb.OutputFile[];
29
+ }>;
@@ -0,0 +1,7 @@
1
+ export declare class EventEmitter<E extends object> {
2
+ private _listeners;
3
+ emit<K extends keyof E>(type: K, event: E[K]): void;
4
+ once<K extends keyof E>(type: K, listener: (event: E[K]) => void): void;
5
+ on<K extends keyof E>(type: K, listener: (event: E[K]) => void): void;
6
+ off<K extends keyof E>(type: K, listener: (event: E[K]) => void): void;
7
+ }
@@ -0,0 +1,17 @@
1
+ import watcher from '@parcel/watcher';
2
+ export type FileChangeHandler = (events: watcher.Event[]) => Promise<void>;
3
+ type FileWatcherOptions = watcher.Options & {
4
+ debounceMs?: number;
5
+ };
6
+ /**
7
+ * Wraps the Parcel file watcher to ensure errors can be catched in an async/await fashion
8
+ */
9
+ export declare class FileWatcher {
10
+ private _subscription;
11
+ private _errorEmitter;
12
+ static watch(dir: string, fn: FileChangeHandler, opt?: FileWatcherOptions): Promise<FileWatcher>;
13
+ private constructor();
14
+ close(): Promise<void>;
15
+ wait: () => Promise<unknown>;
16
+ }
17
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const is: {
2
+ defined: <T>(value: T | undefined) => value is T;
3
+ notNull: <T>(value: T | null) => value is T;
4
+ };
@@ -0,0 +1,2 @@
1
+ export declare function isValidID(id: string): boolean;
2
+ export declare function isPrefixedULID(id: string): boolean;
@@ -0,0 +1,22 @@
1
+ export * as attributes from './attribute-utils';
2
+ export * as cache from './cache-utils';
3
+ export * as casing from './case-utils';
4
+ export * as emitter from './event-emitter';
5
+ export * as esbuild from './esbuild-utils';
6
+ export * as filewatcher from './file-watcher';
7
+ export * as guards from './guard-utils';
8
+ export * as id from './id-utils';
9
+ export * as object from './object-utils';
10
+ export * as path from './path-utils';
11
+ export * as pkgJson from './pkgjson-utils';
12
+ export * as promises from './promise-utils';
13
+ export * as prompt from './prompt-utils';
14
+ export * as records from './record-utils';
15
+ export * as require from './require-utils';
16
+ export * as schema from './schema-utils';
17
+ export * as semver from './semver-utils';
18
+ export * as string from './string-utils';
19
+ export * as template from './template-utils';
20
+ export * as tunnel from './tunnel-utils';
21
+ export * as types from './type-utils';
22
+ export * as url from './url-utils';
@@ -0,0 +1 @@
1
+ export declare const omit: <O extends object, K extends keyof O>(obj: O, property: K) => Omit<O, K>;
@@ -0,0 +1,28 @@
1
+ export declare namespace posix {
2
+ type AbsolutePath = `/${string}`;
3
+ const isPath: (path: string) => boolean;
4
+ const isRelativePath: (path: string) => boolean;
5
+ const isAbsolutePath: (path: string) => path is AbsolutePath;
6
+ }
7
+ export declare namespace win32 {
8
+ type AbsolutePath = `${string}:\\${string}`;
9
+ const isPath: (path: string) => boolean;
10
+ const isRelativePath: (path: string) => boolean;
11
+ const isAbsolutePath: (path: string) => path is AbsolutePath;
12
+ }
13
+ export type AbsolutePath = posix.AbsolutePath | win32.AbsolutePath;
14
+ export declare const isPath: (path: string) => boolean;
15
+ export declare const isPlatformSpecificPath: (path: string) => boolean;
16
+ export declare const isPlatformSpecificAbsolutePath: (path: string) => path is AbsolutePath;
17
+ export declare const cwd: () => AbsolutePath;
18
+ export declare const join: (abs: AbsolutePath, ...paths: string[]) => AbsolutePath;
19
+ export declare const rmExtension: (filename: string) => string;
20
+ export declare const toUnix: (path: string) => string;
21
+ export declare const toNormalizedPosixPath: (path: string) => string;
22
+ export declare const absoluteFrom: (rootdir: AbsolutePath, target: string) => AbsolutePath;
23
+ export declare const relativeFrom: (rootdir: AbsolutePath, target: string) => string;
24
+ export declare class PathStore<P extends string> {
25
+ readonly abs: Record<P, AbsolutePath>;
26
+ constructor(abs: Record<P, AbsolutePath>);
27
+ rel(from: Extract<P, `${string}Dir`>): Record<P, AbsolutePath> extends infer T extends object ? { [P_1 in keyof T]: string; } : never;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ type JSON = string | number | boolean | null | JSON[] | {
2
+ [key: string]: JSON;
3
+ };
4
+ export type PackageJson = {
5
+ name: string;
6
+ version?: string;
7
+ description?: string;
8
+ scripts?: Record<string, string>;
9
+ dependencies?: Record<string, string>;
10
+ devDependencies?: Record<string, string>;
11
+ peerDependencies?: Record<string, string>;
12
+ } & {
13
+ [key: string]: JSON;
14
+ };
15
+ export declare const readPackageJson: (path: string) => Promise<PackageJson | undefined>;
16
+ export declare const findDependency: (pkgJson: PackageJson, name: string) => string | undefined;
17
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const awaitRecord: <T>(record: Record<string, Promise<T>>) => Promise<Record<string, T>>;
2
+ export declare const sleep: (ms: number) => Promise<unknown>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ import type { Logger } from '../logger';
2
+ export type CLIPromptsProps = {
3
+ confirm: boolean;
4
+ };
5
+ type ChoiceValueType = string | number;
6
+ export type CLIPromptsChoice<V extends ChoiceValueType> = {
7
+ title: string;
8
+ value: V;
9
+ };
10
+ type PasswordOptions = Partial<{
11
+ default: string | undefined;
12
+ initial: string;
13
+ }>;
14
+ type SelectOptions<V extends ChoiceValueType> = Partial<{
15
+ default: V | undefined;
16
+ initial: CLIPromptsChoice<V>;
17
+ choices: CLIPromptsChoice<V>[];
18
+ }>;
19
+ type TextOptions = Partial<{
20
+ default: string | undefined;
21
+ initial: string;
22
+ }>;
23
+ export declare class CLIPrompt {
24
+ private _props;
25
+ private _logger;
26
+ constructor(_props: CLIPromptsProps, _logger: Logger);
27
+ confirm(message: string): Promise<boolean>;
28
+ password(message: string, opts?: PasswordOptions): Promise<string | undefined>;
29
+ select<V extends ChoiceValueType = string>(message: string, opts?: SelectOptions<V>): Promise<V | undefined>;
30
+ text(message: string, opts?: TextOptions): Promise<string | undefined>;
31
+ private _prompts;
32
+ }
33
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare const setNullOnMissingValues: <A, B>(record?: Record<string, A>, oldRecord?: Record<string, B>) => Record<string, A | null>;
2
+ export declare const zipObjects: <A, B>(recordA: Record<string, A>, recordB: Record<string, B>) => Record<string, [A | null, B | null]>;
3
+ export declare const mapValues: <A, B>(record: Record<string, A>, fn: (value: A, key: string) => B) => Record<string, B>;
4
+ export declare const mapValuesAsync: <A, B>(record: Record<string, A>, fn: (value: A, key: string) => Promise<B>) => Promise<Record<string, B>>;
5
+ export declare const mapKeys: <A>(record: Record<string, A>, fn: (value: A, key: string) => string) => Record<string, A>;
6
+ export declare function filterValues<A, B extends A>(record: Record<string, A>, fn: (value: A, key: string) => value is B): Record<string, B>;
7
+ export declare function filterValues<A, _B extends A>(record: Record<string, A>, fn: (value: A, key: string) => boolean): Record<string, A>;
8
+ export declare const mergeRecords: <K extends string, V>(a: Record<K, V>, b: Record<K, V>, merge: (v1: V, v2: V) => V) => Record<K, V>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const requireJsFile: <T>(path: string) => T;
2
+ export declare const requireJsCode: <T>(code: string) => T;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import * as sdk from '@botpress/sdk';
2
+ import { JSONSchema7 } from 'json-schema';
3
+ type SchemaOptions = {
4
+ title?: string;
5
+ examples?: any[];
6
+ };
7
+ type SchemaDefinition = {
8
+ schema: sdk.ZuiObjectOrRefSchema;
9
+ ui?: Record<string, SchemaOptions | undefined>;
10
+ };
11
+ export declare function mapZodToJsonSchema(definition: SchemaDefinition): Promise<ReturnType<typeof sdk.transforms.toJSONSchemaLegacy>>;
12
+ export declare const dereferenceSchema: (schema: JSONSchema7) => Promise<JSONSchema7>;
13
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import semver from 'semver';
2
+ export declare namespace releases {
3
+ const eq: (a: semver.ReleaseType, b: semver.ReleaseType) => boolean;
4
+ const gt: (a: semver.ReleaseType, b: semver.ReleaseType) => boolean;
5
+ const gte: (a: semver.ReleaseType, b: semver.ReleaseType) => boolean;
6
+ const lt: (a: semver.ReleaseType, b: semver.ReleaseType) => boolean;
7
+ const lte: (a: semver.ReleaseType, b: semver.ReleaseType) => boolean;
8
+ }
@@ -0,0 +1,2 @@
1
+ export declare const splitOnce: (text: string, separator: string) => [string, string | undefined];
2
+ export declare function chunkString(input: string, chunkSize: number): Generator<string, void, void>;
@@ -0,0 +1 @@
1
+ export declare const formatHandleBars: (templateStr: string, data: Record<string, string>) => string;
@@ -0,0 +1,49 @@
1
+ import { TunnelTail, ClientCloseEvent, ClientErrorEvent } from '@bpinternal/tunnel';
2
+ import { Logger } from '../logger';
3
+ import { EventEmitter } from './event-emitter';
4
+ export type ReconnectionTriggerEvent = {
5
+ type: 'init';
6
+ ev: null;
7
+ } | {
8
+ type: 'error';
9
+ ev: ClientErrorEvent;
10
+ } | {
11
+ type: 'close';
12
+ ev: ClientCloseEvent;
13
+ };
14
+ export type ReconnectedEvent = {
15
+ tunnel: TunnelTail;
16
+ ev: ReconnectionTriggerEvent;
17
+ };
18
+ export declare class ReconnectionFailedError extends Error {
19
+ readonly event: ReconnectionTriggerEvent;
20
+ constructor(event: ReconnectionTriggerEvent);
21
+ private static _reason;
22
+ }
23
+ export declare class TunnelSupervisor {
24
+ private _tunnelUrl;
25
+ private _tunnelId;
26
+ private _logger;
27
+ private _tunnel?;
28
+ private _closed;
29
+ private _started;
30
+ readonly events: EventEmitter<{
31
+ connectionFailed: ReconnectionTriggerEvent;
32
+ manuallyClosed: null;
33
+ connected: {
34
+ tunnel: TunnelTail;
35
+ ev: ReconnectionTriggerEvent;
36
+ };
37
+ }>;
38
+ constructor(_tunnelUrl: string, _tunnelId: string, _logger: Logger);
39
+ start(): Promise<void>;
40
+ get closed(): boolean;
41
+ /**
42
+ * @returns Promise that rejects when a reconnection attempt fails and resolves when the tunnel is closed manually
43
+ */
44
+ wait(): Promise<void>;
45
+ close(): void;
46
+ private _reconnectSync;
47
+ private _reconnect;
48
+ private _registerListeners;
49
+ }
@@ -0,0 +1,19 @@
1
+ export type Merge<A extends object, B extends object> = Omit<A, keyof B> & B;
2
+ export type SafeOmit<T, K extends keyof T> = Omit<T, K>;
3
+ export type Writable<T> = {
4
+ -readonly [K in keyof T]: T[K];
5
+ };
6
+ export type AssertNever<_T extends never> = true;
7
+ export type AssertExtends<_A extends B, B> = true;
8
+ export type AssertKeyOf<_K extends keyof T, T> = true;
9
+ export type AssertTrue<_T extends true> = true;
10
+ export type AssertAll<_T extends true[]> = true;
11
+ export type IsExtend<X, Y> = X extends Y ? true : false;
12
+ export type IsEquivalent<X, Y> = IsExtend<X, Y> extends true ? IsExtend<Y, X> : false;
13
+ export type IsIdentical<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
14
+ export type IsEqual<X, Y> = IsIdentical<Normalize<X>, Normalize<Y>>;
15
+ type NormalizeObject<T extends object> = T extends infer O ? {
16
+ [K in keyof O]: Normalize<O[K]>;
17
+ } : never;
18
+ export type Normalize<T> = T extends (...args: infer A) => infer R ? (...args: Normalize<A>) => Normalize<R> : T extends Array<infer E> ? Array<Normalize<E>> : T extends ReadonlyArray<infer E> ? ReadonlyArray<Normalize<E>> : T extends Promise<infer R> ? Promise<Normalize<R>> : T extends Buffer ? Buffer : T extends object ? NormalizeObject<T> : T;
19
+ export {};
@@ -0,0 +1,19 @@
1
+ declare const _PROTOCOLS: readonly ["http", "https", "ws", "wss"];
2
+ export type Protocol = (typeof _PROTOCOLS)[number];
3
+ export type Path = `/${string}`;
4
+ export type Url = {
5
+ protocol: Protocol;
6
+ host: string;
7
+ port?: number;
8
+ path?: Path;
9
+ };
10
+ export type UrlParseResult = {
11
+ status: 'success';
12
+ url: Url;
13
+ } | {
14
+ status: 'error';
15
+ error: string;
16
+ };
17
+ export declare function parse(hostOrUrl: string): UrlParseResult;
18
+ export declare const format: (url: Url) => string;
19
+ export {};
@@ -0,0 +1 @@
1
+ export declare const ENTRY_POINT: string;
@@ -0,0 +1,18 @@
1
+ import type { Logger } from '../logger';
2
+ import { Config } from './config';
3
+ export type ChildOutput = {
4
+ exitCode: number | null;
5
+ signal: NodeJS.Signals | null;
6
+ };
7
+ /**
8
+ * Wrapper above child_process.ChildProcess to simplify usage
9
+ */
10
+ export declare class ChildProcessWrapper {
11
+ private _child;
12
+ private _exitPromise;
13
+ static spawn(config: Config, logger: Logger): Promise<ChildProcessWrapper>;
14
+ private _exited;
15
+ private constructor();
16
+ kill(): Promise<ChildOutput>;
17
+ listen(): Promise<ChildOutput>;
18
+ }
@@ -0,0 +1,28 @@
1
+ import { z } from '@botpress/sdk';
2
+ export declare const CONFIG_ENV_KEY = "CHILD_PROCESS_CONFIGURATION";
3
+ export type Config = z.infer<typeof configSchema>;
4
+ export declare const configSchema: import("@botpress/sdk").ZodUnion<[import("@botpress/sdk").ZodObject<{
5
+ type: import("@botpress/sdk").ZodLiteral<"code">;
6
+ code: import("@botpress/sdk").ZodString;
7
+ env: import("@botpress/sdk").ZodOptional<import("@botpress/sdk").ZodRecord<import("@botpress/sdk").ZodString, import("@botpress/sdk").ZodString>>;
8
+ }, "strip", {
9
+ type: "code";
10
+ code: string;
11
+ env?: Record<string, string> | undefined;
12
+ }, {
13
+ type: "code";
14
+ code: string;
15
+ env?: Record<string, string> | undefined;
16
+ }>, import("@botpress/sdk").ZodObject<{
17
+ type: import("@botpress/sdk").ZodLiteral<"file">;
18
+ file: import("@botpress/sdk").ZodString;
19
+ env: import("@botpress/sdk").ZodOptional<import("@botpress/sdk").ZodRecord<import("@botpress/sdk").ZodString, import("@botpress/sdk").ZodString>>;
20
+ }, "strip", {
21
+ type: "file";
22
+ file: string;
23
+ env?: Record<string, string> | undefined;
24
+ }, {
25
+ type: "file";
26
+ file: string;
27
+ env?: Record<string, string> | undefined;
28
+ }>]>;
@@ -0,0 +1,2 @@
1
+ export { Config } from './config';
2
+ export { Worker } from './worker';
@@ -0,0 +1,14 @@
1
+ export declare const CHILD_ENV_KEY = "IS_CHILD";
2
+ export declare const CHILD_ENV_VALUE = "true";
3
+ export type MainProcessProps = {
4
+ type: 'main';
5
+ pid: number;
6
+ };
7
+ export type ChildProcessProps = {
8
+ type: 'child';
9
+ sendMessage: (message: string) => void;
10
+ pid: number;
11
+ };
12
+ export type ProcessProps = MainProcessProps | ChildProcessProps;
13
+ export declare const processProps: ProcessProps;
14
+ export declare const isChildProcess: boolean;
@@ -0,0 +1,30 @@
1
+ import type { ChildProcessWrapper } from './child-wrapper';
2
+ export type WorkerStatus = WorkerState['status'];
3
+ export type WorkerState = {
4
+ status: 'errored';
5
+ thrown: unknown;
6
+ } | {
7
+ status: 'dead';
8
+ murdered: boolean;
9
+ } | {
10
+ status: 'killing';
11
+ } | {
12
+ status: 'reloading';
13
+ } | {
14
+ status: 'live';
15
+ child: ChildProcessWrapper;
16
+ };
17
+ export type StateOf<S extends WorkerStatus> = Extract<WorkerState, {
18
+ status: S;
19
+ }>;
20
+ export type WorkerStateHandler<S extends WorkerStatus> = (state: StateOf<S>) => void;
21
+ export declare class WorkerStateObserver {
22
+ private _state;
23
+ private _handlers;
24
+ constructor(initialState: WorkerState);
25
+ waitFor<S extends WorkerStatus>(status: S): Promise<void>;
26
+ on<S extends WorkerStatus>(status: S, handler: WorkerStateHandler<S>): void;
27
+ off<S extends WorkerStatus>(status: S, handler: WorkerStateHandler<S>): void;
28
+ get(): WorkerState;
29
+ set(newState: WorkerState): void;
30
+ }
@@ -0,0 +1,20 @@
1
+ import type { Logger } from '../logger';
2
+ import type { Config } from './config';
3
+ export type WorkerProps = {
4
+ hangOnExit?: boolean;
5
+ };
6
+ export declare class Worker {
7
+ private _config;
8
+ private _logger;
9
+ private _props;
10
+ static spawn(config: Config, logger: Logger, props?: Partial<WorkerProps>): Promise<Worker>;
11
+ private _state;
12
+ private constructor();
13
+ /**
14
+ * Used to determine if the worker can be killed
15
+ */
16
+ get running(): boolean;
17
+ kill: () => Promise<import("./child-wrapper").ChildOutput>;
18
+ reload: () => Promise<void>;
19
+ wait: () => Promise<void>;
20
+ }
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "4.17.14",
3
+ "version": "4.17.16",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
- "build": "pnpm run bundle && pnpm run template:gen",
7
- "dev": "ts-node -T src/index.ts",
8
- "start": "node dist/index.js",
6
+ "build": "pnpm run build:types && pnpm run bundle && pnpm run template:gen",
7
+ "dev": "ts-node -T src/cli.ts",
8
+ "start": "node dist/cli.js",
9
9
  "check:type": "tsc --noEmit",
10
10
  "bundle": "ts-node -T build.ts",
11
+ "build:types": "tsc -p ./tsconfig.build.json",
11
12
  "template:gen": "pnpm -r --stream -F @bp-templates/* exec bp gen",
12
13
  "test:e2e": "ts-node -T ./e2e"
13
14
  },
@@ -18,6 +19,7 @@
18
19
  "bp": "./bin.js"
19
20
  },
20
21
  "main": "dist/index.js",
22
+ "types": "dist/index.d.ts",
21
23
  "dependencies": {
22
24
  "@apidevtools/json-schema-ref-parser": "^11.7.0",
23
25
  "@botpress/chat": "0.5.1",
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "rootDir": "src",
6
+ "outDir": "dist",
7
+ "declaration": true,
8
+ "esModuleInterop": true,
9
+ "sourceMap": true,
10
+ "emitDeclarationOnly": true,
11
+ "noCheck": true
12
+ },
13
+ "include": ["./src/**/*"]
14
+ }