@promptbook/remote-server 0.89.0-5 → 0.89.0-6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.89.0-5",
3
+ "version": "0.89.0-6",
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/remote-server.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.89.0-5"
50
+ "@promptbook/core": "0.89.0-6"
51
51
  },
52
52
  "dependencies": {
53
53
  "colors": "1.4.0",
@@ -59,6 +59,8 @@
59
59
  "rxjs": "^7.8.1",
60
60
  "socket.io": "4.8.1",
61
61
  "spacetrim": "0.11.59",
62
+ "swagger-jsdoc": "^6.2.8",
63
+ "swagger-ui-express": "^5.0.1",
62
64
  "userhome": "1.0.1",
63
65
  "waitasecond": "1.11.83"
64
66
  }
package/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('express'), require('http'), require('socket.io'), require('spacetrim'), require('waitasecond'), require('crypto'), require('child_process'), require('fs/promises'), require('path'), require('rxjs'), require('prettier'), require('prettier/parser-html'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('papaparse')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'colors', 'express', 'http', 'socket.io', 'spacetrim', 'waitasecond', 'crypto', 'child_process', 'fs/promises', 'path', 'rxjs', 'prettier', 'prettier/parser-html', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'papaparse'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.express, global.http, global.socket_io, global.spaceTrim, global.waitasecond, global.crypto, global.child_process, global.promises, global.path, global.rxjs, global.prettier, global.parserHtml, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse));
5
- })(this, (function (exports, colors, express, http, socket_io, spaceTrim, waitasecond, crypto, child_process, promises, path, rxjs, prettier, parserHtml, hexEncoder, sha256, cryptoJs, mimeTypes, papaparse) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('express'), require('http'), require('socket.io'), require('spacetrim'), require('swagger-jsdoc'), require('swagger-ui-express'), require('waitasecond'), require('crypto'), require('child_process'), require('fs/promises'), require('path'), require('rxjs'), require('prettier'), require('prettier/parser-html'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('papaparse')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'colors', 'express', 'http', 'socket.io', 'spacetrim', 'swagger-jsdoc', 'swagger-ui-express', 'waitasecond', 'crypto', 'child_process', 'fs/promises', 'path', 'rxjs', 'prettier', 'prettier/parser-html', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'papaparse'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.express, global.http, global.socket_io, global.spaceTrim, global.swaggerJsdoc, global.swaggerUi, global.waitasecond, global.crypto, global.child_process, global.promises, global.path, global.rxjs, global.prettier, global.parserHtml, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse));
5
+ })(this, (function (exports, colors, express, http, socket_io, spaceTrim, swaggerJsdoc, swaggerUi, waitasecond, crypto, child_process, promises, path, rxjs, prettier, parserHtml, hexEncoder, sha256, cryptoJs, mimeTypes, papaparse) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -10,6 +10,8 @@
10
10
  var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
11
11
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
12
12
  var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
13
+ var swaggerJsdoc__default = /*#__PURE__*/_interopDefaultLegacy(swaggerJsdoc);
14
+ var swaggerUi__default = /*#__PURE__*/_interopDefaultLegacy(swaggerUi);
13
15
  var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
14
16
  var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
15
17
  var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
@@ -28,7 +30,7 @@
28
30
  * @generated
29
31
  * @see https://github.com/webgptorg/promptbook
30
32
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-5';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-6';
32
34
  /**
33
35
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
36
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -6779,9 +6781,37 @@
6779
6781
  response.setHeader('X-Powered-By', 'Promptbook engine');
6780
6782
  next();
6781
6783
  });
6784
+ const swaggerOptions = {
6785
+ definition: {
6786
+ openapi: '3.0.0',
6787
+ info: {
6788
+ title: 'Promptbook Remote Server API',
6789
+ version: '1.0.0',
6790
+ description: 'API documentation for the Promptbook Remote Server',
6791
+ },
6792
+ servers: [
6793
+ {
6794
+ url: `http://localhost:${port}${rootPath}`,
6795
+ },
6796
+ ],
6797
+ },
6798
+ apis: ['./src/remote-server/**/*.ts'], // Adjust path as needed
6799
+ };
6800
+ const swaggerSpec = swaggerJsdoc__default["default"](swaggerOptions);
6801
+ app.use(`${rootPath}/api-docs`, swaggerUi__default["default"].serve, swaggerUi__default["default"].setup(swaggerSpec));
6782
6802
  const runningExecutionTasks = [];
6783
6803
  // <- TODO: [🤬] Identify the users
6784
6804
  // TODO: [🧠] Do here some garbage collection of finished tasks
6805
+ /**
6806
+ * @swagger
6807
+ * /:
6808
+ * get:
6809
+ * summary: Get server details
6810
+ * description: Returns details about the Promptbook server.
6811
+ * responses:
6812
+ * 200:
6813
+ * description: Server details in markdown format.
6814
+ */
6785
6815
  app.get(['/', rootPath], async (request, response) => {
6786
6816
  var _a;
6787
6817
  if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.includes('socket.io')) {
@@ -6839,6 +6869,22 @@
6839
6869
  `));
6840
6870
  });
6841
6871
  // TODO: !!!!!! Add login route
6872
+ /**
6873
+ * @swagger
6874
+ * /books:
6875
+ * get:
6876
+ * summary: List all books
6877
+ * description: Returns a list of all available books in the collection.
6878
+ * responses:
6879
+ * 200:
6880
+ * description: A list of books.
6881
+ * content:
6882
+ * application/json:
6883
+ * schema:
6884
+ * type: array
6885
+ * items:
6886
+ * type: string
6887
+ */
6842
6888
  app.get(`${rootPath}/books`, async (request, response) => {
6843
6889
  if (collection === null) {
6844
6890
  response.status(500).send('No collection available');
@@ -6849,6 +6895,29 @@
6849
6895
  response.send(pipelines);
6850
6896
  });
6851
6897
  // TODO: [🧠] Is it secure / good idea to expose source codes of hosted books
6898
+ /**
6899
+ * @swagger
6900
+ * /books/{bookId}:
6901
+ * get:
6902
+ * summary: Get book content
6903
+ * description: Returns the content of a specific book.
6904
+ * parameters:
6905
+ * - in: path
6906
+ * name: bookId
6907
+ * required: true
6908
+ * schema:
6909
+ * type: string
6910
+ * description: The ID of the book to retrieve.
6911
+ * responses:
6912
+ * 200:
6913
+ * description: The content of the book.
6914
+ * content:
6915
+ * text/markdown:
6916
+ * schema:
6917
+ * type: string
6918
+ * 404:
6919
+ * description: Book not found.
6920
+ */
6852
6921
  app.get(`${rootPath}/books/*`, async (request, response) => {
6853
6922
  try {
6854
6923
  if (collection === null) {
@@ -6903,6 +6972,22 @@
6903
6972
  };
6904
6973
  }
6905
6974
  }
6975
+ /**
6976
+ * @swagger
6977
+ * /executions:
6978
+ * get:
6979
+ * summary: List all executions
6980
+ * description: Returns a list of all running execution tasks.
6981
+ * responses:
6982
+ * 200:
6983
+ * description: A list of execution tasks.
6984
+ * content:
6985
+ * application/json:
6986
+ * schema:
6987
+ * type: array
6988
+ * items:
6989
+ * type: object
6990
+ */
6906
6991
  app.get(`${rootPath}/executions`, async (request, response) => {
6907
6992
  response.send(runningExecutionTasks.map((runningExecutionTask) => exportExecutionTask(runningExecutionTask, false)));
6908
6993
  });
@@ -6927,6 +7012,35 @@
6927
7012
  }
6928
7013
  response.send(exportExecutionTask(executionTask, true));
6929
7014
  });
7015
+ /**
7016
+ * @swagger
7017
+ * /executions/new:
7018
+ * post:
7019
+ * summary: Start a new execution
7020
+ * description: Starts a new execution task for a given pipeline.
7021
+ * requestBody:
7022
+ * required: true
7023
+ * content:
7024
+ * application/json:
7025
+ * schema:
7026
+ * type: object
7027
+ * properties:
7028
+ * pipelineUrl:
7029
+ * type: string
7030
+ * inputParameters:
7031
+ * type: object
7032
+ * identification:
7033
+ * type: object
7034
+ * responses:
7035
+ * 200:
7036
+ * description: The newly created execution task.
7037
+ * content:
7038
+ * application/json:
7039
+ * schema:
7040
+ * type: object
7041
+ * 400:
7042
+ * description: Invalid input.
7043
+ */
6930
7044
  app.post(`${rootPath}/executions/new`, async (request, response) => {
6931
7045
  try {
6932
7046
  const { inputParameters, identification /* <- [🤬] */ } = request.body;