@promptbook/node 0.88.0-8 → 0.88.0-9

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.
@@ -62,6 +62,7 @@ import { clonePipeline } from '../utils/serialization/clonePipeline';
62
62
  import { deepClone } from '../utils/serialization/deepClone';
63
63
  import { exportJson } from '../utils/serialization/exportJson';
64
64
  import { isSerializableAsJson } from '../utils/serialization/isSerializableAsJson';
65
+ import { jsonStringsToJsons } from '../utils/serialization/jsonStringsToJsons';
65
66
  import { difference } from '../utils/sets/difference';
66
67
  import { intersection } from '../utils/sets/intersection';
67
68
  import { union } from '../utils/sets/union';
@@ -143,6 +144,7 @@ export { clonePipeline };
143
144
  export { deepClone };
144
145
  export { exportJson };
145
146
  export { isSerializableAsJson };
147
+ export { jsonStringsToJsons };
146
148
  export { difference };
147
149
  export { intersection };
148
150
  export { union };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Recursively converts JSON strings to JSON objects
3
+
4
+ * @public exported from `@promptbook/utils`
5
+ */
6
+ export declare function jsonStringsToJsons<T>(object: T): T;
7
+ /**
8
+ * TODO: Type the return type correctly
9
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.88.0-8",
3
+ "version": "0.88.0-9",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -47,7 +47,7 @@
47
47
  "module": "./esm/index.es.js",
48
48
  "typings": "./esm/typings/src/_packages/node.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.88.0-8"
50
+ "@promptbook/core": "0.88.0-9"
51
51
  },
52
52
  "dependencies": {
53
53
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -46,7 +46,7 @@
46
46
  * @generated
47
47
  * @see https://github.com/webgptorg/promptbook
48
48
  */
49
- const PROMPTBOOK_ENGINE_VERSION = '0.88.0-8';
49
+ const PROMPTBOOK_ENGINE_VERSION = '0.88.0-9';
50
50
  /**
51
51
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
52
52
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1621,6 +1621,36 @@
1621
1621
  * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
1622
1622
  */
1623
1623
 
1624
+ /**
1625
+ * Recursively converts JSON strings to JSON objects
1626
+
1627
+ * @public exported from `@promptbook/utils`
1628
+ */
1629
+ function jsonStringsToJsons(object) {
1630
+ if (object === null) {
1631
+ return object;
1632
+ }
1633
+ if (Array.isArray(object)) {
1634
+ return object.map(jsonStringsToJsons);
1635
+ }
1636
+ if (typeof object !== 'object') {
1637
+ return object;
1638
+ }
1639
+ const newObject = { ...object };
1640
+ for (const [key, value] of Object.entries(object)) {
1641
+ if (typeof value === 'string' && isValidJsonString(value)) {
1642
+ newObject[key] = JSON.parse(value);
1643
+ }
1644
+ else {
1645
+ newObject[key] = jsonStringsToJsons(value);
1646
+ }
1647
+ }
1648
+ return newObject;
1649
+ }
1650
+ /**
1651
+ * TODO: Type the return type correctly
1652
+ */
1653
+
1624
1654
  /**
1625
1655
  * This error indicates errors during the execution of the pipeline
1626
1656
  *
@@ -1891,11 +1921,12 @@
1891
1921
  let updatedAt = createdAt;
1892
1922
  const errors = [];
1893
1923
  const warnings = [];
1894
- const currentValue = {};
1924
+ let currentValue = {};
1895
1925
  const partialResultSubject = new rxjs.Subject();
1896
1926
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
1897
1927
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
1898
1928
  Object.assign(currentValue, newOngoingResult);
1929
+ // <- TODO: assign deep
1899
1930
  partialResultSubject.next(newOngoingResult);
1900
1931
  });
1901
1932
  finalResultPromise
@@ -1915,7 +1946,8 @@
1915
1946
  // And delete `ExecutionTask.currentValue.preparedPipeline`
1916
1947
  assertsTaskSuccessful(executionResult);
1917
1948
  status = 'FINISHED';
1918
- Object.assign(currentValue, executionResult);
1949
+ currentValue = jsonStringsToJsons(executionResult);
1950
+ // <- TODO: Convert JSON values in string to JSON objects
1919
1951
  partialResultSubject.next(executionResult);
1920
1952
  }
1921
1953
  catch (error) {