@promptbook/vercel 0.79.0 → 0.80.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.
Files changed (40) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +222 -143
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +6 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +8 -6
  6. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  8. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +32 -0
  9. package/esm/typings/src/commands/_common/getParserForCommand.d.ts +1 -1
  10. package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
  11. package/esm/typings/src/commands/_common/stringifyCommand.d.ts +1 -1
  12. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +3 -0
  13. package/esm/typings/src/config.d.ts +0 -25
  14. package/esm/typings/src/constants.d.ts +35 -0
  15. package/esm/typings/src/conversion/{pipelineStringToJson.d.ts → compilePipeline.d.ts} +3 -3
  16. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
  17. package/esm/typings/src/conversion/{pipelineStringToJsonSync.d.ts → precompilePipeline.d.ts} +4 -3
  18. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +20 -0
  19. package/esm/typings/src/high-level-abstractions/implicit-formfactor/ImplicitFormfactorHla.d.ts +10 -0
  20. package/esm/typings/src/high-level-abstractions/index.d.ts +44 -0
  21. package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +10 -0
  22. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  23. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  24. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -0
  25. package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -0
  26. package/esm/typings/src/types/typeAliases.d.ts +1 -1
  27. package/esm/typings/src/utils/normalization/orderJson.d.ts +21 -0
  28. package/esm/typings/src/utils/normalization/orderJson.test.d.ts +4 -0
  29. package/esm/typings/src/utils/organization/keepTypeImported.d.ts +9 -0
  30. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
  31. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +20 -2
  32. package/esm/typings/src/utils/serialization/deepClone.test.d.ts +1 -0
  33. package/esm/typings/src/utils/serialization/exportJson.d.ts +29 -0
  34. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -1
  35. package/package.json +2 -2
  36. package/umd/index.umd.js +222 -143
  37. package/umd/index.umd.js.map +1 -1
  38. package/esm/typings/src/utils/serialization/$asDeeplyFrozenSerializableJson.d.ts +0 -17
  39. /package/esm/typings/src/conversion/{pipelineStringToJson.test.d.ts → compilePipeline.test.d.ts} +0 -0
  40. /package/esm/typings/src/conversion/{pipelineStringToJsonSync.test.d.ts → precompilePipeline.test.d.ts} +0 -0
@@ -54,7 +54,7 @@ export declare class RemoteLlmExecutionTools<TCustomOptions = undefined> impleme
54
54
  private callCommonModel;
55
55
  }
56
56
  /**
57
- * TODO: Maybe use `$asDeeplyFrozenSerializableJson`
57
+ * TODO: Maybe use `$exportJson`
58
58
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
59
59
  * TODO: [🍓] Allow to list compatible models with each variant
60
60
  * TODO: [🗯] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable
@@ -11,7 +11,7 @@ import type { RemoteServerOptions } from './interfaces/RemoteServerOptions';
11
11
  */
12
12
  export declare function startRemoteServer<TCustomOptions = undefined>(options: RemoteServerOptions<TCustomOptions>): IDestroyable;
13
13
  /**
14
- * TODO: Maybe use `$asDeeplyFrozenSerializableJson`
14
+ * TODO: Maybe use `$exportJson`
15
15
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
16
16
  * TODO: [⚖] Expose the collection to be able to connect to same collection via createCollectionFromUrl
17
17
  * TODO: Handle progress - support streaming
@@ -22,6 +22,7 @@ type PreparedTasks = {
22
22
  export declare function prepareTasks(pipeline: PrepareTaskInput, tools: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options: PrepareAndScrapeOptions): Promise<PreparedTasks>;
23
23
  export {};
24
24
  /**
25
+ * TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
25
26
  * TODO: [🧠] Add context to each task (if missing)
26
27
  * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
27
28
  * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
@@ -2,6 +2,7 @@ import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
2
2
  /**
3
3
  * Unprepare just strips the preparation data of the pipeline
4
4
  *
5
+ * @deprecated In future version this function will be removed or deprecated
5
6
  * @public exported from `@promptbook/core`
6
7
  */
7
8
  export declare function unpreparePipeline(pipeline: PipelineJson): PipelineJson;
@@ -1,5 +1,5 @@
1
1
  import type { TupleToUnion } from 'type-fest';
2
- import { RESERVED_PARAMETER_NAMES } from '../config';
2
+ import { RESERVED_PARAMETER_NAMES } from '../constants';
3
3
  /**
4
4
  * Semantic helper
5
5
  */
