snow-flow 10.0.1-dev.419 → 10.0.1-dev.421
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/package.json
CHANGED
|
@@ -168,7 +168,8 @@ async function createFlowViaScheduledJob(
|
|
|
168
168
|
" snap.setValue('access', 'public');",
|
|
169
169
|
" snap.setValue('active', true);",
|
|
170
170
|
" snap.setValue('master', true);",
|
|
171
|
-
" snap.setValue('status', '
|
|
171
|
+
" snap.setValue('status', 'published');",
|
|
172
|
+
" snap.setValue('label_cache', '[]');",
|
|
172
173
|
" try { snap.setValue('sc_callable', false); } catch(e) {}",
|
|
173
174
|
" try { snap.setValue('callable_by_client_api', false); } catch(e) {}",
|
|
174
175
|
" snapId = snap.insert();",
|
|
@@ -410,8 +411,43 @@ async function createFlowViaScheduledJob(
|
|
|
410
411
|
" }",
|
|
411
412
|
" } catch(refE) { r.steps.reference_flow = { error: refE + '' }; }",
|
|
412
413
|
"",
|
|
413
|
-
// ──
|
|
414
|
-
" r.steps.engine = { mode: '
|
|
414
|
+
// ── Engine: try FlowAPI.compile on snapshot and flow ──
|
|
415
|
+
" r.steps.engine = { mode: 'compile', sn_fd: typeof sn_fd !== 'undefined' ? 'available' : 'unavailable' };",
|
|
416
|
+
" if (typeof sn_fd !== 'undefined' && sn_fd.FlowAPI) {",
|
|
417
|
+
" r.steps.engine.FlowAPI = 'available';",
|
|
418
|
+
// Try compile on snapshot first (snapshot extends sys_hub_flow_block)
|
|
419
|
+
" if (snapId) {",
|
|
420
|
+
" try {",
|
|
421
|
+
" var snapCompResult = sn_fd.FlowAPI.compile(snapId);",
|
|
422
|
+
" r.steps.engine.compile_snapshot = snapCompResult ? (snapCompResult + '').substring(0, 200) : 'success (null return)';",
|
|
423
|
+
" } catch(sce) { r.steps.engine.compile_snapshot = 'error: ' + (sce.getMessage ? sce.getMessage() : sce + ''); }",
|
|
424
|
+
" }",
|
|
425
|
+
// Then compile the flow record itself
|
|
426
|
+
" if (flowSysId) {",
|
|
427
|
+
" try {",
|
|
428
|
+
" var flowCompResult = sn_fd.FlowAPI.compile(flowSysId);",
|
|
429
|
+
" r.steps.engine.compile_flow = flowCompResult ? (flowCompResult + '').substring(0, 200) : 'success (null return)';",
|
|
430
|
+
" } catch(fce) { r.steps.engine.compile_flow = 'error: ' + (fce.getMessage ? fce.getMessage() : fce + ''); }",
|
|
431
|
+
" }",
|
|
432
|
+
// After compile, re-read snapshot to check if label_cache was populated
|
|
433
|
+
" if (snapId) {",
|
|
434
|
+
" try {",
|
|
435
|
+
" var postSnap = new GlideRecord('sys_hub_flow_snapshot');",
|
|
436
|
+
" if (postSnap.get(snapId)) {",
|
|
437
|
+
" var lc = postSnap.getValue('label_cache') + '';",
|
|
438
|
+
" r.steps.engine.label_cache_after_compile = lc.length > 5 ? lc.substring(0, 100) + '...(len:' + lc.length + ')' : lc;",
|
|
439
|
+
" }",
|
|
440
|
+
" } catch(e) {}",
|
|
441
|
+
" }",
|
|
442
|
+
// Try other known APIs
|
|
443
|
+
" var otherApis = ['FlowDesigner', 'FlowPublisher', 'FlowCompiler'];",
|
|
444
|
+
" r.steps.engine.other_apis = {};",
|
|
445
|
+
" for (var oa = 0; oa < otherApis.length; oa++) {",
|
|
446
|
+
" r.steps.engine.other_apis[otherApis[oa]] = typeof sn_fd[otherApis[oa]] !== 'undefined' ? 'available' : 'unavailable';",
|
|
447
|
+
" }",
|
|
448
|
+
" } else {",
|
|
449
|
+
" r.steps.engine.FlowAPI = 'unavailable';",
|
|
450
|
+
" }",
|
|
415
451
|
" }",
|
|
416
452
|
"",
|
|
417
453
|
" r.flow_sys_id = flowSysId ? flowSysId + '' : null;",
|
|
@@ -1130,7 +1166,7 @@ async function registerFlowWithEngine(
|
|
|
1130
1166
|
): Promise<{ success: boolean; method: string; attempts: string[] }> {
|
|
1131
1167
|
var attempts: string[] = [];
|
|
1132
1168
|
|
|
1133
|
-
// Helper: try a POST and classify the result
|
|
1169
|
+
// Helper: try a POST and classify the result (capture error body for diagnostics)
|
|
1134
1170
|
async function tryPost(label: string, url: string, body?: any): Promise<boolean> {
|
|
1135
1171
|
try {
|
|
1136
1172
|
await client.post(url, body || {});
|
|
@@ -1138,7 +1174,9 @@ async function registerFlowWithEngine(
|
|
|
1138
1174
|
return true;
|
|
1139
1175
|
} catch (e: any) {
|
|
1140
1176
|
var s = e.response?.status || 'err';
|
|
1141
|
-
|
|
1177
|
+
var errBody = '';
|
|
1178
|
+
try { errBody = JSON.stringify(e.response?.data || '').substring(0, 150); } catch (_) {}
|
|
1179
|
+
attempts.push(label + ': ' + s + (errBody ? ' ' + errBody : ''));
|
|
1142
1180
|
return false;
|
|
1143
1181
|
}
|
|
1144
1182
|
}
|
|
@@ -1841,16 +1879,27 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
|
|
|
1841
1879
|
createSummary.indented('Version created: ' + diagnostics.version_created + (diagnostics.version_method ? ' (' + diagnostics.version_method + ')' : ''));
|
|
1842
1880
|
if (diagnostics.engine_registration) {
|
|
1843
1881
|
var eng = diagnostics.engine_registration;
|
|
1844
|
-
if (eng.
|
|
1845
|
-
//
|
|
1846
|
-
var engineLabel = 'sn_fd=' + eng.sn_fd;
|
|
1882
|
+
if (eng.mode === 'compile') {
|
|
1883
|
+
// New compile mode (scheduled job path)
|
|
1884
|
+
var engineLabel = 'sn_fd=' + eng.sn_fd + ', FlowAPI=' + (eng.FlowAPI || 'unknown');
|
|
1885
|
+
if (eng.compile_snapshot) engineLabel += ', compile(snapshot)=' + eng.compile_snapshot;
|
|
1886
|
+
if (eng.compile_flow) engineLabel += ', compile(flow)=' + eng.compile_flow;
|
|
1887
|
+
if (eng.label_cache_after_compile) engineLabel += ', label_cache=' + eng.label_cache_after_compile;
|
|
1888
|
+
createSummary.indented('Engine (compile): ' + engineLabel);
|
|
1889
|
+
if (eng.other_apis) {
|
|
1890
|
+
var apiList = Object.keys(eng.other_apis).map(function(k: string) { return k + '=' + eng.other_apis[k]; }).join(', ');
|
|
1891
|
+
createSummary.indented(' Other APIs: ' + apiList);
|
|
1892
|
+
}
|
|
1893
|
+
} else if (eng.sn_fd) {
|
|
1894
|
+
// Legacy probe-only mode (from scheduled job)
|
|
1895
|
+
var legacyLabel = 'sn_fd=' + eng.sn_fd;
|
|
1847
1896
|
if (eng.apis_found && eng.apis_found.length > 0) {
|
|
1848
|
-
|
|
1897
|
+
legacyLabel += ', APIs=[' + eng.apis_found.join(', ') + ']';
|
|
1849
1898
|
}
|
|
1850
|
-
if (eng.publish)
|
|
1851
|
-
if (eng.compile)
|
|
1852
|
-
if (eng.error)
|
|
1853
|
-
createSummary.indented('Engine (server-side): ' +
|
|
1899
|
+
if (eng.publish) legacyLabel += ', publishFlow=' + eng.publish;
|
|
1900
|
+
if (eng.compile) legacyLabel += ', compile=' + eng.compile;
|
|
1901
|
+
if (eng.error) legacyLabel += ', error=' + eng.error;
|
|
1902
|
+
createSummary.indented('Engine (server-side): ' + legacyLabel);
|
|
1854
1903
|
} else if (eng.success !== undefined) {
|
|
1855
1904
|
// REST-based engine registration (Table API path)
|
|
1856
1905
|
createSummary.indented('Engine registration: ' + (eng.success ? eng.method : 'FAILED'));
|