jsgui3-server 0.0.138 → 0.0.140

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 (57) hide show
  1. package/AGENTS.md +87 -0
  2. package/README.md +12 -0
  3. package/docs/GUIDE_TO_AGENTIC_WORKFLOWS_BY_GROK.md +19 -0
  4. package/docs/advanced-usage-examples.md +1360 -0
  5. package/docs/agent-development-guide.md +386 -0
  6. package/docs/api-reference.md +916 -0
  7. package/docs/broken-functionality-tracker.md +285 -0
  8. package/docs/bundling-system-deep-dive.md +525 -0
  9. package/docs/cli-reference.md +393 -0
  10. package/docs/comprehensive-documentation.md +1403 -0
  11. package/docs/configuration-reference.md +808 -0
  12. package/docs/controls-development.md +859 -0
  13. package/docs/documentation-review/CURRENT_REVIEW.md +95 -0
  14. package/docs/function-publishers-json-apis.md +847 -0
  15. package/docs/getting-started-with-json.md +518 -0
  16. package/docs/minification-compression-sourcemaps-status.md +482 -0
  17. package/docs/minification-compression-sourcemaps-test-results.md +205 -0
  18. package/docs/publishers-guide.md +313 -0
  19. package/docs/resources-guide.md +615 -0
  20. package/docs/serve-helpers.md +406 -0
  21. package/docs/simple-server-api-design.md +13 -0
  22. package/docs/system-architecture.md +275 -0
  23. package/docs/troubleshooting.md +698 -0
  24. package/examples/json/README.md +115 -0
  25. package/examples/json/basic-api/README.md +345 -0
  26. package/examples/json/basic-api/server.js +199 -0
  27. package/examples/json/simple-api/README.md +125 -0
  28. package/examples/json/simple-api/diagnostic-report.json +73 -0
  29. package/examples/json/simple-api/diagnostic-test.js +433 -0
  30. package/examples/json/simple-api/server-debug.md +58 -0
  31. package/examples/json/simple-api/server.js +91 -0
  32. package/examples/json/simple-api/test.js +215 -0
  33. package/http/responders/static/Static_Route_HTTP_Responder.js +1 -2
  34. package/package.json +19 -8
  35. package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +65 -12
  36. package/publishers/helpers/preparers/static/bundle/Static_Routes_Responses_Webpage_Bundle_Preparer.js +6 -1
  37. package/publishers/http-function-publisher.js +59 -38
  38. package/publishers/http-webpage-publisher.js +48 -1
  39. package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +38 -146
  40. package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +54 -5
  41. package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +36 -4
  42. package/serve-factory.js +36 -9
  43. package/server.js +10 -4
  44. package/test-report.json +0 -0
  45. package/tests/README.md +250 -0
  46. package/tests/assigners.test.js +316 -0
  47. package/tests/bundlers.test.js +329 -0
  48. package/tests/configuration-validation.test.js +530 -0
  49. package/tests/content-analysis.test.js +641 -0
  50. package/tests/end-to-end.test.js +496 -0
  51. package/tests/error-handling.test.js +746 -0
  52. package/tests/performance.test.js +653 -0
  53. package/tests/publishers.test.js +395 -0
  54. package/tests/temp_invalid.js +7 -0
  55. package/tests/temp_invalid_utf8.js +1 -0
  56. package/tests/temp_malformed.js +10 -0
  57. package/tests/test-runner.js +261 -0
