@promptbook/utils 0.75.0-4 → 0.75.2
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 +22 -16
- package/esm/index.es.js +28 -17
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +6 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/config.d.ts +25 -0
- package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +0 -4
- package/esm/typings/src/pipeline/PipelineInterface/getPipelineInterface.d.ts +1 -3
- package/esm/typings/src/pipeline/PipelineInterface/isPipelineImplementingInterface.d.ts +1 -4
- package/esm/typings/src/pipeline/PipelineInterface/isPipelineInterfacesEqual.d.ts +1 -4
- package/esm/typings/src/utils/organization/spaceTrim.d.ts +11 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +26 -14
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
#  Promptbook
|
|
4
4
|
|
|
5
|
-
It's time for a paradigm shift! The future of software is in plain English, French or Latin.
|
|
6
|
-
|
|
7
5
|
|
|
8
6
|
|
|
9
7
|
|
|
@@ -25,10 +23,6 @@ It's time for a paradigm shift! The future of software is in plain English, Fren
|
|
|
25
23
|
|
|
26
24
|
|
|
27
25
|
|
|
28
|
-
<blockquote style="color: #ff8811">
|
|
29
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
30
|
-
</blockquote>
|
|
31
|
-
|
|
32
26
|
## 📦 Package `@promptbook/utils`
|
|
33
27
|
|
|
34
28
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -177,7 +171,7 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
177
171
|
|
|
178
172
|
## 🤍 The Book Abstract
|
|
179
173
|
|
|
180
|
-
|
|
174
|
+
**It's time for a paradigm shift! The future of software is in plain English, French or Latin.**
|
|
181
175
|
|
|
182
176
|
During the computer revolution, we have seen [multiple generations of computer languages](https://github.com/webgptorg/promptbook/discussions/180), from the physical rewiring of the vacuum tubes through low-level machine code to the high-level languages like Python or JavaScript. And now, we're on the edge of the **next revolution**!
|
|
183
177
|
|
|
@@ -187,11 +181,17 @@ The incredible growth in power of microprocessors and the Moore's Law have been
|
|
|
187
181
|
|
|
188
182
|
This shift is going to happen, whether we are ready for it or not. Our mission is to make it excellently, not just good.
|
|
189
183
|
|
|
190
|
-
|
|
184
|
+
**Join us in this journey!**
|
|
185
|
+
|
|
191
186
|
|
|
192
187
|
|
|
188
|
+
## 🚀 Get started
|
|
193
189
|
|
|
190
|
+
Take a look at the simple starter kit with books integrated into the **Hello World** sample applications:
|
|
194
191
|
|
|
192
|
+
- [Hello Book](https://github.com/webgptorg/hello-world)
|
|
193
|
+
- [Hello Book in Node.js](https://github.com/webgptorg/hello-world-node-js)
|
|
194
|
+
- [Hello Book in Next.js](https://github.com/webgptorg/hello-world-next-js)
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
|
|
@@ -211,7 +211,7 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
211
211
|
<tbody>
|
|
212
212
|
<tr>
|
|
213
213
|
<td>Core</td>
|
|
214
|
-
<td>Promptbook
|
|
214
|
+
<td>Promptbook Core is a description and documentation of the basic concepts, ideas and inner workings of how Promptbook should be implemented, and defines what features must be describable by book language.</td>
|
|
215
215
|
<td rowspan=2>https://ptbk.io<br/>https://github.com/webgptorg/book</td>
|
|
216
216
|
</tr>
|
|
217
217
|
<tr>
|
|
@@ -222,17 +222,23 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
222
222
|
</tr>
|
|
223
223
|
<tr>
|
|
224
224
|
<td>Promptbook typescript project</td>
|
|
225
|
-
<td>
|
|
225
|
+
<td>Promptbook implementation in TypeScript released as multiple NPM packages</td>
|
|
226
226
|
<td>https://github.com/webgptorg/promptbook + Multiple packages on NPM</td>
|
|
227
227
|
</tr>
|
|
228
228
|
<tr>
|
|
229
229
|
<td>Promptbook studio</td>
|
|
230
|
-
<td>
|
|
231
|
-
<td
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
<td>
|
|
230
|
+
<td>Studio to write Books and instantly publish them as miniapps</td>
|
|
231
|
+
<td>
|
|
232
|
+
https://promptbook.studio<br/>
|
|
233
|
+
https://github.com/hejny/promptbook-studio</td>
|
|
234
|
+
</tr><tr>
|
|
235
|
+
<td>Hello World</td>
|
|
236
|
+
<td>Simple starter kit with Books integrated into the sample applications</td>
|
|
237
|
+
<td>
|
|
238
|
+
https://github.com/webgptorg/hello-world<br/>
|
|
239
|
+
https://github.com/webgptorg/hello-world-node-js<br/>
|
|
240
|
+
https://github.com/webgptorg/hello-world-next-js
|
|
241
|
+
</td>
|
|
236
242
|
</tr>
|
|
237
243
|
</tbody>
|
|
238
244
|
</table>
|
package/esm/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import spaceTrim$
|
|
1
|
+
import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
2
|
import { basename } from 'path';
|
|
3
3
|
|
|
4
4
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -13,7 +13,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
13
13
|
*
|
|
14
14
|
* @see https://github.com/webgptorg/promptbook
|
|
15
15
|
*/
|
|
16
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.75.
|
|
16
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.75.1';
|
|
17
17
|
/**
|
|
18
18
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
19
19
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -146,7 +146,7 @@ function __spreadArray(to, from, pack) {
|
|
|
146
146
|
var UnexpectedError = /** @class */ (function (_super) {
|
|
147
147
|
__extends(UnexpectedError, _super);
|
|
148
148
|
function UnexpectedError(message) {
|
|
149
|
-
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
149
|
+
var _this = _super.call(this, spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
150
150
|
_this.name = 'UnexpectedError';
|
|
151
151
|
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
152
152
|
return _this;
|
|
@@ -659,7 +659,7 @@ function renderPromptbookMermaid(pipelineJson, options) {
|
|
|
659
659
|
}
|
|
660
660
|
return normalizeTo_camelCase('task-' + titleToName(task.title));
|
|
661
661
|
};
|
|
662
|
-
var promptbookMermaid = spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.tasks
|
|
662
|
+
var promptbookMermaid = spaceTrim$1(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.tasks
|
|
663
663
|
.flatMap(function (_a) {
|
|
664
664
|
var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
|
|
665
665
|
return __spreadArray([
|
|
@@ -787,7 +787,7 @@ function extractVariables(script) {
|
|
|
787
787
|
if (!(error instanceof Error)) {
|
|
788
788
|
throw error;
|
|
789
789
|
}
|
|
790
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n "); }));
|
|
790
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n "); }));
|
|
791
791
|
}
|
|
792
792
|
return variables;
|
|
793
793
|
}
|
|
@@ -1042,7 +1042,7 @@ var NotFoundError = /** @class */ (function (_super) {
|
|
|
1042
1042
|
var NotYetImplementedError = /** @class */ (function (_super) {
|
|
1043
1043
|
__extends(NotYetImplementedError, _super);
|
|
1044
1044
|
function NotYetImplementedError(message) {
|
|
1045
|
-
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
1045
|
+
var _this = _super.call(this, spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
1046
1046
|
_this.name = 'NotYetImplementedError';
|
|
1047
1047
|
Object.setPrototypeOf(_this, NotYetImplementedError.prototype);
|
|
1048
1048
|
return _this;
|
|
@@ -1126,7 +1126,7 @@ function deserializeError(error) {
|
|
|
1126
1126
|
function serializeError(error) {
|
|
1127
1127
|
var name = error.name, message = error.message, stack = error.stack;
|
|
1128
1128
|
if (!__spreadArray(['Error'], __read(Object.keys(ERRORS)), false).includes(name)) {
|
|
1129
|
-
throw new UnexpectedError(spaceTrim$
|
|
1129
|
+
throw new UnexpectedError(spaceTrim$2(function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
1130
1130
|
}
|
|
1131
1131
|
return {
|
|
1132
1132
|
name: name,
|
|
@@ -1632,6 +1632,17 @@ function searchKeywords(haystack, needle) {
|
|
|
1632
1632
|
return true;
|
|
1633
1633
|
}
|
|
1634
1634
|
|
|
1635
|
+
/**
|
|
1636
|
+
* Trims string from all 4 sides
|
|
1637
|
+
*
|
|
1638
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
1639
|
+
* Developed by same author @hejny as this package
|
|
1640
|
+
*
|
|
1641
|
+
* @public exported from `@promptbook/utils`
|
|
1642
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
1643
|
+
*/
|
|
1644
|
+
var spaceTrim = spaceTrim$1;
|
|
1645
|
+
|
|
1635
1646
|
/**
|
|
1636
1647
|
* @@@
|
|
1637
1648
|
*
|
|
@@ -1716,7 +1727,7 @@ function checkSerializableAsJson(name, value) {
|
|
|
1716
1727
|
}
|
|
1717
1728
|
else if (typeof value === 'object') {
|
|
1718
1729
|
if (value instanceof Date) {
|
|
1719
|
-
throw new UnexpectedError(spaceTrim$
|
|
1730
|
+
throw new UnexpectedError(spaceTrim$2("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
1720
1731
|
}
|
|
1721
1732
|
else if (value instanceof Map) {
|
|
1722
1733
|
throw new UnexpectedError("".concat(name, " is Map"));
|
|
@@ -1728,7 +1739,7 @@ function checkSerializableAsJson(name, value) {
|
|
|
1728
1739
|
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
1729
1740
|
}
|
|
1730
1741
|
else if (value instanceof Error) {
|
|
1731
|
-
throw new UnexpectedError(spaceTrim$
|
|
1742
|
+
throw new UnexpectedError(spaceTrim$2("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
1732
1743
|
}
|
|
1733
1744
|
else {
|
|
1734
1745
|
try {
|
|
@@ -1755,7 +1766,7 @@ function checkSerializableAsJson(name, value) {
|
|
|
1755
1766
|
if (!(error instanceof Error)) {
|
|
1756
1767
|
throw error;
|
|
1757
1768
|
}
|
|
1758
|
-
throw new UnexpectedError(spaceTrim$
|
|
1769
|
+
throw new UnexpectedError(spaceTrim$2(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
1759
1770
|
}
|
|
1760
1771
|
/*
|
|
1761
1772
|
TODO: [0] Is there some more elegant way to check circular references?
|
|
@@ -2259,13 +2270,13 @@ function union() {
|
|
|
2259
2270
|
* @public exported from `@promptbook/utils`
|
|
2260
2271
|
*/
|
|
2261
2272
|
function trimCodeBlock(value) {
|
|
2262
|
-
value = spaceTrim(value);
|
|
2273
|
+
value = spaceTrim$1(value);
|
|
2263
2274
|
if (!/^```[a-z]*(.*)```$/is.test(value)) {
|
|
2264
2275
|
return value;
|
|
2265
2276
|
}
|
|
2266
2277
|
value = value.replace(/^```[a-z]*/i, '');
|
|
2267
2278
|
value = value.replace(/```$/i, '');
|
|
2268
|
-
value = spaceTrim(value);
|
|
2279
|
+
value = spaceTrim$1(value);
|
|
2269
2280
|
return value;
|
|
2270
2281
|
}
|
|
2271
2282
|
|
|
@@ -2278,9 +2289,9 @@ function trimCodeBlock(value) {
|
|
|
2278
2289
|
* @public exported from `@promptbook/utils`
|
|
2279
2290
|
*/
|
|
2280
2291
|
function trimEndOfCodeBlock(value) {
|
|
2281
|
-
value = spaceTrim(value);
|
|
2292
|
+
value = spaceTrim$1(value);
|
|
2282
2293
|
value = value.replace(/```$/g, '');
|
|
2283
|
-
value = spaceTrim(value);
|
|
2294
|
+
value = spaceTrim$1(value);
|
|
2284
2295
|
return value;
|
|
2285
2296
|
}
|
|
2286
2297
|
|
|
@@ -2302,7 +2313,7 @@ function unwrapResult(text, options) {
|
|
|
2302
2313
|
var trimmedText = text;
|
|
2303
2314
|
// Remove leading and trailing spaces and newlines
|
|
2304
2315
|
if (isTrimmed) {
|
|
2305
|
-
trimmedText = spaceTrim(trimmedText);
|
|
2316
|
+
trimmedText = spaceTrim$1(trimmedText);
|
|
2306
2317
|
}
|
|
2307
2318
|
var processedText = trimmedText;
|
|
2308
2319
|
if (isIntroduceSentenceRemoved) {
|
|
@@ -2311,7 +2322,7 @@ function unwrapResult(text, options) {
|
|
|
2311
2322
|
// Remove the introduce sentence and quotes by replacing it with an empty string
|
|
2312
2323
|
processedText = processedText.replace(introduceSentenceRegex, '');
|
|
2313
2324
|
}
|
|
2314
|
-
processedText = spaceTrim(processedText);
|
|
2325
|
+
processedText = spaceTrim$1(processedText);
|
|
2315
2326
|
}
|
|
2316
2327
|
if (processedText.length < 3) {
|
|
2317
2328
|
return trimmedText;
|
|
@@ -2519,5 +2530,5 @@ function isValidUuid(value) {
|
|
|
2519
2530
|
return /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i.test(value);
|
|
2520
2531
|
}
|
|
2521
2532
|
|
|
2522
|
-
export { $currentDate, $deepFreeze, $isRunningInBrowser, $isRunningInNode, $isRunningInWebWorker, $randomSeed, BOOK_LANGUAGE_VERSION, CHARACTERS_PER_STANDARD_LINE, CountUtils, DIACRITIC_VARIANTS_LETTERS, LINES_PER_STANDARD_PAGE, PROMPTBOOK_ENGINE_VERSION, capitalize, checkSerializableAsJson, clonePipeline, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, decapitalize, deepClone, deserializeError, difference, extractParameterNames, extractParameterNamesFromTask, extractVariables, forEachAsync, intersection, isHostnameOnPrivateNetwork, isSerializableAsJson, isUrlOnPrivateNetwork, isValidEmail, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidKeyword, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, nameToUriPart, nameToUriParts, normalizeToKebabCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_camelCase, normalizeTo_snake_case, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, parseNumber, removeDiacritics, removeEmojis, removeQuotes, renameParameter, renderPromptbookMermaid, replaceParameters, searchKeywords, serializeError, splitIntoSentences, titleToName, trimCodeBlock, trimEndOfCodeBlock, union, unwrapResult };
|
|
2533
|
+
export { $currentDate, $deepFreeze, $isRunningInBrowser, $isRunningInNode, $isRunningInWebWorker, $randomSeed, BOOK_LANGUAGE_VERSION, CHARACTERS_PER_STANDARD_LINE, CountUtils, DIACRITIC_VARIANTS_LETTERS, LINES_PER_STANDARD_PAGE, PROMPTBOOK_ENGINE_VERSION, capitalize, checkSerializableAsJson, clonePipeline, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, decapitalize, deepClone, deserializeError, difference, extractParameterNames, extractParameterNamesFromTask, extractVariables, forEachAsync, intersection, isHostnameOnPrivateNetwork, isSerializableAsJson, isUrlOnPrivateNetwork, isValidEmail, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidKeyword, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, nameToUriPart, nameToUriParts, normalizeToKebabCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_camelCase, normalizeTo_snake_case, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, parseNumber, removeDiacritics, removeEmojis, removeQuotes, renameParameter, renderPromptbookMermaid, replaceParameters, searchKeywords, serializeError, spaceTrim, splitIntoSentences, titleToName, trimCodeBlock, trimEndOfCodeBlock, union, unwrapResult };
|
|
2523
2534
|
//# sourceMappingURL=index.es.js.map
|