@promptbook/core 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/core",
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,
package/umd/index.umd.js CHANGED
@@ -27,7 +27,7 @@
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.88.0-8';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.88.0-9';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1814,6 +1814,36 @@
1814
1814
  * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
1815
1815
  */
1816
1816
 
1817
+ /**
1818
+ * Recursively converts JSON strings to JSON objects
1819
+
1820
+ * @public exported from `@promptbook/utils`
1821
+ */
1822
+ function jsonStringsToJsons(object) {
1823
+ if (object === null) {
1824
+ return object;
1825
+ }
1826
+ if (Array.isArray(object)) {
1827
+ return object.map(jsonStringsToJsons);
1828
+ }
1829
+ if (typeof object !== 'object') {
1830
+ return object;
1831
+ }
1832
+ const newObject = { ...object };
1833
+ for (const [key, value] of Object.entries(object)) {
1834
+ if (typeof value === 'string' && isValidJsonString(value)) {
1835
+ newObject[key] = JSON.parse(value);
1836
+ }
1837
+ else {
1838
+ newObject[key] = jsonStringsToJsons(value);
1839
+ }
1840
+ }
1841
+ return newObject;
1842
+ }
1843
+ /**
1844
+ * TODO: Type the return type correctly
1845
+ */
1846
+
1817
1847
  /**
1818
1848
  * This error indicates errors during the execution of the pipeline
1819
1849
  *
@@ -2084,11 +2114,12 @@
2084
2114
  let updatedAt = createdAt;
2085
2115
  const errors = [];
2086
2116
  const warnings = [];
2087
- const currentValue = {};
2117
+ let currentValue = {};
2088
2118
  const partialResultSubject = new rxjs.Subject();
2089
2119
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2090
2120
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
2091
2121
  Object.assign(currentValue, newOngoingResult);
2122
+ // <- TODO: assign deep
2092
2123
  partialResultSubject.next(newOngoingResult);
2093
2124
  });
2094
2125
  finalResultPromise
@@ -2108,7 +2139,8 @@
2108
2139
  // And delete `ExecutionTask.currentValue.preparedPipeline`
2109
2140
  assertsTaskSuccessful(executionResult);
2110
2141
  status = 'FINISHED';
2111
- Object.assign(currentValue, executionResult);
2142
+ currentValue = jsonStringsToJsons(executionResult);
2143
+ // <- TODO: Convert JSON values in string to JSON objects
2112
2144
  partialResultSubject.next(executionResult);
2113
2145
  }
2114
2146
  catch (error) {