retold 1.0.6 → 4.0.1

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.
Files changed (71) hide show
  1. package/.claude/settings.local.json +58 -0
  2. package/CLAUDE.md +52 -0
  3. package/docs/.nojekyll +0 -0
  4. package/docs/README.md +161 -0
  5. package/docs/_sidebar.md +65 -0
  6. package/docs/_topbar.md +6 -0
  7. package/docs/architecture.md +312 -0
  8. package/docs/cover.md +15 -0
  9. package/docs/css/docuserve.css +73 -0
  10. package/docs/fable.md +198 -0
  11. package/docs/getting-started.md +272 -0
  12. package/docs/index.html +39 -0
  13. package/docs/js/pict.min.js +12 -0
  14. package/docs/js/pict.min.js.map +1 -0
  15. package/docs/meadow.md +211 -0
  16. package/docs/modules.md +96 -0
  17. package/docs/orator.md +164 -0
  18. package/docs/pict-docuserve.min.js +58 -0
  19. package/docs/pict-docuserve.min.js.map +1 -0
  20. package/docs/pict.md +213 -0
  21. package/docs/retold-building-documentation.md +33 -0
  22. package/docs/retold-catalog.json +2826 -0
  23. package/docs/retold-keyword-index.json +161289 -0
  24. package/docs/utility.md +63 -0
  25. package/examples/quickstart/README.md +47 -0
  26. package/examples/quickstart/layer1/README.md +21 -0
  27. package/examples/quickstart/layer1/index.js +49 -0
  28. package/examples/quickstart/layer1/package-lock.json +344 -0
  29. package/examples/quickstart/layer1/package.json +12 -0
  30. package/examples/quickstart/layer2/README.md +34 -0
  31. package/examples/quickstart/layer2/index.js +251 -0
  32. package/examples/quickstart/layer2/package-lock.json +4468 -0
  33. package/examples/quickstart/layer2/package.json +17 -0
  34. package/examples/quickstart/layer2/setup-database.js +61 -0
  35. package/examples/quickstart/layer3/README.md +39 -0
  36. package/examples/quickstart/layer3/index.js +91 -0
  37. package/examples/quickstart/layer3/package-lock.json +1936 -0
  38. package/examples/quickstart/layer3/package.json +14 -0
  39. package/examples/quickstart/layer4/README.md +47 -0
  40. package/examples/quickstart/layer4/generate-build-config.js +18 -0
  41. package/examples/quickstart/layer4/html/index.html +17 -0
  42. package/examples/quickstart/layer4/package-lock.json +13206 -0
  43. package/examples/quickstart/layer4/package.json +38 -0
  44. package/examples/quickstart/layer4/server.js +28 -0
  45. package/examples/quickstart/layer4/source/BookStore-Application-Config.json +15 -0
  46. package/examples/quickstart/layer4/source/BookStore-Application.js +54 -0
  47. package/examples/quickstart/layer4/source/providers/Router-Config.json +18 -0
  48. package/examples/quickstart/layer4/source/views/View-About.js +38 -0
  49. package/examples/quickstart/layer4/source/views/View-Home.js +50 -0
  50. package/examples/quickstart/layer4/source/views/View-Layout.js +60 -0
  51. package/examples/quickstart/layer5/README.md +26 -0
  52. package/examples/quickstart/layer5/index.js +121 -0
  53. package/examples/quickstart/layer5/package-lock.json +345 -0
  54. package/examples/quickstart/layer5/package.json +13 -0
  55. package/modules/.claude/settings.local.json +52 -0
  56. package/modules/CLAUDE.md +60 -0
  57. package/modules/Checkout.sh +42 -0
  58. package/modules/Include-Retold-Module-List.sh +15 -0
  59. package/modules/Retold-Modules.md +24 -0
  60. package/modules/Status.sh +59 -0
  61. package/modules/Update.sh +45 -0
  62. package/modules/fable/Fable.md +2 -0
  63. package/modules/meadow/Meadow.md +1 -0
  64. package/modules/orator/Orator.md +1 -0
  65. package/modules/pict/Pict.md +1 -0
  66. package/package.json +30 -35
  67. package/source/Retold.cjs +2 -0
  68. package/test/Retold_tests.js +23 -41
  69. package/.travis.yml +0 -13
  70. package/source/Retold-Meadow-Macros.js +0 -269
  71. package/source/Retold.js +0 -48
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "retold-quickstart-layer2-meadow",
3
+ "version": "1.0.0",
4
+ "description": "Retold Quickstart: Layer 2 - Meadow (Data Access with MySQL)",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "setup": "node setup-database.js",
8
+ "start": "node index.js",
9
+ "demo": "npm run setup && npm start"
10
+ },
11
+ "dependencies": {
12
+ "fable": "^3.1.51",
13
+ "meadow": "^2.0.18",
14
+ "meadow-connection-mysql": "^1.0.6",
15
+ "mysql2": "^3.6.3"
16
+ }
17
+ }
@@ -0,0 +1,61 @@
1
+ // Setup script: creates the database and table for the Meadow example.
2
+ const libMySQL = require('mysql2');
3
+
4
+ const MYSQL_CONFIG =
5
+ {
6
+ host: '127.0.0.1',
7
+ port: 3306,
8
+ user: 'root',
9
+ password: '123456789'
10
+ };
11
+
12
+ const tmpConnection = libMySQL.createConnection(MYSQL_CONFIG);
13
+
14
+ const tmpStatements =
15
+ [
16
+ `CREATE DATABASE IF NOT EXISTS retold_quickstart;`,
17
+ `USE retold_quickstart;`,
18
+ `CREATE TABLE IF NOT EXISTS Book
19
+ (
20
+ IDBook INT UNSIGNED NOT NULL AUTO_INCREMENT,
21
+ GUIDBook CHAR(36) DEFAULT '0x0',
22
+ CreateDate DATETIME,
23
+ CreatingIDUser INT NOT NULL DEFAULT 0,
24
+ UpdateDate DATETIME,
25
+ UpdatingIDUser INT NOT NULL DEFAULT 0,
26
+ Deleted TINYINT NOT NULL DEFAULT 0,
27
+ DeletingIDUser INT NOT NULL DEFAULT 0,
28
+ DeleteDate DATETIME,
29
+ Title CHAR(200) NOT NULL DEFAULT '',
30
+ Author CHAR(200) NOT NULL DEFAULT '',
31
+ YearPublished INT NOT NULL DEFAULT 0,
32
+ PRIMARY KEY (IDBook)
33
+ ) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;`
34
+ ];
35
+
36
+ let tmpIndex = 0;
37
+
38
+ function runNext()
39
+ {
40
+ if (tmpIndex >= tmpStatements.length)
41
+ {
42
+ console.log('Database setup complete.');
43
+ tmpConnection.end();
44
+ return;
45
+ }
46
+
47
+ tmpConnection.query(tmpStatements[tmpIndex],
48
+ function (pError)
49
+ {
50
+ if (pError)
51
+ {
52
+ console.error(`Error running statement ${tmpIndex}:`, pError.message);
53
+ tmpConnection.end();
54
+ process.exit(1);
55
+ }
56
+ tmpIndex++;
57
+ runNext();
58
+ });
59
+ }
60
+
61
+ runNext();
@@ -0,0 +1,39 @@
1
+ # Layer 4: Orator - REST API Server
2
+
3
+ > Retold Layer 4 — API Server: HTTP lifecycle management, middleware,
4
+ > content negotiation, static file serving, with pluggable server implementations
5
+ > (Restify, IPC)
6
+
7
+ Orator provides a consistent HTTP server interface. This example uses the
8
+ Restify service server for production HTTP. Orator also supports an IPC mode
9
+ for in-process testing without network overhead.
10
+
11
+ In a full Retold application, Layer 3 (Meadow-Endpoints) auto-generates CRUD
12
+ routes from your Meadow entities and wires them to Orator. This example shows
13
+ Orator with manually defined routes.
14
+
15
+ ## Run
16
+
17
+ ```bash
18
+ npm install
19
+ npm start
20
+ ```
21
+
22
+ Then test with curl:
23
+
24
+ ```bash
25
+ curl http://localhost:8080/health
26
+ curl http://localhost:8080/api/books
27
+ curl http://localhost:8080/api/books/1
28
+ curl -X POST http://localhost:8080/api/books \
29
+ -H "Content-Type: application/json" \
30
+ -d '{"title":"Snow Crash","author":"Neal Stephenson","year":1992}'
31
+ ```
32
+
33
+ ## What This Demonstrates
34
+
35
+ - Creating an HTTP server with Orator and the Restify service server
36
+ - Defining GET and POST routes with request/response handling
37
+ - Route parameters and JSON responses
38
+ - Body parsing middleware (postWithBodyParser)
39
+ - Starting and stopping the server lifecycle
@@ -0,0 +1,91 @@
1
+ const libFable = require('fable');
2
+ const libOrator = require('orator');
3
+ const libOratorServiceServerRestify = require('orator-serviceserver-restify');
4
+
5
+ // 1. Create Fable
6
+ let _Fable = new libFable(
7
+ {
8
+ Product: 'BookStore-API',
9
+ ProductVersion: '1.0.0',
10
+ APIServerPort: 8080
11
+ });
12
+
13
+ // 2. Register the Restify service server, then Orator
14
+ _Fable.serviceManager.addServiceType('OratorServiceServer', libOratorServiceServerRestify);
15
+ _Fable.serviceManager.instantiateServiceProvider('OratorServiceServer');
16
+ _Fable.serviceManager.addServiceType('Orator', libOrator);
17
+ let _Orator = _Fable.serviceManager.instantiateServiceProvider('Orator');
18
+
19
+ // In-memory book store for this example
20
+ let _Books =
21
+ [
22
+ { id: 1, title: 'The Hobbit', author: 'J.R.R. Tolkien', year: 1937 },
23
+ { id: 2, title: 'Dune', author: 'Frank Herbert', year: 1965 },
24
+ { id: 3, title: 'Neuromancer', author: 'William Gibson', year: 1984 }
25
+ ];
26
+ let _NextID = 4;
27
+
28
+ // 3. Initialize and start the server
29
+ _Orator.initialize(
30
+ function ()
31
+ {
32
+ // 4. Define routes
33
+
34
+ // Health check
35
+ _Orator.serviceServer.get('/health',
36
+ function (pRequest, pResponse, fNext)
37
+ {
38
+ pResponse.send({ status: 'ok', product: _Fable.settings.Product });
39
+ return fNext();
40
+ });
41
+
42
+ // List all books
43
+ _Orator.serviceServer.get('/api/books',
44
+ function (pRequest, pResponse, fNext)
45
+ {
46
+ pResponse.send(_Books);
47
+ return fNext();
48
+ });
49
+
50
+ // Get a single book by ID
51
+ _Orator.serviceServer.get('/api/books/:id',
52
+ function (pRequest, pResponse, fNext)
53
+ {
54
+ let tmpBook = _Books.find((b) => b.id === parseInt(pRequest.params.id));
55
+ if (!tmpBook)
56
+ {
57
+ pResponse.send(404, { error: 'Book not found' });
58
+ return fNext();
59
+ }
60
+ pResponse.send(tmpBook);
61
+ return fNext();
62
+ });
63
+
64
+ // Create a book (with body parser for JSON)
65
+ _Orator.serviceServer.postWithBodyParser('/api/books',
66
+ function (pRequest, pResponse, fNext)
67
+ {
68
+ let tmpBook =
69
+ {
70
+ id: _NextID++,
71
+ title: pRequest.body.title || 'Untitled',
72
+ author: pRequest.body.author || 'Unknown',
73
+ year: pRequest.body.year || 0
74
+ };
75
+ _Books.push(tmpBook);
76
+ _Fable.log.info(`Created book: "${tmpBook.title}"`);
77
+ pResponse.send(201, tmpBook);
78
+ return fNext();
79
+ });
80
+
81
+ // 5. Start listening
82
+ _Orator.startService(
83
+ function ()
84
+ {
85
+ _Fable.log.info('Try these commands:');
86
+ _Fable.log.info(' curl http://localhost:8080/health');
87
+ _Fable.log.info(' curl http://localhost:8080/api/books');
88
+ _Fable.log.info(' curl http://localhost:8080/api/books/1');
89
+ _Fable.log.info(' curl -X POST http://localhost:8080/api/books -H "Content-Type: application/json" -d \'{"title":"Snow Crash","author":"Neal Stephenson","year":1992}\'');
90
+ });
91
+ });