@@ -0,0 +1,530 @@
1
+ const assert = require('assert');
2
+ const { describe, it } = require('mocha');
3
+
4
+ // Import classes for configuration validation
5
+ const HTTP_Webpage_Publisher = require('../publishers/http-webpage-publisher');
6
+ const Core_JS_Single_File_Minifying_Bundler_Using_ESBuild = require('../resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild');
7
+ const Core_JS_Non_Minifying_Bundler_Using_ESBuild = require('../resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild');
8
+ const Advanced_JS_Bundler_Using_ESBuild = require('../resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild');
9
+ const Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner = require('../publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner');
10
+
11
+ describe('Configuration Validation Tests', function() {
12
+ this.timeout(10000);
13
+
14
+ let mockWebpage;
15
+
16
+ beforeEach(function() {
17
+ mockWebpage = {
18
+ content: class MockControl {
19
+ all_html_render() {
20
+ return Promise.resolve('<html></html>');
21
+ }
22
+ }
23
+ };
24
+ });
25
+
26
+ describe('HTTP_Webpage_Publisher Configuration Validation', function() {
27
+ describe('Compression Configuration', function() {
28
+ it('should accept valid compression configuration', function() {
29
+ const validConfig = {
30
+ webpage: mockWebpage,
31
+ bundler: {
32
+ compression: {
33
+ enabled: true,
34
+ algorithms: ['gzip', 'br'],
35
+ gzip: { level: 6 },
36
+ brotli: { quality: 6 },
37
+ threshold: 1024
38
+ }
39
+ }
40
+ };
41
+
42
+ const publisher = new HTTP_Webpage_Publisher(validConfig);
43
+ assert.strictEqual(publisher.bundler_config.compression.enabled, true);
44
+ assert.deepStrictEqual(publisher.bundler_config.compression.algorithms, ['gzip', 'br']);
45
+ });
46
+
47
+ it('should reject invalid compression.enabled type', function() {
48
+ assert.throws(() => {
49
+ new HTTP_Webpage_Publisher({
50
+ webpage: mockWebpage,
51
+ bundler: {
52
+ compression: {
53
+ enabled: 'true' // Should be boolean
54
+ }
55
+ }
56
+ });
57
+ }, /bundler\.compression\.enabled must be a boolean/);
58
+ });
59
+
60
+ it('should reject invalid compression.algorithms type', function() {
61
+ assert.throws(() => {
62
+ new HTTP_Webpage_Publisher({
63
+ webpage: mockWebpage,
64
+ bundler: {
65
+ compression: {
66
+ algorithms: 'gzip' // Should be array
67
+ }
68
+ }
69
+ });
70
+ }, /bundler\.compression\.algorithms must be an array/);
71
+ });
72
+
73
+ it('should reject invalid compression algorithm', function() {
74
+ assert.throws(() => {
75
+ new HTTP_Webpage_Publisher({
76
+ webpage: mockWebpage,
77
+ bundler: {
78
+ compression: {
79
+ algorithms: ['gzip', 'invalid']
80
+ }
81
+ }
82
+ });
83
+ }, /Invalid compression algorithm: invalid/);
84
+ });
85
+
86
+ it('should accept valid compression algorithms', function() {
87
+ const publisher = new HTTP_Webpage_Publisher({
88
+ webpage: mockWebpage,
89
+ bundler: {
90
+ compression: {
91
+ algorithms: ['gzip', 'br']
92
+ }
93
+ }
94
+ });
95
+ assert.deepStrictEqual(publisher.bundler_config.compression.algorithms, ['gzip', 'br']);
96
+ });
97
+
98
+ it('should reject invalid compression.threshold type', function() {
99
+ assert.throws(() => {
100
+ new HTTP_Webpage_Publisher({
101
+ webpage: mockWebpage,
102
+ bundler: {
103
+ compression: {
104
+ threshold: '1024' // Should be number
105
+ }
106
+ }
107
+ });
108
+ }, /bundler\.compression\.threshold must be a non-negative number/);
109
+ });
110
+
111
+ it('should reject negative compression.threshold', function() {
112
+ assert.throws(() => {
113
+ new HTTP_Webpage_Publisher({
114
+ webpage: mockWebpage,
115
+ bundler: {
116
+ compression: {
117
+ threshold: -1
118
+ }
119
+ }
120
+ });
121
+ }, /bundler\.compression\.threshold must be a non-negative number/);
122
+ });
123
+
124
+ it('should accept zero compression.threshold', function() {
125
+ const publisher = new HTTP_Webpage_Publisher({
126
+ webpage: mockWebpage,
127
+ bundler: {
128
+ compression: {
129
+ threshold: 0
130
+ }
131
+ }
132
+ });
133
+ assert.strictEqual(publisher.bundler_config.compression.threshold, 0);
134
+ });
135
+ });
136
+
137
+ describe('Minification Configuration', function() {
138
+ it('should accept valid minification configuration', function() {
139
+ const validConfig = {
140
+ webpage: mockWebpage,
141
+ bundler: {
142
+ minify: {
143
+ enabled: true,
144
+ level: 'normal',
145
+ options: {
146
+ mangle: true,
147
+ compress: true
148
+ }
149
+ }
150
+ }
151
+ };
152
+
153
+ const publisher = new HTTP_Webpage_Publisher(validConfig);
154
+ assert.strictEqual(publisher.bundler_config.minify.enabled, true);
155
+ assert.strictEqual(publisher.bundler_config.minify.level, 'normal');
156
+ });
157
+
158
+ it('should accept all valid minification levels', function() {
159
+ const levels = ['conservative', 'normal', 'aggressive'];
160
+
161
+ levels.forEach(level => {
162
+ const publisher = new HTTP_Webpage_Publisher({
163
+ webpage: mockWebpage,
164
+ bundler: {
165
+ minify: {
166
+ level: level
167
+ }
168
+ }
169
+ });
170
+ assert.strictEqual(publisher.bundler_config.minify.level, level);
171
+ });
172
+ });
173
+
174
+ it('should accept custom minification options', function() {
175
+ const customOptions = {
176
+ mangle: false,
177
+ compress: {
178
+ sequences: false,
179
+ drop_console: true
180
+ }
181
+ };
182
+
183
+ const publisher = new HTTP_Webpage_Publisher({
184
+ webpage: mockWebpage,
185
+ bundler: {
186
+ minify: {
187
+ options: customOptions
188
+ }
189
+ }
190
+ });
191
+ assert.deepStrictEqual(publisher.bundler_config.minify.options, customOptions);
192
+ });
193
+ });
194
+
195
+ describe('Sourcemap Configuration', function() {
196
+ it('should accept valid sourcemap configuration', function() {
197
+ const validConfig = {
198
+ webpage: mockWebpage,
199
+ bundler: {
200
+ sourcemaps: {
201
+ enabled: true,
202
+ format: 'inline',
203
+ includeInProduction: false,
204
+ validation: true
205
+ }
206
+ }
207
+ };
208
+
209
+ const publisher = new HTTP_Webpage_Publisher(validConfig);
210
+ assert.strictEqual(publisher.bundler_config.sourcemaps.enabled, true);
211
+ assert.strictEqual(publisher.bundler_config.sourcemaps.format, 'inline');
212
+ });
213
+
214
+ it('should accept all valid sourcemap formats', function() {
215
+ const formats = ['inline', 'external'];
216
+
217
+ formats.forEach(format => {
218
+ const publisher = new HTTP_Webpage_Publisher({
219
+ webpage: mockWebpage,
220
+ bundler: {
221
+ sourcemaps: {
222
+ format: format
223
+ }
224
+ }
225
+ });
226
+ assert.strictEqual(publisher.bundler_config.sourcemaps.format, format);
227
+ });
228
+ });
229
+ });
230
+
231
+ describe('Complete Configuration Validation', function() {
232
+ it('should accept complete valid configuration', function() {
233
+ const completeConfig = {
234
+ webpage: mockWebpage,
235
+ bundler: {
236
+ minify: {
237
+ enabled: true,
238
+ level: 'aggressive',
239
+ options: {
240
+ compress: {
241
+ drop_console: true,
242
+ drop_debugger: true
243
+ }
244
+ }
245
+ },
246
+ sourcemaps: {
247
+ enabled: true,
248
+ format: 'inline',
249
+ includeInProduction: false
250
+ },
251
+ compression: {
252
+ enabled: true,
253
+ algorithms: ['gzip', 'br'],
254
+ gzip: { level: 9 },
255
+ brotli: { quality: 11 },
256
+ threshold: 2048
257
+ }
258
+ }
259
+ };
260
+
261
+ const publisher = new HTTP_Webpage_Publisher(completeConfig);
262
+ assert.deepStrictEqual(publisher.bundler_config, completeConfig.bundler);
263
+ });
264
+
265
+ it('should handle missing configuration sections gracefully', function() {
266
+ const partialConfig = {
267
+ webpage: mockWebpage,
268
+ bundler: {
269
+ // Only compression, no minify or sourcemaps
270
+ compression: {
271
+ enabled: true
272
+ }
273
+ }
274
+ };
275
+
276
+ const publisher = new HTTP_Webpage_Publisher(partialConfig);
277
+ assert(publisher.bundler_config.compression);
278
+ assert(!publisher.bundler_config.minify);
279
+ assert(!publisher.bundler_config.sourcemaps);
280
+ });
281
+ });
282
+ });
283
+
284
+ describe('Bundler Configuration Validation', function() {
285
+ describe('Core_JS_Single_File_Minifying_Bundler_Using_ESBuild', function() {
286
+ it('should accept valid minification configuration', function() {
287
+ const bundler = new Core_JS_Single_File_Minifying_Bundler_Using_ESBuild({
288
+ minify: {
289
+ enabled: true,
290
+ level: 'normal',
291
+ options: {
292
+ mangle: true
293
+ }
294
+ }
295
+ });
296
+
297
+ assert.strictEqual(bundler.minify_config.enabled, true);
298
+ assert.strictEqual(bundler.minify_config.level, 'normal');
299
+ assert.strictEqual(bundler.minify_config.options.mangle, true);
300
+ });
301
+
302
+ it('should handle disabled minification', function() {
303
+ const bundler = new Core_JS_Single_File_Minifying_Bundler_Using_ESBuild({
304
+ minify: {
305
+ enabled: false
306
+ }
307
+ });
308
+
309
+ assert.strictEqual(bundler.minify_config.enabled, false);
310
+ });
311
+
312
+ it('should default to enabled minification', function() {
313
+ const bundler = new Core_JS_Single_File_Minifying_Bundler_Using_ESBuild({
314
+ minify: {
315
+ level: 'aggressive'
316
+ }
317
+ });
318
+
319
+ assert.strictEqual(bundler.minify_config.enabled, true);
320
+ assert.strictEqual(bundler.minify_config.level, 'aggressive');
321
+ });
322
+
323
+ it('should handle missing minify configuration', function() {
324
+ const bundler = new Core_JS_Single_File_Minifying_Bundler_Using_ESBuild({});
325
+
326
+ assert.deepStrictEqual(bundler.minify_config, {});
327
+ });
328
+ });
329
+
330
+ describe('Core_JS_Non_Minifying_Bundler_Using_ESBuild', function() {
331
+ it('should accept valid sourcemap configuration', function() {
332
+ const bundler = new Core_JS_Non_Minifying_Bundler_Using_ESBuild({
333
+ debug: true,
334
+ sourcemaps: {
335
+ enabled: true,
336
+ format: 'inline',
337
+ includeInProduction: false
338
+ }
339
+ });
340
+
341
+ assert.strictEqual(bundler.sourcemap_config.enabled, true);
342
+ assert.strictEqual(bundler.sourcemap_config.format, 'inline');
343
+ assert.strictEqual(bundler.sourcemap_config.includeInProduction, false);
344
+ });
345
+
346
+ it('should handle disabled sourcemaps', function() {
347
+ const bundler = new Core_JS_Non_Minifying_Bundler_Using_ESBuild({
348
+ sourcemaps: {
349
+ enabled: false
350
+ }
351
+ });
352
+
353
+ assert.strictEqual(bundler.sourcemap_config.enabled, false);
354
+ });
355
+
356
+ it('should default sourcemaps based on debug mode', function() {
357
+ const debugBundler = new Core_JS_Non_Minifying_Bundler_Using_ESBuild({
358
+ debug: true
359
+ });
360
+
361
+ const prodBundler = new Core_JS_Non_Minifying_Bundler_Using_ESBuild({
362
+ debug: false
363
+ });
364
+
365
+ // Both should have default config (empty object means defaults apply)
366
+ assert.deepStrictEqual(debugBundler.sourcemap_config, {});
367
+ assert.deepStrictEqual(prodBundler.sourcemap_config, {});
368
+ });
369
+ });
370
+
371
+ describe('Advanced_JS_Bundler_Using_ESBuild', function() {
372
+ it('should accept and pass through configuration to sub-bundlers', function() {
373
+ const config = {
374
+ debug: false,
375
+ bundler: {
376
+ minify: {
377
+ level: 'aggressive'
378
+ },
379
+ sourcemaps: {
380
+ enabled: false
381
+ }
382
+ }
383
+ };
384
+
385
+ const bundler = new Advanced_JS_Bundler_Using_ESBuild(config);
386
+
387
+ assert.strictEqual(bundler.debug, false);
388
+ assert.deepStrictEqual(bundler.bundler_config, config.bundler);
389
+ });
390
+
391
+ it('should handle debug mode configuration', function() {
392
+ const debugBundler = new Advanced_JS_Bundler_Using_ESBuild({
393
+ debug: true
394
+ });
395
+
396
+ const prodBundler = new Advanced_JS_Bundler_Using_ESBuild({
397
+ debug: false
398
+ });
399
+
400
+ assert.strictEqual(debugBundler.debug, true);
401
+ assert.strictEqual(prodBundler.debug, false);
402
+ });
403
+ });
404
+ });
405
+
406
+ describe('Assigner Configuration Validation', function() {
407
+ describe('Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner', function() {
408
+ it('should accept valid compression configuration', function() {
409
+ const assigner = new Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner({
410
+ compression: {
411
+ enabled: true,
412
+ algorithms: ['gzip', 'br'],
413
+ gzip: { level: 6 },
414
+ brotli: { quality: 6 },
415
+ threshold: 1024
416
+ }
417
+ });
418
+
419
+ assert.strictEqual(assigner.compression_config.enabled, true);
420
+ assert.deepStrictEqual(assigner.compression_config.algorithms, ['gzip', 'br']);
421
+ assert.strictEqual(assigner.compression_config.gzip.level, 6);
422
+ assert.strictEqual(assigner.compression_config.brotli.quality, 6);
423
+ assert.strictEqual(assigner.compression_config.threshold, 1024);
424
+ });
425
+
426
+ it('should handle disabled compression', function() {
427
+ const assigner = new Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner({
428
+ compression: {
429
+ enabled: false
430
+ }
431
+ });
432
+
433
+ assert.strictEqual(assigner.compression_config.enabled, false);
434
+ });
435
+
436
+ it('should apply default values for missing configuration', function() {
437
+ const assigner = new Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner({});
438
+
439
+ // Should have defaults applied internally
440
+ assert(assigner.compression_config); // Should exist as empty object
441
+ });
442
+
443
+ it('should handle partial compression configuration', function() {
444
+ const assigner = new Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner({
445
+ compression: {
446
+ enabled: true,
447
+ algorithms: ['gzip']
448
+ // Missing other options
449
+ }
450
+ });
451
+
452
+ assert.strictEqual(assigner.compression_config.enabled, true);
453
+ assert.deepStrictEqual(assigner.compression_config.algorithms, ['gzip']);
454
+ });
455
+ });
456
+ });
457
+
458
+ describe('Configuration Schema Validation', function() {
459
+ it('should validate gzip level range', function() {
460
+ // Gzip levels should be 0-9, but this is handled by zlib internally
461
+ // Just verify the configuration is accepted
462
+ const assigner = new Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner({
463
+ compression: {
464
+ gzip: { level: 9 }
465
+ }
466
+ });
467
+
468
+ assert.strictEqual(assigner.compression_config.gzip.level, 9);
469
+ });
470
+
471
+ it('should validate brotli quality range', function() {
472
+ // Brotli quality should be 0-11, but this is handled by zlib internally
473
+ const assigner = new Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner({
474
+ compression: {
475
+ brotli: { quality: 11 }
476
+ }
477
+ });
478
+
479
+ assert.strictEqual(assigner.compression_config.brotli.quality, 11);
480
+ });
481
+
482
+ it('should handle invalid algorithm names gracefully', function() {
483
+ // This should not crash during construction, but during assignment
484
+ const assigner = new Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner({
485
+ compression: {
486
+ algorithms: ['invalid_algorithm']
487
+ }
488
+ });
489
+
490
+ // Should store the config even if invalid
491
+ assert.deepStrictEqual(assigner.compression_config.algorithms, ['invalid_algorithm']);
492
+ });
493
+ });
494
+
495
+ describe('Configuration Inheritance and Defaults', function() {
496
+ it('should inherit configuration through the publisher chain', function() {
497
+ const serverConfig = {
498
+ webpage: mockWebpage,
499
+ bundler: {
500
+ compression: {
501
+ enabled: true,
502
+ algorithms: ['gzip']
503
+ },
504
+ minify: {
505
+ level: 'normal'
506
+ }
507
+ }
508
+ };
509
+
510
+ const publisher = new HTTP_Webpage_Publisher(serverConfig);
511
+
512
+ // Verify configuration flows to preparer
513
+ const preparer = publisher.static_routes_responses_webpage_bundle_preparer;
514
+ assert.deepStrictEqual(preparer.bundler_config, serverConfig.bundler);
515
+
516
+ // Verify configuration flows to compression assigner
517
+ const compressionAssigner = preparer.compressed_response_buffers_assigner;
518
+ assert.deepStrictEqual(compressionAssigner.compression_config, serverConfig.bundler.compression);
519
+ });
520
+
521
+ it('should apply sensible defaults when configuration is missing', function() {
522
+ const minimalPublisher = new HTTP_Webpage_Publisher({
523
+ webpage: mockWebpage
524
+ });
525
+
526
+ // Should not crash and should have empty config
527
+ assert.deepStrictEqual(minimalPublisher.bundler_config, {});
528
+ });
529
+ });
530
+ });