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,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
+ });