pict-section-form 1.3.15 → 1.3.16

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 (47) hide show
  1. package/docs/Providers.md +12 -7
  2. package/docs/_sidebar.md +2 -0
  3. package/docs/input_providers/016-facet-filter.md +106 -0
  4. package/docs/input_providers/README.md +1 -0
  5. package/example_applications/README.md +6 -0
  6. package/example_applications/facet_filter/.quackage.json +9 -0
  7. package/example_applications/facet_filter/Facet-Filter-Application.js +210 -0
  8. package/example_applications/facet_filter/Facet-Filter-Server.js +233 -0
  9. package/example_applications/facet_filter/Facet-Filter-Smoke-Runner.js +101 -0
  10. package/example_applications/facet_filter/FacetFilterData.json +44 -0
  11. package/example_applications/facet_filter/README-FacetFilter.md +70 -0
  12. package/example_applications/facet_filter/html/Facet-Filter-Smoke.js +128 -0
  13. package/example_applications/facet_filter/html/index.html +74 -0
  14. package/example_applications/facet_filter/package.json +27 -0
  15. package/example_applications/nested_distill_sandbox/Sandbox-Driver-Headlight.js +17 -0
  16. package/example_applications/nested_distill_sandbox/Sandbox-Driver.js +369 -0
  17. package/example_applications/nested_distill_sandbox/Sandbox-Runner.js +372 -0
  18. package/example_applications/nested_distill_sandbox/approaches/A1-tabular-trigger-group.js +67 -0
  19. package/example_applications/nested_distill_sandbox/approaches/A3-crossmap-selectoptionsrefresh.js +61 -0
  20. package/example_applications/nested_distill_sandbox/approaches/A4-graph-solvers-flat-list.js +53 -0
  21. package/example_applications/nested_distill_sandbox/approaches/A5-facet-filter.js +75 -0
  22. package/example_applications/nested_distill_sandbox/approaches/A5b-facet-filter-symmetric.js +15 -0
  23. package/example_applications/nested_distill_sandbox/approaches/A5h-facet-filter-headlight-picker.js +15 -0
  24. package/example_applications/nested_distill_sandbox/approaches/R0-original-jmf-manifest-headlight.js +27 -0
  25. package/example_applications/nested_distill_sandbox/approaches/R1-real-jmf-manifest-headlight.js +136 -0
  26. package/example_applications/nested_distill_sandbox/approaches/_Common.js +344 -0
  27. package/example_applications/nested_distill_sandbox/approaches/_Scenarios.js +262 -0
  28. package/package.json +1 -1
  29. package/source/providers/Pict-Provider-DynamicSolver.js +2 -0
  30. package/source/providers/Pict-Provider-ListDistilling.js +266 -1
  31. package/source/providers/Pict-Provider-MetaLists.js +16 -2
  32. package/source/providers/inputs/Pict-Provider-Input-FacetFilter.js +232 -0
  33. package/source/providers/inputs/Pict-Provider-Input-Select.js +41 -1
  34. package/source/views/Pict-View-Form-Metacontroller.js +5 -3
  35. package/test/Pict-Provider-ListDistilling-Facet_tests.js +375 -0
  36. package/test/PictSectionForm-Injection-Conformance_tests.js +11 -0
  37. package/test/fixtures/injection/Injection-Fixture-Cases.js +1 -0
  38. package/test/fixtures/injection/Injection-Fixture-Manifest.json +15 -0
  39. package/types/source/providers/Pict-Provider-DynamicSolver.d.ts.map +1 -1
  40. package/types/source/providers/Pict-Provider-ListDistilling.d.ts +90 -1
  41. package/types/source/providers/Pict-Provider-ListDistilling.d.ts.map +1 -1
  42. package/types/source/providers/Pict-Provider-MetaLists.d.ts.map +1 -1
  43. package/types/source/providers/inputs/Pict-Provider-Input-FacetFilter.d.ts +103 -0
  44. package/types/source/providers/inputs/Pict-Provider-Input-FacetFilter.d.ts.map +1 -0
  45. package/types/source/providers/inputs/Pict-Provider-Input-Select.d.ts +12 -0
  46. package/types/source/providers/inputs/Pict-Provider-Input-Select.d.ts.map +1 -1
  47. package/types/source/views/Pict-View-Form-Metacontroller.d.ts.map +1 -1