@@ -0,0 +1,21 @@
1
+ import type { JsonArray, JsonObject } from 'type-fest';
2
+ /**
3
+ * Options for the `orderJson` function
4
+ */
5
+ export type OrderJsonOptions<TObject extends JsonObject | JsonArray> = {
6
+ /**
7
+ * Value to checked, ordered and deeply frozen
8
+ */
9
+ value: TObject;
10
+ /**
11
+ * Order of the object properties
12
+ */
13
+ order: Array<keyof TObject>;
14
+ };
15
+ /**
16
+ * Orders JSON object by keys
17
+ *
18
+ * @returns The same type of object as the input re-ordered
19
+ * @public exported from `@promptbook/utils`
20
+ */
21
+ export declare function orderJson<TObject extends JsonObject | JsonArray>(options: OrderJsonOptions<TObject>): TObject;
@@ -0,0 +1,4 @@
1
+ export {};
2
+ /**
3
+ * TODO: [🧠] Is there a way how to test order of value better way than via `JSON.stringify`
4
+ */
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Just says that the type is used but `organize-imports-cli` does not recognize it.
3
+ * [🤛] This is a workaround for the issue.
4
+ *
5
+ * @param value any values
6
+ * @returns void
7
+ * @private within the repository
8
+ */
9
+ export declare function keepTypeImported<TTypeToKeep>(): void;
@@ -1,6 +1,6 @@
1
1
  import type { ReadonlyDeep } from 'type-fest';
2
2
  /**
3
- * @@@
3
+ * Freezes the given object and all its nested objects recursively
4
4
  *
5
5
  * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
6
6
  * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
@@ -1,4 +1,22 @@
1
1
  import type { string_name } from '../../types/typeAliases';
2
+ import type { really_unknown } from '../organization/really_unknown';
3
+ /**
4
+ * Options for the `checkSerializableAsJson` function
5
+ */
6
+ export type CheckSerializableAsJsonOptions = {
7
+ /**
8
+ * Value to be checked
9
+ */
10
+ value: really_unknown;
11
+ /**
12
+ * Semantic name of the value for debugging purposes
13
+ */
14
+ name?: string_name;
15
+ /**
16
+ * Message alongside the value for debugging purposes
17
+ */
18
+ message?: string;
19
+ };
2
20
  /**
3
21
  * Checks if the value is [🚉] serializable as JSON
4
22
  * If not, throws an UnexpectedError with a rich error message and tracking
@@ -19,9 +37,9 @@ import type { string_name } from '../../types/typeAliases';
19
37
  * @throws UnexpectedError if the value is not serializable as JSON
20
38
  * @public exported from `@promptbook/utils`
21
39
  */
22
- export declare function checkSerializableAsJson(name: string_name, value: unknown): void;
40
+ export declare function checkSerializableAsJson(options: CheckSerializableAsJsonOptions): void;
23
41
  /**
24
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
42
+ * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
25
43
  * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
26
44
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
27
45
  */
@@ -0,0 +1,29 @@
1
+ import type { JsonArray, JsonObject } from 'type-fest';
2
+ import type { OrderJsonOptions } from '../normalization/orderJson';
3
+ import type { CheckSerializableAsJsonOptions } from './checkSerializableAsJson';
4
+ /**
5
+ * Options for the `$exportJson` function
6
+ */
7
+ export type ExportJsonOptions<TObject> = CheckSerializableAsJsonOptions & Partial<Pick<OrderJsonOptions<TObject & (JsonObject | JsonArray)>, 'order'>> & {
8
+ /**
9
+ * Value to be checked, ordered and deeply frozen
10
+ */
11
+ value: TObject;
12
+ };
13
+ /**
14
+ * Utility to export a JSON object from a function
15
+ *
16
+ * 1) Checks if the value is serializable as JSON
17
+ * 2) Makes a deep clone of the object
18
+ * 2) Orders the object properties
19
+ * 2) Deeply freezes the cloned object
20
+ *
21
+ * Note: This function does not mutates the given object
22
+ *
23
+ * @returns The same type of object as the input but read-only and re-ordered
24
+ * @public exported from `@promptbook/utils`
25
+ */
26
+ export declare function exportJson<TObject>(options: ExportJsonOptions<TObject>): TObject;
27
+ /**
28
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
29
+ */
@@ -1,3 +1,4 @@
1
+ import { JsonValue } from 'type-fest';
1
2
  /**
2
3
  * Tests if the value is [🚉] serializable as JSON
3
4
  *
@@ -17,7 +18,7 @@
17
18
  *
18
19
  * @public exported from `@promptbook/utils`
19
20
  */
20
- export declare function isSerializableAsJson(value: unknown): boolean;
21
+ export declare function isSerializableAsJson(value: unknown): value is JsonValue;
21
22
  /**
22
23
  * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
23
24
  * TODO: [🧠][💺] Can be done this on type-level?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/vercel",
3
- "version": "0.79.0",
3
+ "version": "0.80.0-1",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "--note-0": " <- [🐊]",
6
6
  "private": false,
@@ -54,7 +54,7 @@
54
54
  "module": "./esm/index.es.js",
55
55
  "typings": "./esm/typings/src/_packages/vercel.index.d.ts",
56
56
  "peerDependencies": {
57
- "@promptbook/core": "0.79.0"
57
+ "@promptbook/core": "0.80.0-1"
58
58
  },
59
59
  "dependencies": {
60
60
  "colors": "1.4.0",