jsgui3-server 0.0.147 → 0.0.149

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 (145) hide show
  1. package/.github/workflows/control-scan-manifest-check.yml +31 -0
  2. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-071799b982906680f5fd699d.js +40 -0
  3. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-07352945ad5c92654fcb8b65.js +39 -0
  4. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-138a601fadb6191ea314c6fd.js +39 -0
  5. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-171f6c381c2cadf2e9fa7087.js +39 -0
  6. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-1d973388156b84a04373fac9.js +39 -0
  7. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-20e117bc8a10d2cd16234bbe.js +40 -0
  8. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-2b028a82b0e5efddba42425f.js +39 -0
  9. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-4518556cd5c7e059e82b22b8.js +40 -0
  10. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-5bac1aa0f213902f718ed74f.js +40 -0
  11. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-5f9996ac7822caf777d92f56.js +39 -0
  12. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-60a92c702e65fd9cf748e3ec.js +39 -0
  13. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-6164c1f8f738995c541895d2.js +44 -0
  14. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-6718a85eb9e5aa782dd47a05.js +45 -0
  15. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-69e280f14e37aee76a1d4675.js +39 -0
  16. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-7570d1b030d44b111ed59c4c.js +39 -0
  17. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-7798c9bbd55e510d5039f936.js +42 -0
  18. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-78cd511ea1ef18ecb03d1be5.js +40 -0
  19. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-7d482e0b95bcb5e3c543118b.js +43 -0
  20. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-80e9476d1127c55b40fdb36f.js +40 -0
  21. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-810ced55d5320a3088a05b13.js +40 -0
  22. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-8423565f1a40e329afc8c6cf.js +40 -0
  23. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-900bef783b8cee36506ec282.js +39 -0
  24. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-a1a37aff6416fdad74040ddf.js +39 -0
  25. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-ad48d5e8eda40f175b4df090.js +39 -0
  26. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-aec5a2d963015528c9099462.js +39 -0
  27. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-af9d34e0f1722fab9e28c269.js +39 -0
  28. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-b818e4015e2f1fe86280b5ab.js +41 -0
  29. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-bcb2541adc70b7aba61768c5.js +44 -0
  30. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-bfe89d2c78ed44f95ed7dd73.js +40 -0
  31. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-c06f04806a1e688e1187110c.js +40 -0
  32. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-c3f3adf904f585afc544b96a.js +39 -0
  33. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-d45acb873e1d8e32d5e60f2e.js +39 -0
  34. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-db06f132533706f4a0163b8c.js +39 -0
  35. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-f660f40d78b135fc8560a862.js +39 -0
  36. package/.jsgui3-server-cache/jsgui3-html-shims/jsgui3-html-controls-shim-f9dee4ec18a96e09bee06bae.js +39 -0
  37. package/README.md +85 -3
  38. package/admin-ui/client.js +213 -0
  39. package/admin-ui/server.js +104 -0
  40. package/client/controls/auto-observable.js +207 -0
  41. package/dev-status.svg +139 -0
  42. package/docs/api-reference.md +301 -43
  43. package/docs/books/admin-ui/01-introduction.md +32 -0
  44. package/docs/books/admin-ui/02-architecture.md +92 -0
  45. package/docs/books/admin-ui/03-controls.md +194 -0
  46. package/docs/books/admin-ui/04-implementation-plan.md +62 -0
  47. package/docs/books/admin-ui/README.md +26 -0
  48. package/docs/books/jsgui3-bundling-research-book/00-table-of-contents.md +35 -0
  49. package/docs/books/jsgui3-bundling-research-book/01-pipeline-and-runtime-semantics.md +34 -0
  50. package/docs/books/jsgui3-bundling-research-book/02-javascript-bundling-core.md +36 -0
  51. package/docs/books/jsgui3-bundling-research-book/03-style-extraction-and-css-compilation.md +35 -0
  52. package/docs/books/jsgui3-bundling-research-book/04-static-publishing-and-delivery.md +39 -0
  53. package/docs/books/jsgui3-bundling-research-book/05-current-limits-and-size-bloat-vectors.md +25 -0
  54. package/docs/books/jsgui3-bundling-research-book/06-unused-module-elimination-strategy.md +77 -0
  55. package/docs/books/jsgui3-bundling-research-book/07-jsgui3-html-control-and-mixin-pruning.md +63 -0
  56. package/docs/books/jsgui3-bundling-research-book/08-test-and-verification-methodology.md +43 -0
  57. package/docs/books/jsgui3-bundling-research-book/09-roadmap-and-rollout.md +42 -0
  58. package/docs/books/jsgui3-bundling-research-book/10-further-research-strategies-and-upgrades.md +211 -0
  59. package/docs/books/jsgui3-bundling-research-book/README.md +35 -0
  60. package/docs/bundling-system-deep-dive.md +9 -4
  61. package/docs/comprehensive-documentation.md +49 -18
  62. package/docs/configuration-reference.md +152 -27
  63. package/docs/core/README.md +19 -0
  64. package/docs/core/jsgui3-server-core-book/00-table-of-contents.md +21 -0
  65. package/docs/core/jsgui3-server-core-book/01-startup-readiness-state-machine.md +41 -0
  66. package/docs/core/jsgui3-server-core-book/02-resource-abstraction-and-lifecycle.md +92 -0
  67. package/docs/core/jsgui3-server-core-book/03-resource-pool-and-event-topology.md +47 -0
  68. package/docs/core/jsgui3-server-core-book/04-sse-publisher-semantics.md +41 -0
  69. package/docs/core/jsgui3-server-core-book/05-serve-factory-resource-wiring.md +46 -0
  70. package/docs/core/jsgui3-server-core-book/06-e2e-testing-methodology.md +48 -0
  71. package/docs/core/jsgui3-server-core-book/07-defect-detection-and-hardening-loop.md +47 -0
  72. package/docs/publishers-guide.md +59 -4
  73. package/docs/resources-guide.md +184 -35
  74. package/docs/simple-server-api-design.md +72 -17
  75. package/docs/system-architecture.md +18 -14
  76. package/examples/controls/15) window, observable SSE/server.js +6 -1
  77. package/examples/controls/19) window, auto observable ui/client.js +125 -0
  78. package/examples/controls/19) window, auto observable ui/server.js +73 -0
  79. package/examples/controls/20) window, task manager app/README.md +133 -0
  80. package/examples/controls/20) window, task manager app/client.js +797 -0
  81. package/examples/controls/20) window, task manager app/server.js +178 -0
  82. package/examples/controls/6) window, color_palette/client.js +165 -68
  83. package/examples/controls/9) window, date picker/client.js +362 -76
  84. package/examples/controls/9b) window, shared data.model mirrored date pickers/client.js +104 -83
  85. package/examples/jsgui3-html/06) theming/client.js +22 -1
  86. package/examples/jsgui3-html/10) binding-debugger/client.js +137 -1
  87. package/http/responders/static/Static_Route_HTTP_Responder.js +52 -34
  88. package/lab/experiments/capture-color-controls.js +196 -0
  89. package/lab/results/screenshots/color-controls/full_page.png +0 -0
  90. package/lab/results/screenshots/color-controls/section_1_color_grid_12x12.png +0 -0
  91. package/lab/results/screenshots/color-controls/section_2_color_grid_4x2.png +0 -0
  92. package/lab/results/screenshots/color-controls/section_3_color_palette.png +0 -0
  93. package/lab/results/screenshots/color-controls/section_4_palette_comparison.png +0 -0
  94. package/lab/results/screenshots/color-controls/section_5_raw_swatches.png +0 -0
  95. package/lab/results/screenshots/color-controls/section_6_optimized_crayola.png +0 -0
  96. package/lab/results/screenshots/color-controls/section_7_pastel_palette.png +0 -0
  97. package/lab/results/screenshots/color-controls/section_8_extended_144.png +0 -0
  98. package/lab/screenshot-utils.js +248 -0
  99. package/module.js +11 -4
  100. package/package.json +14 -4
  101. package/publishers/Publishers.js +4 -3
  102. package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +5 -5
  103. package/publishers/http-observable-publisher.js +8 -0
  104. package/publishers/http-sse-publisher.js +341 -0
  105. package/publishers/http-webpage-publisher.js +13 -3
  106. package/publishers/http-webpageorsite-publisher.js +18 -0
  107. package/resources/process-resource.js +950 -0
  108. package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +164 -46
  109. package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +18 -7
  110. package/resources/processors/bundlers/js/esbuild/JSGUI3_HTML_Control_Optimizer.js +829 -0
  111. package/resources/remote-process-resource.js +355 -0
  112. package/resources/server-resource-pool.js +354 -41
  113. package/serve-factory.js +441 -259
  114. package/server.js +161 -16
  115. package/tests/README.md +66 -4
  116. package/tests/admin-ui-render.test.js +24 -0
  117. package/tests/assigners.test.js +56 -40
  118. package/tests/bundling-default-control-elimination.puppeteer.test.js +260 -0
  119. package/tests/configuration-validation.test.js +21 -18
  120. package/tests/content-analysis.test.js +7 -6
  121. package/tests/control-optimizer-cache-behavior.test.js +52 -0
  122. package/tests/control-scan-manifest-regression.test.js +144 -0
  123. package/tests/end-to-end.test.js +15 -14
  124. package/tests/error-handling.test.js +222 -179
  125. package/tests/fixtures/bundling-default-button-client.js +37 -0
  126. package/tests/fixtures/bundling-default-window-client.js +34 -0
  127. package/tests/fixtures/control_scan_manifest_expectations.json +48 -0
  128. package/tests/fixtures/resource-monitor-client.js +319 -0
  129. package/tests/helpers/puppeteer-e2e-harness.js +317 -0
  130. package/tests/http-sse-publisher.test.js +136 -0
  131. package/tests/performance.test.js +69 -65
  132. package/tests/process-resource.test.js +138 -0
  133. package/tests/publishers.test.js +7 -7
  134. package/tests/remote-process-resource.test.js +160 -0
  135. package/tests/sass-controls.e2e.test.js +7 -1
  136. package/tests/serve-resources.test.js +270 -0
  137. package/tests/serve.test.js +120 -50
  138. package/tests/server-resource-pool.test.js +106 -0
  139. package/tests/small-controls-bundle-size.test.js +252 -0
  140. package/tests/test-runner.js +13 -1
  141. package/tests/window-examples.puppeteer.test.js +204 -1
  142. package/tests/window-resource-integration.puppeteer.test.js +585 -0
  143. package/tests/temp_invalid.js +0 -7
  144. package/tests/temp_invalid_utf8.js +0 -1
  145. package/tests/temp_malformed.js +0 -10