@@ -0,0 +1,372 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ Nested-distill sandbox: the node side.
4
+
5
+ node Sandbox-Runner.js [approach ...] [--live] [--verbose] [--keep]
6
+
7
+ For each approach module in ./approaches: fetches the entity reads it declares from a real
8
+ meadow-endpoints server (cached in ./.data; --live refetches), serves them to the page through the
9
+ driver's recorded-server stub, runs the approach's scripted user actions in headless Chrome and prints
10
+ [ok] / [fail] per check. Server credentials come from the JSON file named by SANDBOX_SERVER_CONFIG
11
+ ({ ServerURL, UserID, Password }).
12
+ */
13
+
14
+ const libFS = require('fs');
15
+ const libOS = require('os');
16
+ const libPath = require('path');
17
+ const libURL = require('url');
18
+ const libChildProcess = require('child_process');
19
+
20
+ const libHarness = require('../../test/browser/Injection-Conformance-Harness-Runner.js');
21
+ const libCommon = require('./approaches/_Common.js');
22
+
23
+ const PACKAGE_ROOT = libPath.resolve(__dirname, '..', '..');
24
+ const DRIVER_ENTRY = libPath.join(__dirname, 'Sandbox-Driver.js');
25
+ const BUNDLE_PATH = libPath.join(__dirname, 'dist', 'sandbox-driver.js');
26
+ const HEADLIGHT_DRIVER_ENTRY = libPath.join(__dirname, 'Sandbox-Driver-Headlight.js');
27
+ const HEADLIGHT_BUNDLE_PATH = libPath.join(__dirname, 'dist', 'sandbox-driver-headlight.js');
28
+ const DATA_DIRECTORY = libPath.join(__dirname, '.data');
29
+ const RESULTS_PATTERN = /data-results="([A-Za-z0-9+/=]*)"/;
30
+ const PAGE_SIZE = 250;
31
+
32
+ /**
33
+ * @return {string}
34
+ */
35
+ function buildBundle(pEntry, pOutput)
36
+ {
37
+ libFS.mkdirSync(libPath.dirname(pOutput), { recursive: true });
38
+ const tmpBrowserify = require.resolve('browserify/bin/cmd.js', { paths: [ PACKAGE_ROOT ] });
39
+ const tmpBuild = libChildProcess.spawnSync(process.execPath, [ tmpBrowserify, pEntry, '-s', 'NestedDistillSandbox', '-o', pOutput ], { cwd: PACKAGE_ROOT, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
40
+ if (tmpBuild.status !== 0)
41
+ {
42
+ throw new Error(`Bundling the sandbox driver failed: ${tmpBuild.stderr}`);
43
+ }
44
+ return pOutput;
45
+ }
46
+
47
+ class ServerSession
48
+ {
49
+ constructor(pConfigPath)
50
+ {
51
+ this.config = JSON.parse(libFS.readFileSync(pConfigPath, 'utf8'));
52
+ this.cookie = '';
53
+ }
54
+
55
+ async call(pMethod, pPath, pBody)
56
+ {
57
+ const tmpResponse = await fetch(`${this.config.ServerURL}${pPath}`,
58
+ {
59
+ method: pMethod,
60
+ headers: { 'Content-Type': 'application/json', Cookie: this.cookie },
61
+ body: pBody ? JSON.stringify(pBody) : undefined
62
+ });
63
+ for (const tmpRaw of (tmpResponse.headers.getSetCookie() || []))
64
+ {
65
+ if (tmpRaw.startsWith('UserSession='))
66
+ {
67
+ this.cookie = tmpRaw.split(';')[0];
68
+ }
69
+ }
70
+ const tmpText = await tmpResponse.text();
71
+ let tmpBody = tmpText;
72
+ try
73
+ {
74
+ tmpBody = JSON.parse(tmpText);
75
+ }
76
+ catch (pError)
77
+ {
78
+ // HTML error pages stay as text.
79
+ }
80
+ return { Status: tmpResponse.status, Body: tmpBody };
81
+ }
82
+
83
+ async login()
84
+ {
85
+ const tmpResult = await this.call('POST', 'Authenticate', { UserName: this.config.UserID, Password: this.config.Password });
86
+ if (!tmpResult.Body || (tmpResult.Body.LoggedIn !== true))
87
+ {
88
+ throw new Error(`Authenticate failed (${tmpResult.Status}).`);
89
+ }
90
+ return tmpResult.Body;
91
+ }
92
+
93
+ /**
94
+ * Reads every page of an entity set the way meadow-endpoints serves it.
95
+ *
96
+ * @param {string} pEntity
97
+ * @param {string} pFilter - a meadow FilteredTo expression, or '' for the unfiltered set
98
+ * @return {Promise<{ Records: Array<any>, Pages: Array<{ Path: string, Status: number, Count: number, Ms: number, Bytes: number }> }>}
99
+ */
100
+ async readAll(pEntity, pFilter)
101
+ {
102
+ const tmpRecords = [];
103
+ const tmpPages = [];
104
+ for (let tmpStart = 0; ; tmpStart += PAGE_SIZE)
105
+ {
106
+ const tmpPath = pFilter ? `${pEntity}s/FilteredTo/${encodeURIComponent(pFilter).replace(/%7E/g, '~')}/${tmpStart}/${PAGE_SIZE}` : `${pEntity}s/${tmpStart}/${PAGE_SIZE}`;
107
+ const tmpStartTime = Date.now();
108
+ const tmpResult = await this.call('GET', tmpPath);
109
+ const tmpBytes = JSON.stringify(tmpResult.Body || '').length;
110
+ tmpPages.push({ Path: tmpPath, Status: tmpResult.Status, Count: Array.isArray(tmpResult.Body) ? tmpResult.Body.length : -1, Ms: Date.now() - tmpStartTime, Bytes: tmpBytes });
111
+ if ((tmpResult.Status >= 400) || !Array.isArray(tmpResult.Body))
112
+ {
113
+ throw new Error(`GET ${tmpPath} -> ${tmpResult.Status}: ${JSON.stringify(tmpResult.Body).slice(0, 300)}`);
114
+ }
115
+ tmpRecords.push(...tmpResult.Body);
116
+ if (tmpResult.Body.length < PAGE_SIZE)
117
+ {
118
+ break;
119
+ }
120
+ }
121
+ return { Records: tmpRecords, Pages: tmpPages };
122
+ }
123
+ }
124
+
125
+ class RecordedServer
126
+ {
127
+ /**
128
+ * @param {boolean} pLive - refetch instead of reading the local cache
129
+ */
130
+ constructor(pLive)
131
+ {
132
+ this.live = pLive;
133
+ this.session = null;
134
+ this.responses = {};
135
+ this.wire = [];
136
+ libFS.mkdirSync(DATA_DIRECTORY, { recursive: true });
137
+ }
138
+
139
+ /**
140
+ * One meadow-endpoints page read, exactly the URL the browser's EntityProvider would issue.
141
+ *
142
+ * @param {string} pEntity
143
+ * @param {string} pFilter
144
+ * @param {number} pStart
145
+ * @param {number} pCount
146
+ * @return {Promise<Array<any>>}
147
+ */
148
+ async read(pEntity, pFilter, pStart, pCount)
149
+ {
150
+ const tmpKey = `${pEntity}|${pFilter}`;
151
+ const tmpCachePath = libPath.join(DATA_DIRECTORY, `${Buffer.from(`${tmpKey}|${pStart}|${pCount}`).toString('base64url').slice(0, 200)}.json`);
152
+ if (!this.live && libFS.existsSync(tmpCachePath))
153
+ {
154
+ const tmpCached = JSON.parse(libFS.readFileSync(tmpCachePath, 'utf8'));
155
+ this.remember(tmpKey, tmpCached.Records, Object.assign({ Cached: true, FetchedAt: tmpCached.FetchedAt }, tmpCached.Page));
156
+ return tmpCached.Records;
157
+ }
158
+ if (!this.session)
159
+ {
160
+ if (!process.env.SANDBOX_SERVER_CONFIG)
161
+ {
162
+ throw new Error(`No cached response for [${tmpKey}] and SANDBOX_SERVER_CONFIG is not set.`);
163
+ }
164
+ this.session = new ServerSession(process.env.SANDBOX_SERVER_CONFIG);
165
+ await this.session.login();
166
+ }
167
+ const tmpFilterSegment = encodeURIComponent(pFilter).replace(/%7E/g, '~').replace(/%2C/g, ',');
168
+ const tmpPath = pFilter ? `${pEntity}s/FilteredTo/${tmpFilterSegment}/${pStart}/${pCount}` : `${pEntity}s/${pStart}/${pCount}`;
169
+ const tmpStartTime = Date.now();
170
+ const tmpResult = await this.session.call('GET', tmpPath);
171
+ if ((tmpResult.Status >= 400) || !Array.isArray(tmpResult.Body))
172
+ {
173
+ throw new Error(`GET ${tmpPath} -> ${tmpResult.Status}: ${JSON.stringify(tmpResult.Body).slice(0, 300)}`);
174
+ }
175
+ const tmpPage = { Path: tmpPath, Status: tmpResult.Status, Count: tmpResult.Body.length, Ms: Date.now() - tmpStartTime, Bytes: JSON.stringify(tmpResult.Body).length };
176
+ const tmpFetchedAt = new Date().toISOString();
177
+ libFS.writeFileSync(tmpCachePath, JSON.stringify({ FetchedAt: tmpFetchedAt, Server: this.session.config.ServerURL, Page: tmpPage, Records: tmpResult.Body }));
178
+ this.remember(tmpKey, tmpResult.Body, Object.assign({ Cached: false, FetchedAt: tmpFetchedAt }, tmpPage));
179
+ return tmpResult.Body;
180
+ }
181
+
182
+ remember(pKey, pRecords, pPage)
183
+ {
184
+ this.responses[pKey] = pRecords;
185
+ if (!this.wire.find((pEntry) => pEntry.Key === pKey))
186
+ {
187
+ this.wire.push(Object.assign({ Key: pKey }, pPage));
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Runs a manifest's InitialBundle with pict's own bundle engine (templating, waves, ProjectDataset)
193
+ * against the real server, recording every read so the page can replay it byte-for-byte.
194
+ *
195
+ * @param {Array<Record<string, any>>} pBundle
196
+ * @param {Record<string, any>} pAppData
197
+ * @return {Promise<Record<string, any>>} the AppData after the bundle ran
198
+ */
199
+ async runBundle(pBundle, pAppData)
200
+ {
201
+ const libPict = require(require.resolve('pict', { paths: [ PACKAGE_ROOT ] }));
202
+ const tmpPict = new libPict({ Product: 'NestedDistillSandboxNode', LogNoisiness: 0 });
203
+ tmpPict.AppData = JSON.parse(JSON.stringify(pAppData || {}));
204
+ const tmpPending = [];
205
+ const fServe = (pEntity, pFilter, pStart, pCount, fCallback) =>
206
+ {
207
+ const tmpPromise = this.read(pEntity, pFilter, pStart || 0, pCount || 10000).then((pRecords) => fCallback(null, pRecords), (pError) => fCallback(pError));
208
+ tmpPending.push(tmpPromise);
209
+ };
210
+ tmpPict.EntityProvider.getEntitySet = (pEntity, pFilter, fCallback) => fServe(pEntity, pFilter, 0, 10000, fCallback);
211
+ tmpPict.EntityProvider.getEntitySetPage = (pEntity, pFilter, pStart, pCount, fCallback) => fServe(pEntity, pFilter, pStart, pCount, fCallback);
212
+ await new Promise((fResolve, fReject) => tmpPict.EntityProvider.gatherDataFromServer(JSON.parse(JSON.stringify(pBundle || [])), (pError) => (pError ? fReject(pError) : fResolve())));
213
+ return tmpPict.AppData;
214
+ }
215
+ }
216
+
217
+ /**
218
+ * @param {Record<string, any>} pConfig
219
+ * @param {string} pLabel
220
+ * @param {boolean} pKeep
221
+ * @return {Record<string, any>}
222
+ */
223
+ function runPage(pConfig, pLabel, pKeep)
224
+ {
225
+ const tmpChrome = libHarness.findChrome();
226
+ if (!tmpChrome)
227
+ {
228
+ throw new Error('No chrome-family browser found; set CHROME_BIN.');
229
+ }
230
+ const tmpWorkDirectory = libFS.mkdtempSync(libPath.join(libOS.tmpdir(), 'nested-distill-sandbox-'));
231
+ const tmpConfigPath = libPath.join(tmpWorkDirectory, `${pLabel}-config.js`);
232
+ libFS.writeFileSync(tmpConfigPath, `window.SandboxConfig = ${JSON.stringify(pConfig)};\n`);
233
+ const tmpPictDist = require.resolve('pict/dist/pict.js', { paths: [ PACKAGE_ROOT ] });
234
+ const tmpPagePath = libPath.join(tmpWorkDirectory, `${pLabel}.html`);
235
+ const fURL = (pPath) => libURL.pathToFileURL(pPath).href;
236
+ libFS.writeFileSync(tmpPagePath, `<!doctype html>
237
+ <html lang="en">
238
+ <head>
239
+ <meta charset="utf-8">
240
+ <title>Nested Distill Sandbox</title>
241
+ <style id="PICT-CSS"></style>
242
+ <script src="${fURL(tmpConfigPath)}"></script>
243
+ <script src="${fURL(tmpPictDist)}"></script>
244
+ <script src="${fURL(pConfig.Host === 'Headlight' ? HEADLIGHT_BUNDLE_PATH : BUNDLE_PATH)}"></script>
245
+ </head>
246
+ <body>
247
+ <div id="Pict-Form-Container"></div>
248
+ <div id="Sandbox-Results"></div>
249
+ <script>Pict.safeOnDocumentReady(function () { NestedDistillSandbox.run(); });</script>
250
+ </body>
251
+ </html>
252
+ `);
253
+ const tmpProfileDirectory = libFS.mkdtempSync(libPath.join(libOS.tmpdir(), 'nested-distill-profile-'));
254
+ const tmpBrowser = libChildProcess.spawnSync(tmpChrome,
255
+ [
256
+ '--headless=new', '--disable-gpu', '--no-sandbox', '--no-first-run', '--no-default-browser-check',
257
+ '--allow-file-access-from-files', '--virtual-time-budget=60000',
258
+ `--user-data-dir=${tmpProfileDirectory}`, '--dump-dom', fURL(tmpPagePath),
259
+ ],
260
+ { encoding: 'utf8', maxBuffer: 512 * 1024 * 1024, timeout: 180000 });
261
+ libFS.rmSync(tmpProfileDirectory, { recursive: true, force: true });
262
+ if (!pKeep)
263
+ {
264
+ libFS.rmSync(tmpWorkDirectory, { recursive: true, force: true });
265
+ }
266
+ else
267
+ {
268
+ console.log(` page kept at ${tmpPagePath}`);
269
+ }
270
+ const tmpMatch = RESULTS_PATTERN.exec(tmpBrowser.stdout || '');
271
+ if (!tmpMatch)
272
+ {
273
+ throw new Error(`The sandbox page published no results. Browser stderr: ${String(tmpBrowser.stderr || '').split('\n').slice(-12).join('\n')}`);
274
+ }
275
+ return JSON.parse(Buffer.from(tmpMatch[1], 'base64').toString('utf8'));
276
+ }
277
+
278
+ async function main()
279
+ {
280
+ const tmpArguments = process.argv.slice(2);
281
+ const tmpLive = tmpArguments.includes('--live');
282
+ const tmpVerbose = tmpArguments.includes('--verbose');
283
+ const tmpKeep = tmpArguments.includes('--keep');
284
+ let tmpNames = tmpArguments.filter((pArgument) => !pArgument.startsWith('--'));
285
+ const tmpApproachDirectory = libPath.join(__dirname, 'approaches');
286
+ if (tmpNames.length < 1)
287
+ {
288
+ tmpNames = libFS.readdirSync(tmpApproachDirectory).filter((pFile) => pFile.endsWith('.js') && !pFile.startsWith('_')).map((pFile) => pFile.replace(/\.js$/, '')).sort();
289
+ }
290
+ buildBundle(DRIVER_ENTRY, BUNDLE_PATH);
291
+ let tmpHeadlightBuilt = false;
292
+ const tmpReport = {};
293
+ let tmpFailures = 0;
294
+ for (const tmpName of tmpNames)
295
+ {
296
+ const tmpApproach = require(libPath.join(tmpApproachDirectory, `${tmpName}.js`));
297
+ if ((tmpApproach.Host === 'Headlight') && !tmpHeadlightBuilt)
298
+ {
299
+ buildBundle(HEADLIGHT_DRIVER_ENTRY, HEADLIGHT_BUNDLE_PATH);
300
+ tmpHeadlightBuilt = true;
301
+ }
302
+ console.log(`\n=== ${tmpName}${tmpApproach.Baseline ? ' (baseline)' : ''}: ${tmpApproach.Title}`);
303
+ const tmpServer = new RecordedServer(tmpLive);
304
+ const tmpCatalog = await tmpServer.read('Product', '', 0, 10000);
305
+ const tmpBase = tmpApproach.page();
306
+ const tmpBaseAppData = await tmpServer.runBundle(tmpBase.Manifest.InitialBundle, libCommon.appData());
307
+ let tmpFixtures = null;
308
+ try
309
+ {
310
+ tmpFixtures = libCommon.pickFixtures(libCommon.expectedGraph(tmpServer.responses), tmpCatalog);
311
+ }
312
+ catch (pError)
313
+ {
314
+ console.log(` (no fixtures from this approach's graph: ${pError.message})`);
315
+ }
316
+ tmpReport[tmpName] = { Title: tmpApproach.Title, Scenarios: {} };
317
+ for (const tmpScenario of tmpApproach.scenarios(tmpFixtures))
318
+ {
319
+ const tmpScenarioAppData = tmpScenario.AppData || libCommon.appData();
320
+ await tmpServer.runBundle(tmpBase.Manifest.InitialBundle, tmpScenarioAppData);
321
+ for (const tmpRequest of (tmpScenario.ExtraRequests || []))
322
+ {
323
+ await tmpServer.read(tmpRequest.Entity, tmpRequest.Filter, 0, 10000);
324
+ }
325
+ const tmpGraph = libCommon.expectedGraph(tmpServer.responses);
326
+ const tmpConfig = Object.assign({ ServerResponses: tmpServer.responses, GroupHash: libCommon.GROUP_HASH, MarshalDestination: libCommon.MARSHAL_ROOT, Host: tmpApproach.Host || 'PictSectionForm' }, tmpBase, { AppData: tmpScenarioAppData, Script: tmpScenario.Script }, tmpScenario.Page || {});
327
+ let tmpResults;
328
+ try
329
+ {
330
+ tmpResults = runPage(tmpConfig, `${tmpName}-${tmpScenario.Name}`, tmpKeep);
331
+ }
332
+ catch (pError)
333
+ {
334
+ tmpResults = { Fatal: String(pError), Snapshots: [], Errors: [] };
335
+ }
336
+ let tmpChecks;
337
+ try
338
+ {
339
+ tmpChecks = tmpResults.Fatal ? [ { Label: 'page ran', Passed: false, Detail: tmpResults.Fatal } ] : tmpScenario.checks(tmpResults, tmpFixtures, tmpGraph);
340
+ }
341
+ catch (pError)
342
+ {
343
+ tmpChecks = [ { Label: 'checks ran', Passed: false, Detail: String(pError && pError.stack) } ];
344
+ }
345
+ tmpReport[tmpName].Scenarios[tmpScenario.Name] = { Checks: tmpChecks, Errors: tmpResults.Errors, Requests: tmpResults.Requests, Timings: tmpResults.Timings, Snapshots: tmpVerbose ? tmpResults.Snapshots : undefined };
346
+ console.log(` -- ${tmpScenario.Name} (first render ${tmpResults.Timings ? tmpResults.Timings.FirstRenderMs : '?'} ms, ${tmpResults.ErrorCount || 0} error log line(s))`);
347
+ for (const tmpCheck of tmpChecks)
348
+ {
349
+ const tmpSeverity = tmpCheck.Passed ? 'ok' : (tmpCheck.Expected === false ? 'known' : 'fail');
350
+ if ((tmpSeverity === 'fail') && !tmpApproach.Baseline)
351
+ {
352
+ tmpFailures++;
353
+ }
354
+ console.log(` [${tmpSeverity}] ${tmpCheck.Label}${(!tmpCheck.Passed && tmpCheck.Detail) ? ' -- ' + JSON.stringify(tmpCheck.Detail).slice(0, 400) : ''}`);
355
+ }
356
+ if (tmpVerbose && tmpResults.Errors && tmpResults.Errors.length)
357
+ {
358
+ console.log(` errors: ${JSON.stringify(tmpResults.Errors.slice(0, 8))}`);
359
+ }
360
+ }
361
+ for (const tmpWire of tmpServer.wire)
362
+ {
363
+ console.log(` wire ${tmpWire.Cached ? '(cached ' + tmpWire.FetchedAt + ')' : '(live)'} ${tmpWire.Path || tmpWire.Key}: ${tmpWire.Count} records, ${(tmpWire.Bytes / 1024).toFixed(0)} KB, ${tmpWire.Ms} ms`);
364
+ }
365
+ tmpReport[tmpName].Wire = tmpServer.wire;
366
+ }
367
+ libFS.writeFileSync(libPath.join(__dirname, 'dist', 'sandbox-report.json'), JSON.stringify(tmpReport, null, '\t'));
368
+ console.log(`\n${tmpFailures} unexpected failure(s). Report: dist/sandbox-report.json`);
369
+ return tmpFailures ? 1 : 0;
370
+ }
371
+
372
+ main().then((pCode) => { process.exitCode = pCode; }, (pError) => { console.error(pError); process.exitCode = 2; });
@@ -0,0 +1,67 @@
1
+ /*
2
+ A1: the per-row fetch pattern -- picking a product runs a TabularTriggerGroup that fetches that Product
3
+ record and autofills the row's Site / Pit / Gsb from the row cache when the response lands.
4
+ Replayed with a realistic server latency.
5
+ */
6
+
7
+ const libCommon = require('./_Common.js');
8
+ const libScenarios = require('./_Scenarios.js');
9
+
10
+ const SELECT_COLUMNS = [ 'Material' ];
11
+ const CAPABILITIES = { NarrowByRow: false, AutofillUnique: false, ClearOnChange: false };
12
+ const LATENCY_MS = 90;
13
+ const TRIGGER = 'AggregateProductRow';
14
+
15
+ const fReceiver = (pTriggerAddress) => ({ Providers: [ 'Pict-Input-TabularTriggerGroup' ], TabularTriggerGroup: { TriggerGroupHash: TRIGGER, TriggerAddress: pTriggerAddress, MarshalEmptyValues: true } });
16
+
17
+ function page()
18
+ {
19
+ return (
20
+ {
21
+ SelectColumns: SELECT_COLUMNS,
22
+ ProbeAddresses: [ libScenarios.SUMMARY_ADDRESS ],
23
+ ServerLatencyMs: LATENCY_MS,
24
+ Manifest: libCommon.formManifest(
25
+ {
26
+ InitialBundle: libCommon.graphBundle(),
27
+ PickLists:
28
+ [
29
+ { Hash: 'AggregateProducts', ListAddress: 'AggregateProducts', ListSourceAddress: libCommon.GRAPH_ADDRESS, ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.IDProduct~}', TextTemplate: '{~D:Record.Name~} - {~D:Record.Source~} ({~D:Record.PitNumber~})', Sorted: true },
30
+ ],
31
+ Columns:
32
+ {
33
+ Site: { Name: 'Site', PictForm: Object.assign({ InputType: 'ReadOnly' }, fReceiver('Product.Metadata.Current.Site')) },
34
+ PitNumber: { Name: 'Pit', PictForm: Object.assign({ InputType: 'ReadOnly' }, fReceiver('Product.Metadata.PitNumber')) },
35
+ Material:
36
+ {
37
+ Name: 'Aggregate Product',
38
+ PictForm:
39
+ {
40
+ InputType: 'Option', SelectOptionsPickList: 'AggregateProducts', Width: 6,
41
+ Providers: [ 'Pict-Input-TabularTriggerGroup' ],
42
+ TabularTriggerGroup: { TriggerGroupHash: TRIGGER, TriggerAllInputs: true, EntitiesBundle: [ { Entity: 'Product', Filter: 'FBV~IDProduct~EQ~{~D:Record.Value~}', Destination: 'Product', SingleRecord: true } ] }
43
+ }
44
+ },
45
+ Gsb: { Name: 'Gsb', DataType: 'Number', PictForm: Object.assign({ InputType: 'ReadOnly' }, fReceiver('Product.Metadata.Current.Gsb.Use')) },
46
+ BlendPct: { Name: 'Blend Percent', DataType: 'PreciseNumber', PictForm: {} },
47
+ }
48
+ })
49
+ });
50
+ }
51
+
52
+ module.exports =
53
+ {
54
+ Baseline: true,
55
+ Title: `Per-row fetch on change (TabularTriggerGroup + row cache autofill), ${LATENCY_MS} ms server latency`,
56
+ page: page,
57
+ scenarios: (pFixtures) =>
58
+ {
59
+ const tmpScenarios = libScenarios.scenarios(pFixtures, CAPABILITIES, SELECT_COLUMNS);
60
+ for (const tmpScenario of tmpScenarios)
61
+ {
62
+ const tmpIDs = tmpScenario.Script.filter((pStep) => (pStep.Action === 'choose') && (pStep.Column === 'Material')).map((pStep) => pStep.Value);
63
+ tmpScenario.ExtraRequests = Array.from(new Set(tmpIDs)).map((pID) => ({ Entity: 'Product', Filter: `FBV~IDProduct~EQ~${pID}` }));
64
+ }
65
+ return tmpScenarios;
66
+ },
67
+ };
@@ -0,0 +1,61 @@
1
+ /*
2
+ A3: what ships today for narrowing -- CrossMap ListFilterRules over the graph, refreshed by an
3
+ AutofillTriggerGroup with SelectOptionsRefresh. A CrossMap's FilterToValueAddress is one form address,
4
+ so a tabular column can only be pointed at a fixed row (row 0 here).
5
+ */
6
+
7
+ const libCommon = require('./_Common.js');
8
+ const libScenarios = require('./_Scenarios.js');
9
+
10
+ const SELECT_COLUMNS = [ 'Site', 'PitNumber', 'Material' ];
11
+ const CAPABILITIES = { NarrowByRow: false, RowIsolation: false, AutofillUnique: false, ClearOnChange: false, SnapshotCarry: false };
12
+ const TRIGGER = 'AggregateFacetChange';
13
+
14
+ const fLookup = (pField) => `findfirstvaluebyexactmatch("${libCommon.GRAPH_ADDRESS}", "IDProduct", Material, "${pField}")`;
15
+ const fCrossMap = (pJoinListValueAddress, pExternalValueAddress, pRowZeroColumn) => (
16
+ {
17
+ Filter: `${pJoinListValueAddress} by ${pExternalValueAddress}`,
18
+ FilterType: 'CrossMap',
19
+ JoinListAddress: libCommon.GRAPH_ADDRESS,
20
+ JoinListAddressGlobal: true,
21
+ JoinListValueAddress: pJoinListValueAddress,
22
+ ExternalValueAddress: pExternalValueAddress,
23
+ FilterToValueAddress: `${libCommon.ROWS_ADDRESS}[0].${pRowZeroColumn}`,
24
+ IgnoreEmpty: true
25
+ });
26
+ const fRefresh = { Providers: [ 'Pict-Input-AutofillTriggerGroup' ], AutofillTriggerGroup: [ { TriggerGroupHash: TRIGGER, TriggerAllInputs: true }, { TriggerGroupHash: TRIGGER, SelectOptionsRefresh: true } ] };
27
+
28
+ function page()
29
+ {
30
+ return (
31
+ {
32
+ SelectColumns: SELECT_COLUMNS,
33
+ ProbeAddresses: [ libScenarios.SUMMARY_ADDRESS ],
34
+ Manifest: libCommon.formManifest(
35
+ {
36
+ InitialBundle: libCommon.graphBundle(),
37
+ PickLists:
38
+ [
39
+ { Hash: 'AggregateSites', ListAddress: 'AggregateSites', ListSourceAddress: libCommon.GRAPH_ADDRESS, ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.Site~}', TextTemplate: '{~D:Record.Site~}', Unique: true, Sorted: true },
40
+ { Hash: 'AggregatePits', ListAddress: 'AggregatePits', ListSourceAddress: libCommon.GRAPH_ADDRESS, ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.PitNumber~}', TextTemplate: '{~D:Record.PitNumber~}', Unique: true, Sorted: true },
41
+ { Hash: 'AggregateProducts', ListAddress: 'AggregateProducts', ListSourceAddress: libCommon.GRAPH_ADDRESS, ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.IDProduct~}', TextTemplate: '{~D:Record.Name~} - {~D:Record.Source~}', Sorted: true },
42
+ ],
43
+ RecordSetSolvers: [ `Gsb = ${fLookup('Gsb')}`, `Producer = ${fLookup('IDOrganization')}`, `DesignYear = ${fLookup('DesignYear')}` ],
44
+ Columns:
45
+ {
46
+ Site: { Name: 'Site', PictForm: Object.assign({ InputType: 'Option', SelectOptionsPickList: 'AggregateSites' }, fRefresh) },
47
+ PitNumber: { Name: 'Pit', PictForm: Object.assign({ InputType: 'Option', SelectOptionsPickList: 'AggregatePits', ListFilterRules: [ fCrossMap('PitNumber', 'Site', 'Site') ] }, fRefresh) },
48
+ Material: { Name: 'Aggregate Product', PictForm: Object.assign({ InputType: 'Option', SelectOptionsPickList: 'AggregateProducts', Width: 6, ListFilterRules: [ fCrossMap('IDProduct', 'Site', 'Site'), fCrossMap('IDProduct', 'PitNumber', 'PitNumber') ] }, fRefresh) },
49
+ BlendPct: { Name: 'Blend Percent', DataType: 'PreciseNumber', PictForm: {} },
50
+ }
51
+ })
52
+ });
53
+ }
54
+
55
+ module.exports =
56
+ {
57
+ Baseline: true,
58
+ Title: 'Existing CrossMap ListFilterRules + SelectOptionsRefresh trigger group (no new code)',
59
+ page: page,
60
+ scenarios: (pFixtures) => libScenarios.scenarios(pFixtures, CAPABILITIES, SELECT_COLUMNS),
61
+ };
@@ -0,0 +1,53 @@
1
+ /*
2
+ A4: load the graph once, pick the product from one flat list, derive everything else with RecordSetSolvers.
3
+
4
+ Uses only what ships today: a form-level InitialBundle + ProjectDataset, a form-level PickList and
5
+ findfirstvaluebyexactmatch. Site and Pit are read-only results of the product, not choices.
6
+ */
7
+
8
+ const libCommon = require('./_Common.js');
9
+ const libScenarios = require('./_Scenarios.js');
10
+
11
+ const SELECT_COLUMNS = [ 'Material' ];
12
+ const CAPABILITIES = { NarrowByRow: false, AutofillUnique: false, ClearOnChange: false, SnapshotCarry: false };
13
+
14
+ const fLookup = (pField) => `findfirstvaluebyexactmatch("${libCommon.GRAPH_ADDRESS}", "IDProduct", Material, "${pField}")`;
15
+
16
+ function page()
17
+ {
18
+ return (
19
+ {
20
+ SelectColumns: SELECT_COLUMNS,
21
+ ProbeAddresses: [ libScenarios.SUMMARY_ADDRESS ],
22
+ Manifest: libCommon.formManifest(
23
+ {
24
+ InitialBundle: libCommon.graphBundle(),
25
+ PickLists:
26
+ [
27
+ { Hash: 'AggregateProducts', ListAddress: 'AggregateProducts', ListSourceAddress: libCommon.GRAPH_ADDRESS, ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.IDProduct~}', TextTemplate: '{~D:Record.Name~} - {~D:Record.Source~} ({~D:Record.PitNumber~})', Sorted: true },
28
+ ],
29
+ RecordSetSolvers:
30
+ [
31
+ `Site = ${fLookup('Site')}`,
32
+ `PitNumber = ${fLookup('PitNumber')}`,
33
+ `Gsb = ${fLookup('Gsb')}`,
34
+ `Producer = ${fLookup('IDOrganization')}`,
35
+ `DesignYear = ${fLookup('DesignYear')}`,
36
+ ],
37
+ Columns:
38
+ {
39
+ Site: { Name: 'Site', PictForm: { InputType: 'ReadOnly' } },
40
+ PitNumber: { Name: 'Pit', PictForm: { InputType: 'ReadOnly' } },
41
+ Material: { Name: 'Aggregate Product', PictForm: { InputType: 'Option', SelectOptionsPickList: 'AggregateProducts', Width: 6 } },
42
+ BlendPct: { Name: 'Blend Percent', DataType: 'PreciseNumber', PictForm: {} },
43
+ }
44
+ })
45
+ });
46
+ }
47
+
48
+ module.exports =
49
+ {
50
+ Title: 'Load-once graph, one flat product list, Site/Pit/Gsb derived by RecordSetSolvers (only needs the ListSourceAddressGlobal picklist flag)',
51
+ page: page,
52
+ scenarios: (pFixtures) => libScenarios.scenarios(pFixtures, CAPABILITIES, SELECT_COLUMNS),
53
+ };
@@ -0,0 +1,75 @@
1
+ /*
2
+ A5: load the graph once; Site, Pit and Product are three dropdowns over it, each narrowed by the other two
3
+ in the same row (Facet ListFilterRules), kept consistent on change (Pict-Input-FacetFilter), and the
4
+ product's carried values derived by RecordSetSolvers.
5
+ */
6
+
7
+ const libCommon = require('./_Common.js');
8
+ const libScenarios = require('./_Scenarios.js');
9
+
10
+ const SELECT_COLUMNS = [ 'Site', 'PitNumber', 'Material' ];
11
+ const CAPABILITIES = {};
12
+
13
+ const CARRY_FIELDS = { Gsb: 'Gsb', Producer: 'IDOrganization', DesignYear: 'DesignYear' };
14
+
15
+ const fFacet = (pJoinListValueAddress, pNarrowBy, pCarryFields) => (
16
+ {
17
+ ListFilterRules:
18
+ [
19
+ Object.assign(
20
+ {
21
+ Filter: 'Aggregate product graph',
22
+ FilterType: 'Facet',
23
+ JoinListAddress: libCommon.GRAPH_ADDRESS,
24
+ JoinListAddressGlobal: true,
25
+ JoinListValueAddress: pJoinListValueAddress,
26
+ NarrowBy: pNarrowBy,
27
+ Facets:
28
+ [
29
+ { JoinListValueAddress: 'State', Value: libCommon.STATE },
30
+ { JoinListValueAddress: 'EffectiveDate', Operator: 'LE', ValueAddress: 'ProductFilterToday' },
31
+ { JoinListValueAddress: 'ExpirationDate', Operator: 'GE', ValueAddress: 'ProductFilterToday' }
32
+ ]
33
+ }, pCarryFields ? { CarryFields: pCarryFields } : {})
34
+ ],
35
+ Providers: [ 'Pict-Input-FacetFilter' ]
36
+ });
37
+
38
+ /**
39
+ * @param {string} pNarrowBy
40
+ * @return {Record<string, any>}
41
+ */
42
+ function page(pNarrowBy)
43
+ {
44
+ return (
45
+ {
46
+ SelectColumns: SELECT_COLUMNS,
47
+ ProbeAddresses: [ libScenarios.SUMMARY_ADDRESS ],
48
+ Manifest: libCommon.formManifest(
49
+ {
50
+ InitialBundle: libCommon.graphBundle(),
51
+ PickLists:
52
+ [
53
+ { Hash: 'AggregateSites', ListAddress: 'AggregateSites', ListSourceAddress: libCommon.GRAPH_ADDRESS, ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.Site~}', TextTemplate: '{~D:Record.Site~}', Unique: true, Sorted: true },
54
+ { Hash: 'AggregatePits', ListAddress: 'AggregatePits', ListSourceAddress: libCommon.GRAPH_ADDRESS, ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.PitNumber~}', TextTemplate: '{~D:Record.PitNumber~}', Unique: true, Sorted: true },
55
+ { Hash: 'AggregateProducts', ListAddress: 'AggregateProducts', ListSourceAddress: libCommon.GRAPH_ADDRESS, ListSourceAddressGlobal: true, IDTemplate: '{~D:Record.IDProduct~}', TextTemplate: '{~D:Record.Name~} - {~D:Record.Source~}', Sorted: true },
56
+ ],
57
+ Columns:
58
+ {
59
+ Site: { Name: 'Site', PictForm: Object.assign({ InputType: 'Option', SelectOptionsPickList: 'AggregateSites' }, fFacet('Site', pNarrowBy)) },
60
+ PitNumber: { Name: 'Pit', PictForm: Object.assign({ InputType: 'Option', SelectOptionsPickList: 'AggregatePits' }, fFacet('PitNumber', pNarrowBy)) },
61
+ Material: { Name: 'Aggregate Product', PictForm: Object.assign({ InputType: 'Option', SelectOptionsPickList: 'AggregateProducts', Width: 6 }, fFacet('IDProduct', pNarrowBy, CARRY_FIELDS)) },
62
+ BlendPct: { Name: 'Blend Percent', DataType: 'PreciseNumber', PictForm: {} },
63
+ }
64
+ })
65
+ });
66
+ }
67
+
68
+ module.exports =
69
+ {
70
+ Title: 'Load-once graph, three row-faceted dropdowns narrowed by the columns to their left (Facet rule, NarrowBy Preceding + Pict-Input-FacetFilter), product values carried into the row on change (CarryFields)',
71
+ page: () => page('Preceding'),
72
+ buildPage: page,
73
+ scenarios: (pFixtures) => libScenarios.scenarios(pFixtures, CAPABILITIES, SELECT_COLUMNS),
74
+ SELECT_COLUMNS: SELECT_COLUMNS,
75
+ };
@@ -0,0 +1,15 @@
1
+ /*
2
+ A5b: A5 with symmetric narrowing (NarrowBy "All"): every list is narrowed by every other choice in the row.
3
+ */
4
+
5
+ const libA5 = require('./A5-facet-filter.js');
6
+ const libScenarios = require('./_Scenarios.js');
7
+
8
+ const CAPABILITIES = { ClearOnChange: false };
9
+
10
+ module.exports =
11
+ {
12
+ Title: 'A5 with symmetric narrowing (NarrowBy All): each list narrowed by every other choice in its row',
13
+ page: () => libA5.buildPage('All'),
14
+ scenarios: (pFixtures) => libScenarios.scenarios(pFixtures, CAPABILITIES, libA5.SELECT_COLUMNS),
15
+ };
@@ -0,0 +1,15 @@
1
+ /*
2
+ A5 rendered by the Headlight host: Option columns become the Headlight Picker, which applies the Facet
3
+ rule when it (re)builds its options on each marshal.
4
+ */
5
+
6
+ const libA5 = require('./A5-facet-filter.js');
7
+ const libScenarios = require('./_Scenarios.js');
8
+
9
+ module.exports =
10
+ {
11
+ Host: 'Headlight',
12
+ Title: 'A5 under the Headlight host (Option -> Headlight Picker)',
13
+ page: () => libA5.buildPage('Preceding'),
14
+ scenarios: (pFixtures) => libScenarios.scenarios(pFixtures, {}, libA5.SELECT_COLUMNS),
15
+ };