@promptbook/markdown-utils 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.
- package/README.md +3 -26
- package/esm/index.es.js +35 -3
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/utils/serialization/jsonStringsToJsons.d.ts +9 -0
- package/esm/typings/src/utils/serialization/jsonStringsToJsons.test.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.umd.js +35 -3
- package/umd/index.umd.js.map +1 -1
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-9';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1741,6 +1741,36 @@
|
|
|
1741
1741
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
1742
1742
|
*/
|
|
1743
1743
|
|
|
1744
|
+
/**
|
|
1745
|
+
* Recursively converts JSON strings to JSON objects
|
|
1746
|
+
|
|
1747
|
+
* @public exported from `@promptbook/utils`
|
|
1748
|
+
*/
|
|
1749
|
+
function jsonStringsToJsons(object) {
|
|
1750
|
+
if (object === null) {
|
|
1751
|
+
return object;
|
|
1752
|
+
}
|
|
1753
|
+
if (Array.isArray(object)) {
|
|
1754
|
+
return object.map(jsonStringsToJsons);
|
|
1755
|
+
}
|
|
1756
|
+
if (typeof object !== 'object') {
|
|
1757
|
+
return object;
|
|
1758
|
+
}
|
|
1759
|
+
const newObject = { ...object };
|
|
1760
|
+
for (const [key, value] of Object.entries(object)) {
|
|
1761
|
+
if (typeof value === 'string' && isValidJsonString(value)) {
|
|
1762
|
+
newObject[key] = JSON.parse(value);
|
|
1763
|
+
}
|
|
1764
|
+
else {
|
|
1765
|
+
newObject[key] = jsonStringsToJsons(value);
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
return newObject;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* TODO: Type the return type correctly
|
|
1772
|
+
*/
|
|
1773
|
+
|
|
1744
1774
|
/**
|
|
1745
1775
|
* This error indicates problems parsing the format value
|
|
1746
1776
|
*
|
|
@@ -1998,11 +2028,12 @@
|
|
|
1998
2028
|
let updatedAt = createdAt;
|
|
1999
2029
|
const errors = [];
|
|
2000
2030
|
const warnings = [];
|
|
2001
|
-
|
|
2031
|
+
let currentValue = {};
|
|
2002
2032
|
const partialResultSubject = new rxjs.Subject();
|
|
2003
2033
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2004
2034
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2005
2035
|
Object.assign(currentValue, newOngoingResult);
|
|
2036
|
+
// <- TODO: assign deep
|
|
2006
2037
|
partialResultSubject.next(newOngoingResult);
|
|
2007
2038
|
});
|
|
2008
2039
|
finalResultPromise
|
|
@@ -2022,7 +2053,8 @@
|
|
|
2022
2053
|
// And delete `ExecutionTask.currentValue.preparedPipeline`
|
|
2023
2054
|
assertsTaskSuccessful(executionResult);
|
|
2024
2055
|
status = 'FINISHED';
|
|
2025
|
-
|
|
2056
|
+
currentValue = jsonStringsToJsons(executionResult);
|
|
2057
|
+
// <- TODO: Convert JSON values in string to JSON objects
|
|
2026
2058
|
partialResultSubject.next(executionResult);
|
|
2027
2059
|
}
|
|
2028
2060
|
catch (error) {
|