@promptbook/pdf 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/pdf",
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/pdf.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
  "crypto": "^1.0.1",
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-8';
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
@@ -2080,6 +2080,36 @@
2080
2080
  * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
2081
2081
  */
2082
2082
 
2083
+ /**
2084
+ * Recursively converts JSON strings to JSON objects
2085
+
2086
+ * @public exported from `@promptbook/utils`
2087
+ */
2088
+ function jsonStringsToJsons(object) {
2089
+ if (object === null) {
2090
+ return object;
2091
+ }
2092
+ if (Array.isArray(object)) {
2093
+ return object.map(jsonStringsToJsons);
2094
+ }
2095
+ if (typeof object !== 'object') {
2096
+ return object;
2097
+ }
2098
+ const newObject = { ...object };
2099
+ for (const [key, value] of Object.entries(object)) {
2100
+ if (typeof value === 'string' && isValidJsonString(value)) {
2101
+ newObject[key] = JSON.parse(value);
2102
+ }
2103
+ else {
2104
+ newObject[key] = jsonStringsToJsons(value);
2105
+ }
2106
+ }
2107
+ return newObject;
2108
+ }
2109
+ /**
2110
+ * TODO: Type the return type correctly
2111
+ */
2112
+
2083
2113
  /**
2084
2114
  * This error indicates problems parsing the format value
2085
2115
  *
@@ -2311,11 +2341,12 @@
2311
2341
  let updatedAt = createdAt;
2312
2342
  const errors = [];
2313
2343
  const warnings = [];
2314
- const currentValue = {};
2344
+ let currentValue = {};
2315
2345
  const partialResultSubject = new rxjs.Subject();
2316
2346
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2317
2347
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
2318
2348
  Object.assign(currentValue, newOngoingResult);
2349
+ // <- TODO: assign deep
2319
2350
  partialResultSubject.next(newOngoingResult);
2320
2351
  });
2321
2352
  finalResultPromise
@@ -2335,7 +2366,8 @@
2335
2366
  // And delete `ExecutionTask.currentValue.preparedPipeline`
2336
2367
  assertsTaskSuccessful(executionResult);
2337
2368
  status = 'FINISHED';
2338
- Object.assign(currentValue, executionResult);
2369
+ currentValue = jsonStringsToJsons(executionResult);
2370
+ // <- TODO: Convert JSON values in string to JSON objects
2339
2371
  partialResultSubject.next(executionResult);
2340
2372
  }
2341
2373
  catch (error) {