retold 1.0.6 → 4.0.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/.claude/settings.local.json +84 -0
- package/CLAUDE.md +52 -0
- package/docs/.nojekyll +0 -0
- package/docs/README.md +162 -0
- package/docs/_sidebar.md +78 -0
- package/docs/_topbar.md +6 -0
- package/docs/architecture/architecture.md +312 -0
- package/docs/architecture/module-architecture.md +234 -0
- package/docs/architecture/modules.md +99 -0
- package/docs/cover.md +15 -0
- package/docs/css/docuserve.css +73 -0
- package/docs/examples/examples.md +71 -0
- package/docs/examples/todolist/todo-list-cli-client.md +178 -0
- package/docs/examples/todolist/todo-list-console-client.md +152 -0
- package/docs/examples/todolist/todo-list-model.md +114 -0
- package/docs/examples/todolist/todo-list-server.md +128 -0
- package/docs/examples/todolist/todo-list-web-client.md +177 -0
- package/docs/examples/todolist/todo-list.md +162 -0
- package/docs/getting-started.md +273 -0
- package/docs/index.html +39 -0
- package/docs/modules/fable.md +198 -0
- package/docs/modules/meadow.md +209 -0
- package/docs/modules/orator.md +165 -0
- package/docs/modules/pict.md +235 -0
- package/docs/modules/utility.md +54 -0
- package/docs/retold-building-documentation.md +33 -0
- package/docs/retold-catalog.json +1405 -0
- package/docs/retold-keyword-index.json +203389 -0
- package/examples/quickstart/README.md +47 -0
- package/examples/quickstart/layer1/README.md +21 -0
- package/examples/quickstart/layer1/index.js +49 -0
- package/examples/quickstart/layer1/package-lock.json +344 -0
- package/examples/quickstart/layer1/package.json +12 -0
- package/examples/quickstart/layer2/README.md +34 -0
- package/examples/quickstart/layer2/index.js +251 -0
- package/examples/quickstart/layer2/package-lock.json +4468 -0
- package/examples/quickstart/layer2/package.json +17 -0
- package/examples/quickstart/layer2/setup-database.js +61 -0
- package/examples/quickstart/layer3/README.md +39 -0
- package/examples/quickstart/layer3/index.js +91 -0
- package/examples/quickstart/layer3/package-lock.json +1936 -0
- package/examples/quickstart/layer3/package.json +14 -0
- package/examples/quickstart/layer4/README.md +47 -0
- package/examples/quickstart/layer4/generate-build-config.js +18 -0
- package/examples/quickstart/layer4/html/index.html +17 -0
- package/examples/quickstart/layer4/package-lock.json +13206 -0
- package/examples/quickstart/layer4/package.json +38 -0
- package/examples/quickstart/layer4/server.js +28 -0
- package/examples/quickstart/layer4/source/BookStore-Application-Config.json +15 -0
- package/examples/quickstart/layer4/source/BookStore-Application.js +54 -0
- package/examples/quickstart/layer4/source/providers/Router-Config.json +18 -0
- package/examples/quickstart/layer4/source/views/View-About.js +38 -0
- package/examples/quickstart/layer4/source/views/View-Home.js +50 -0
- package/examples/quickstart/layer4/source/views/View-Layout.js +60 -0
- package/examples/quickstart/layer5/README.md +26 -0
- package/examples/quickstart/layer5/index.js +121 -0
- package/examples/quickstart/layer5/package-lock.json +345 -0
- package/examples/quickstart/layer5/package.json +13 -0
- package/examples/todo-list/Dockerfile +45 -0
- package/examples/todo-list/README.md +394 -0
- package/examples/todo-list/cli-client/package-lock.json +418 -0
- package/examples/todo-list/cli-client/package.json +19 -0
- package/examples/todo-list/cli-client/source/TodoCLI-CLIProgram.js +30 -0
- package/examples/todo-list/cli-client/source/TodoCLI-Run.js +3 -0
- package/examples/todo-list/cli-client/source/commands/add/TodoCLI-Command-Add.js +74 -0
- package/examples/todo-list/cli-client/source/commands/complete/TodoCLI-Command-Complete.js +84 -0
- package/examples/todo-list/cli-client/source/commands/list/TodoCLI-Command-List.js +110 -0
- package/examples/todo-list/cli-client/source/commands/remove/TodoCLI-Command-Remove.js +49 -0
- package/examples/todo-list/cli-client/source/services/TodoCLI-Service-API.js +92 -0
- package/examples/todo-list/console-client/console-client.cjs +913 -0
- package/examples/todo-list/console-client/package-lock.json +426 -0
- package/examples/todo-list/console-client/package.json +19 -0
- package/examples/todo-list/console-client/views/PictView-TUI-Header.cjs +43 -0
- package/examples/todo-list/console-client/views/PictView-TUI-Layout.cjs +58 -0
- package/examples/todo-list/console-client/views/PictView-TUI-StatusBar.cjs +41 -0
- package/examples/todo-list/console-client/views/PictView-TUI-TaskList.cjs +104 -0
- package/examples/todo-list/docker-motd.sh +36 -0
- package/examples/todo-list/docker-run.sh +2 -0
- package/examples/todo-list/docker-shell.sh +2 -0
- package/examples/todo-list/model/MeadowSchema-Task.json +152 -0
- package/examples/todo-list/model/Task-Compiled.json +25 -0
- package/examples/todo-list/model/Task.mddl +15 -0
- package/examples/todo-list/model/data/seeded_todo_events.csv +1001 -0
- package/examples/todo-list/server/database-initialization-service.cjs +273 -0
- package/examples/todo-list/server/package-lock.json +6113 -0
- package/examples/todo-list/server/package.json +19 -0
- package/examples/todo-list/server/server.cjs +138 -0
- package/examples/todo-list/web-client/css/todolist-theme.css +235 -0
- package/examples/todo-list/web-client/generate-build-config.cjs +18 -0
- package/examples/todo-list/web-client/html/index.html +18 -0
- package/examples/todo-list/web-client/package-lock.json +12030 -0
- package/examples/todo-list/web-client/package.json +43 -0
- package/examples/todo-list/web-client/source/TodoList-Application-Config.json +12 -0
- package/examples/todo-list/web-client/source/TodoList-Application.cjs +383 -0
- package/examples/todo-list/web-client/source/providers/Provider-TaskData.cjs +243 -0
- package/examples/todo-list/web-client/source/providers/Router-Config.json +32 -0
- package/examples/todo-list/web-client/source/views/View-Layout.cjs +75 -0
- package/examples/todo-list/web-client/source/views/View-TaskForm.cjs +87 -0
- package/examples/todo-list/web-client/source/views/View-TaskList.cjs +127 -0
- package/examples/todo-list/web-client/source/views/calendar/View-MonthView.cjs +293 -0
- package/examples/todo-list/web-client/source/views/calendar/View-WeekView.cjs +149 -0
- package/examples/todo-list/web-client/source/views/calendar/View-YearView.cjs +226 -0
- package/modules/.claude/settings.local.json +52 -0
- package/modules/CLAUDE.md +60 -0
- package/modules/Checkout.sh +42 -0
- package/modules/Include-Retold-Module-List.sh +15 -0
- package/modules/Retold-Modules.md +24 -0
- package/modules/Status.sh +59 -0
- package/modules/Update.sh +45 -0
- package/modules/fable/Fable.md +2 -0
- package/modules/meadow/Meadow.md +1 -0
- package/modules/orator/Orator.md +1 -0
- package/modules/pict/Pict.md +1 -0
- package/package.json +30 -35
- package/source/Retold.cjs +2 -0
- package/test/Retold_tests.js +23 -41
- package/.travis.yml +0 -13
- package/source/Retold-Meadow-Macros.js +0 -269
- package/source/Retold.js +0 -48
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
const libFable = require('fable');
|
|
2
|
+
const libMeadow = require('meadow');
|
|
3
|
+
const libMeadowConnectionMySQL = require('meadow-connection-mysql');
|
|
4
|
+
|
|
5
|
+
// 1. Create Fable with MySQL configuration
|
|
6
|
+
let _Fable = new libFable(
|
|
7
|
+
{
|
|
8
|
+
Product: 'BookStore',
|
|
9
|
+
ProductVersion: '1.0.0',
|
|
10
|
+
MySQL:
|
|
11
|
+
{
|
|
12
|
+
Server: '127.0.0.1',
|
|
13
|
+
Port: 3306,
|
|
14
|
+
User: 'root',
|
|
15
|
+
Password: '123456789',
|
|
16
|
+
Database: 'retold_quickstart',
|
|
17
|
+
ConnectionPoolLimit: 5
|
|
18
|
+
},
|
|
19
|
+
MeadowConnectionMySQLAutoConnect: true
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// 2. Register the MySQL connection provider
|
|
23
|
+
_Fable.serviceManager.addAndInstantiateServiceType('MeadowMySQLProvider', libMeadowConnectionMySQL);
|
|
24
|
+
|
|
25
|
+
// 3. Define the Meadow schema (column metadata for query generation)
|
|
26
|
+
let _BookSchema =
|
|
27
|
+
[
|
|
28
|
+
{ Column: 'IDBook', Type: 'AutoIdentity' },
|
|
29
|
+
{ Column: 'GUIDBook', Type: 'AutoGUID' },
|
|
30
|
+
{ Column: 'CreateDate', Type: 'CreateDate' },
|
|
31
|
+
{ Column: 'CreatingIDUser', Type: 'CreateIDUser' },
|
|
32
|
+
{ Column: 'UpdateDate', Type: 'UpdateDate' },
|
|
33
|
+
{ Column: 'UpdatingIDUser', Type: 'UpdateIDUser' },
|
|
34
|
+
{ Column: 'Deleted', Type: 'Deleted' },
|
|
35
|
+
{ Column: 'DeletingIDUser', Type: 'DeleteIDUser' },
|
|
36
|
+
{ Column: 'DeleteDate', Type: 'DeleteDate' },
|
|
37
|
+
{ Column: 'Title', Type: 'String' },
|
|
38
|
+
{ Column: 'Author', Type: 'String' },
|
|
39
|
+
{ Column: 'YearPublished', Type: 'Numeric' }
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
// 4. Define a JSON schema (for validation)
|
|
43
|
+
let _BookJsonSchema =
|
|
44
|
+
{
|
|
45
|
+
title: 'Book',
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties:
|
|
48
|
+
{
|
|
49
|
+
IDBook: { type: 'integer' },
|
|
50
|
+
Title: { type: 'string' },
|
|
51
|
+
Author: { type: 'string' },
|
|
52
|
+
YearPublished: { type: 'integer' }
|
|
53
|
+
},
|
|
54
|
+
required: ['IDBook']
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// 5. Define default values for new records
|
|
58
|
+
let _BookDefault =
|
|
59
|
+
{
|
|
60
|
+
IDBook: null,
|
|
61
|
+
GUIDBook: '',
|
|
62
|
+
CreateDate: false,
|
|
63
|
+
CreatingIDUser: 0,
|
|
64
|
+
UpdateDate: false,
|
|
65
|
+
UpdatingIDUser: 0,
|
|
66
|
+
Deleted: 0,
|
|
67
|
+
DeleteDate: false,
|
|
68
|
+
DeletingIDUser: 0,
|
|
69
|
+
Title: 'Unknown',
|
|
70
|
+
Author: 'Unknown',
|
|
71
|
+
YearPublished: 0
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// 6. Create the Meadow entity
|
|
75
|
+
let _BookMeadow = libMeadow.new(_Fable, 'Book')
|
|
76
|
+
.setProvider('MySQL')
|
|
77
|
+
.setSchema(_BookSchema)
|
|
78
|
+
.setJsonSchema(_BookJsonSchema)
|
|
79
|
+
.setDefaultIdentifier('IDBook')
|
|
80
|
+
.setDefault(_BookDefault)
|
|
81
|
+
.setIDUser(1);
|
|
82
|
+
|
|
83
|
+
_Fable.log.info('--- Meadow CRUD Demo ---');
|
|
84
|
+
|
|
85
|
+
// 7. Create some books
|
|
86
|
+
let _CreatedIDs = [];
|
|
87
|
+
|
|
88
|
+
function createBooks(fCallback)
|
|
89
|
+
{
|
|
90
|
+
let tmpBooks =
|
|
91
|
+
[
|
|
92
|
+
{ Title: 'The Hobbit', Author: 'J.R.R. Tolkien', YearPublished: 1937 },
|
|
93
|
+
{ Title: 'Dune', Author: 'Frank Herbert', YearPublished: 1965 },
|
|
94
|
+
{ Title: 'Neuromancer', Author: 'William Gibson', YearPublished: 1984 }
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
let tmpIndex = 0;
|
|
98
|
+
|
|
99
|
+
function createNext()
|
|
100
|
+
{
|
|
101
|
+
if (tmpIndex >= tmpBooks.length)
|
|
102
|
+
{
|
|
103
|
+
return fCallback();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let tmpQuery = _BookMeadow.query.addRecord(tmpBooks[tmpIndex]);
|
|
107
|
+
_BookMeadow.doCreate(tmpQuery,
|
|
108
|
+
function (pError, pQuery, pQueryRead, pRecord)
|
|
109
|
+
{
|
|
110
|
+
if (pError)
|
|
111
|
+
{
|
|
112
|
+
_Fable.log.error(`Create error: ${pError}`);
|
|
113
|
+
return fCallback(pError);
|
|
114
|
+
}
|
|
115
|
+
_Fable.log.info(`Created: [${pRecord.IDBook}] "${pRecord.Title}" by ${pRecord.Author} (${pRecord.YearPublished})`);
|
|
116
|
+
_CreatedIDs.push(pRecord.IDBook);
|
|
117
|
+
tmpIndex++;
|
|
118
|
+
createNext();
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
createNext();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// 8. Read a single book
|
|
126
|
+
function readBook(pID, fCallback)
|
|
127
|
+
{
|
|
128
|
+
let tmpQuery = _BookMeadow.query.addFilter('IDBook', pID);
|
|
129
|
+
_BookMeadow.doRead(tmpQuery,
|
|
130
|
+
function (pError, pQuery, pRecord)
|
|
131
|
+
{
|
|
132
|
+
if (pError)
|
|
133
|
+
{
|
|
134
|
+
_Fable.log.error(`Read error: ${pError}`);
|
|
135
|
+
return fCallback(pError);
|
|
136
|
+
}
|
|
137
|
+
_Fable.log.info(`Read: [${pRecord.IDBook}] "${pRecord.Title}" by ${pRecord.Author}`);
|
|
138
|
+
return fCallback(null, pRecord);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 9. Read all books
|
|
143
|
+
function readAllBooks(fCallback)
|
|
144
|
+
{
|
|
145
|
+
let tmpQuery = _BookMeadow.query;
|
|
146
|
+
_BookMeadow.doReads(tmpQuery,
|
|
147
|
+
function (pError, pQuery, pRecords)
|
|
148
|
+
{
|
|
149
|
+
if (pError)
|
|
150
|
+
{
|
|
151
|
+
_Fable.log.error(`Reads error: ${pError}`);
|
|
152
|
+
return fCallback(pError);
|
|
153
|
+
}
|
|
154
|
+
_Fable.log.info(`All books (${pRecords.length}):`);
|
|
155
|
+
for (let i = 0; i < pRecords.length; i++)
|
|
156
|
+
{
|
|
157
|
+
_Fable.log.info(` [${pRecords[i].IDBook}] "${pRecords[i].Title}" by ${pRecords[i].Author}`);
|
|
158
|
+
}
|
|
159
|
+
return fCallback(null, pRecords);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 10. Update a book
|
|
164
|
+
function updateBook(pID, pChanges, fCallback)
|
|
165
|
+
{
|
|
166
|
+
pChanges.IDBook = pID;
|
|
167
|
+
let tmpQuery = _BookMeadow.query.addRecord(pChanges);
|
|
168
|
+
_BookMeadow.doUpdate(tmpQuery,
|
|
169
|
+
function (pError, pQuery, pQueryRead, pRecord)
|
|
170
|
+
{
|
|
171
|
+
if (pError)
|
|
172
|
+
{
|
|
173
|
+
_Fable.log.error(`Update error: ${pError}`);
|
|
174
|
+
return fCallback(pError);
|
|
175
|
+
}
|
|
176
|
+
_Fable.log.info(`Updated: [${pRecord.IDBook}] "${pRecord.Title}" by ${pRecord.Author}`);
|
|
177
|
+
return fCallback(null, pRecord);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// 11. Count books
|
|
182
|
+
function countBooks(fCallback)
|
|
183
|
+
{
|
|
184
|
+
let tmpQuery = _BookMeadow.query;
|
|
185
|
+
_BookMeadow.doCount(tmpQuery,
|
|
186
|
+
function (pError, pQuery, pCount)
|
|
187
|
+
{
|
|
188
|
+
if (pError)
|
|
189
|
+
{
|
|
190
|
+
_Fable.log.error(`Count error: ${pError}`);
|
|
191
|
+
return fCallback(pError);
|
|
192
|
+
}
|
|
193
|
+
_Fable.log.info(`Total books: ${pCount}`);
|
|
194
|
+
return fCallback(null, pCount);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// 12. Delete a book (soft delete)
|
|
199
|
+
function deleteBook(pID, fCallback)
|
|
200
|
+
{
|
|
201
|
+
let tmpQuery = _BookMeadow.query.addFilter('IDBook', pID);
|
|
202
|
+
_BookMeadow.doDelete(tmpQuery,
|
|
203
|
+
function (pError, pQuery, pAffected)
|
|
204
|
+
{
|
|
205
|
+
if (pError)
|
|
206
|
+
{
|
|
207
|
+
_Fable.log.error(`Delete error: ${pError}`);
|
|
208
|
+
return fCallback(pError);
|
|
209
|
+
}
|
|
210
|
+
_Fable.log.info(`Deleted book ${pID} (${pAffected} row(s) affected)`);
|
|
211
|
+
return fCallback();
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Run the full demo sequence
|
|
216
|
+
createBooks(
|
|
217
|
+
function ()
|
|
218
|
+
{
|
|
219
|
+
_Fable.log.info('--- Reading single book ---');
|
|
220
|
+
readBook(_CreatedIDs[0],
|
|
221
|
+
function ()
|
|
222
|
+
{
|
|
223
|
+
_Fable.log.info('--- Reading all books ---');
|
|
224
|
+
readAllBooks(
|
|
225
|
+
function ()
|
|
226
|
+
{
|
|
227
|
+
_Fable.log.info('--- Updating a book ---');
|
|
228
|
+
updateBook(_CreatedIDs[1], { Title: 'Dune (Revised Edition)' },
|
|
229
|
+
function ()
|
|
230
|
+
{
|
|
231
|
+
_Fable.log.info('--- Counting books ---');
|
|
232
|
+
countBooks(
|
|
233
|
+
function ()
|
|
234
|
+
{
|
|
235
|
+
_Fable.log.info('--- Deleting a book ---');
|
|
236
|
+
deleteBook(_CreatedIDs[2],
|
|
237
|
+
function ()
|
|
238
|
+
{
|
|
239
|
+
_Fable.log.info('--- Final book list ---');
|
|
240
|
+
readAllBooks(
|
|
241
|
+
function ()
|
|
242
|
+
{
|
|
243
|
+
_Fable.log.info('--- Meadow CRUD Demo Complete ---');
|
|
244
|
+
process.exit(0);
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
});
|