@@ -1,41 +1,354 @@
1
- /**
2
- * Created by James on 02/10/2016.
3
- */
4
-
5
-
6
-
7
-
8
- var jsgui = require('jsgui3-html'), os = require('os'), http = require('http'),
9
- Local_Server_Info = require('./local-server-info-resource'), Resource_Pool = jsgui.Resource_Pool;
10
-
11
- var stringify = jsgui.stringify, each = jsgui.each, arrayify = jsgui.arrayify, tof = jsgui.tof;
12
- var filter_map_by_regex = jsgui.filter_map_by_regex;
13
- var Class = jsgui.Class, Data_Object = jsgui.Data_Object, Enhanced_Data_Object = jsgui.Enhanced_Data_Object;
14
- var fp = jsgui.fp, is_defined = jsgui.is_defined;
15
- var Collection = jsgui.Collection;
16
-
17
- var exec = require('child_process').exec;
18
-
19
- class Server_Resource_Pool extends Resource_Pool {
20
- constructor(spec) {
21
- super(spec);
22
-
23
- var lsi = new Local_Server_Info({
24
- 'name': 'Local Server Info',
25
- 'startup_type': 'auto',
26
- 'access': {
27
- 'full': ['server_admin']
28
- },
29
- 'pool': this
30
- });
31
- this.add(lsi);
32
- }
33
-
34
- }
35
-
36
-
37
- //return Server_Resource_Pool;
38
-
39
-
40
- //});
41
- module.exports = Server_Resource_Pool;
1
+ const jsgui = require('jsgui3-html');
2
+
3
+ const Local_Server_Info = require('./local-server-info-resource');
4
+
5
+ const { Resource_Pool } = jsgui;
6
+
7
+ const to_error = (error_value) => {
8
+ if (!error_value) return new Error('Unknown resource error');
9
+ if (error_value instanceof Error) return error_value;
10
+ return new Error(String(error_value));
11
+ };
12
+
13
+ class Server_Resource_Pool extends Resource_Pool {
14
+ constructor(spec = {}) {
15
+ super(spec);
16
+
17
+ this._resource_event_handlers = new WeakMap();
18
+
19
+ const local_server_info = new Local_Server_Info({
20
+ name: 'Local Server Info',
21
+ startup_type: 'auto',
22
+ access: {
23
+ full: ['server_admin']
24
+ },
25
+ pool: this
26
+ });
27
+ this.add(local_server_info);
28
+ }
29
+
30
+ add(resource) {
31
+ if (!this._resource_event_handlers) {
32
+ this._resource_event_handlers = new WeakMap();
33
+ }
34
+ const add_result = super.add(resource);
35
+ this._bind_resource_events(resource);
36
+ return add_result;
37
+ }
38
+
39
+ push(resource) {
40
+ return this.add(resource);
41
+ }
42
+
43
+ _bind_resource_events(resource) {
44
+ if (!resource || typeof resource.on !== 'function') {
45
+ return;
46
+ }
47
+
48
+ if (!this._resource_event_handlers) {
49
+ this._resource_event_handlers = new WeakMap();
50
+ }
51
+
52
+ if (this._resource_event_handlers.has(resource)) {
53
+ return;
54
+ }
55
+
56
+ const bound_handlers = {
57
+ state_change: (change_data = {}) => {
58
+ this.raise('resource_state_change', {
59
+ resourceName: resource.name,
60
+ ...change_data
61
+ });
62
+ },
63
+ crashed: (event_data = {}) => {
64
+ this.raise('crashed', {
65
+ resourceName: resource.name,
66
+ ...event_data
67
+ });
68
+ },
69
+ unhealthy: (event_data = {}) => {
70
+ this.raise('unhealthy', {
71
+ resourceName: resource.name,
72
+ ...event_data
73
+ });
74
+ },
75
+ unreachable: (event_data = {}) => {
76
+ this.raise('unreachable', {
77
+ resourceName: resource.name,
78
+ ...event_data
79
+ });
80
+ },
81
+ recovered: (event_data = {}) => {
82
+ this.raise('recovered', {
83
+ resourceName: resource.name,
84
+ ...event_data
85
+ });
86
+ }
87
+ };
88
+
89
+ Object.entries(bound_handlers).forEach(([event_name, handler_fn]) => {
90
+ resource.on(event_name, handler_fn);
91
+ });
92
+
93
+ this._resource_event_handlers.set(resource, bound_handlers);
94
+ }
95
+
96
+ _unbind_resource_events(resource) {
97
+ if (!resource || typeof resource.off !== 'function') {
98
+ return;
99
+ }
100
+
101
+ if (!this._resource_event_handlers) {
102
+ this._resource_event_handlers = new WeakMap();
103
+ return;
104
+ }
105
+
106
+ const bound_handlers = this._resource_event_handlers.get(resource);
107
+ if (!bound_handlers) {
108
+ return;
109
+ }
110
+
111
+ Object.entries(bound_handlers).forEach(([event_name, handler_fn]) => {
112
+ resource.off(event_name, handler_fn);
113
+ });
114
+
115
+ this._resource_event_handlers.delete(resource);
116
+ }
117
+
118
+ _invoke_resource_stop(resource) {
119
+ if (!resource || typeof resource.stop !== 'function') {
120
+ return Promise.resolve(false);
121
+ }
122
+
123
+ if (resource.stop.length >= 1) {
124
+ return new Promise((resolve, reject) => {
125
+ resource.stop((error) => {
126
+ if (error) {
127
+ reject(to_error(error));
128
+ return;
129
+ }
130
+ resolve(true);
131
+ });
132
+ });
133
+ }
134
+
135
+ const stop_result = resource.stop();
136
+ if (stop_result && typeof stop_result.then === 'function') {
137
+ return stop_result.then(() => true);
138
+ }
139
+
140
+ return Promise.resolve(true);
141
+ }
142
+
143
+ _invoke_resource_start(resource) {
144
+ if (!resource || typeof resource.start !== 'function') {
145
+ return Promise.resolve(false);
146
+ }
147
+
148
+ if (resource.start.length >= 1) {
149
+ return new Promise((resolve, reject) => {
150
+ resource.start((error) => {
151
+ if (error) {
152
+ reject(to_error(error));
153
+ return;
154
+ }
155
+ resolve(true);
156
+ });
157
+ });
158
+ }
159
+
160
+ const start_result = resource.start();
161
+ if (start_result && typeof start_result.then === 'function') {
162
+ return start_result.then(() => true);
163
+ }
164
+
165
+ return Promise.resolve(true);
166
+ }
167
+
168
+ _resource_meets_requirements(resource) {
169
+ if (!resource) {
170
+ return false;
171
+ }
172
+
173
+ if (typeof resource.meets_requirements !== 'function') {
174
+ return true;
175
+ }
176
+
177
+ try {
178
+ return resource.meets_requirements() !== false;
179
+ } catch (error) {
180
+ throw to_error(error);
181
+ }
182
+ }
183
+
184
+ async _start_internal() {
185
+ const resources_to_start = [];
186
+ this.resources.each((resource) => {
187
+ if (this._resource_meets_requirements(resource)) {
188
+ resources_to_start.push(resource);
189
+ }
190
+ });
191
+
192
+ const start_results = await Promise.allSettled(
193
+ resources_to_start.map((resource) => this._invoke_resource_start(resource))
194
+ );
195
+ const first_rejection = start_results.find((result) => result.status === 'rejected');
196
+ if (first_rejection) {
197
+ throw to_error(first_rejection.reason);
198
+ }
199
+
200
+ return true;
201
+ }
202
+
203
+ start(callback) {
204
+ const start_promise = this._start_internal();
205
+
206
+ if (typeof callback === 'function') {
207
+ start_promise.then(
208
+ () => callback(null, true),
209
+ (error) => callback(error)
210
+ );
211
+ return;
212
+ }
213
+
214
+ return start_promise;
215
+ }
216
+
217
+ async _remove_internal(resource_name) {
218
+ const resource = this.get_resource(resource_name);
219
+ if (!resource) {
220
+ return false;
221
+ }
222
+
223
+ if (typeof resource.stop === 'function') {
224
+ await this._invoke_resource_stop(resource);
225
+ }
226
+
227
+ this._unbind_resource_events(resource);
228
+ this.resources.remove(resource);
229
+
230
+ this.raise('removed', {
231
+ resourceName: resource_name,
232
+ timestamp: Date.now()
233
+ });
234
+
235
+ return true;
236
+ }
237
+
238
+ remove(resource_name, callback) {
239
+ const remove_promise = this._remove_internal(resource_name);
240
+
241
+ if (typeof callback === 'function') {
242
+ remove_promise.then(
243
+ (did_remove) => callback(null, did_remove),
244
+ (error) => callback(error)
245
+ );
246
+ return;
247
+ }
248
+
249
+ return remove_promise;
250
+ }
251
+
252
+ async _stop_internal() {
253
+ const resources_to_stop = [];
254
+ this.resources.each((resource) => {
255
+ if (resource && typeof resource.stop === 'function') {
256
+ resources_to_stop.push(resource);
257
+ }
258
+ });
259
+
260
+ const stop_results = await Promise.allSettled(
261
+ resources_to_stop.map((resource) => this._invoke_resource_stop(resource))
262
+ );
263
+
264
+ const first_rejection = stop_results.find((result) => result.status === 'rejected');
265
+ if (first_rejection) {
266
+ throw to_error(first_rejection.reason);
267
+ }
268
+
269
+ return true;
270
+ }
271
+
272
+ stop(callback) {
273
+ const stop_promise = this._stop_internal();
274
+
275
+ if (typeof callback === 'function') {
276
+ stop_promise.then(
277
+ () => callback(null, true),
278
+ (error) => callback(error)
279
+ );
280
+ return;
281
+ }
282
+
283
+ return stop_promise;
284
+ }
285
+
286
+ get_resources_by_type(type_value) {
287
+ const matching_resources = [];
288
+
289
+ this.resources.each((resource) => {
290
+ if (!resource) {
291
+ return;
292
+ }
293
+
294
+ if (typeof type_value === 'function') {
295
+ if (resource instanceof type_value) {
296
+ matching_resources.push(resource);
297
+ }
298
+ return;
299
+ }
300
+
301
+ if (typeof type_value === 'string') {
302
+ const constructor_name = resource.constructor && resource.constructor.name;
303
+ if (constructor_name === type_value || resource.__type_name === type_value || resource.type === type_value) {
304
+ matching_resources.push(resource);
305
+ }
306
+ }
307
+ });
308
+
309
+ return matching_resources;
310
+ }
311
+
312
+ get summary() {
313
+ const summary = {
314
+ total: 0,
315
+ running: 0,
316
+ stopped: 0,
317
+ crashed: 0,
318
+ unreachable: 0,
319
+ byType: {}
320
+ };
321
+
322
+ this.resources.each((resource) => {
323
+ if (!resource) {
324
+ return;
325
+ }
326
+
327
+ summary.total += 1;
328
+
329
+ const resource_status = resource.status || {};
330
+ const resource_state = resource_status.state || resource.state || 'unknown';
331
+ if (summary[resource_state] !== undefined) {
332
+ summary[resource_state] += 1;
333
+ }
334
+
335
+ const type_name = (resource.constructor && resource.constructor.name) || 'Unknown';
336
+ if (!summary.byType[type_name]) {
337
+ summary.byType[type_name] = [];
338
+ }
339
+
340
+ if (typeof resource.get_abstract === 'function') {
341
+ summary.byType[type_name].push(resource.get_abstract());
342
+ } else {
343
+ summary.byType[type_name].push({
344
+ name: resource.name,
345
+ state: resource_state
346
+ });
347
+ }
348
+ });
349
+
350
+ return summary;
351
+ }
352
+ }
353
+
354
+ module.exports = Server_Resource_Pool;