snow-flow 10.0.1-dev.420 → 10.0.1-dev.422
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
|
@@ -169,6 +169,7 @@ async function createFlowViaScheduledJob(
|
|
|
169
169
|
" snap.setValue('active', true);",
|
|
170
170
|
" snap.setValue('master', true);",
|
|
171
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,98 @@ 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: enumerate FlowAPI methods + try create/save/compile ──
|
|
415
|
+
" r.steps.engine = { mode: 'discover_and_create', sn_fd: typeof sn_fd !== 'undefined' ? 'available' : 'unavailable' };",
|
|
416
|
+
" if (typeof sn_fd !== 'undefined' && sn_fd.FlowAPI) {",
|
|
417
|
+
" r.steps.engine.FlowAPI = 'available';",
|
|
418
|
+
"",
|
|
419
|
+
// Enumerate ALL methods on FlowAPI
|
|
420
|
+
" var apiMethods = [];",
|
|
421
|
+
" try {",
|
|
422
|
+
" for (var mk in sn_fd.FlowAPI) {",
|
|
423
|
+
" if (typeof sn_fd.FlowAPI[mk] === 'function') apiMethods.push(mk);",
|
|
424
|
+
" }",
|
|
425
|
+
" } catch(e) {}",
|
|
426
|
+
// Also try prototype methods
|
|
427
|
+
" try {",
|
|
428
|
+
" var proto = Object.getPrototypeOf ? Object.getPrototypeOf(sn_fd.FlowAPI) : sn_fd.FlowAPI.__proto__;",
|
|
429
|
+
" if (proto) {",
|
|
430
|
+
" for (var pk in proto) {",
|
|
431
|
+
" if (typeof proto[pk] === 'function' && apiMethods.indexOf(pk) === -1) apiMethods.push(pk + '(proto)');",
|
|
432
|
+
" }",
|
|
433
|
+
" }",
|
|
434
|
+
" } catch(e) {}",
|
|
435
|
+
// Try known method names that might exist
|
|
436
|
+
" var knownMethods = ['createFlow', 'createSubflow', 'saveFlow', 'save', 'newFlow', 'designFlow',",
|
|
437
|
+
" 'checkout', 'checkin', 'publish', 'activate', 'deactivate', 'compile', 'getFlow', 'getFlowById',",
|
|
438
|
+
" 'getDesignerModel', 'getDesignerStructure', 'openFlow', 'importFlow', 'createDraftFlow',",
|
|
439
|
+
" 'createVersion', 'publishFlow', 'activateFlow', 'compileFlow', 'getFlowStructure'];",
|
|
440
|
+
" for (var km = 0; km < knownMethods.length; km++) {",
|
|
441
|
+
" if (typeof sn_fd.FlowAPI[knownMethods[km]] === 'function' && apiMethods.indexOf(knownMethods[km]) === -1) {",
|
|
442
|
+
" apiMethods.push(knownMethods[km]);",
|
|
443
|
+
" }",
|
|
444
|
+
" }",
|
|
445
|
+
" r.steps.engine.all_methods = apiMethods;",
|
|
446
|
+
"",
|
|
447
|
+
// Try createFlow / createSubflow / createDraftFlow if they exist
|
|
448
|
+
" var createMethods = ['createFlow', 'createSubflow', 'createDraftFlow', 'newFlow'];",
|
|
449
|
+
" for (var cm = 0; cm < createMethods.length; cm++) {",
|
|
450
|
+
" if (typeof sn_fd.FlowAPI[createMethods[cm]] === 'function') {",
|
|
451
|
+
" try {",
|
|
452
|
+
" var createResult = sn_fd.FlowAPI[createMethods[cm]](flowName, flowDesc);",
|
|
453
|
+
" var crStr = createResult ? JSON.stringify(createResult).substring(0, 300) : 'null';",
|
|
454
|
+
" r.steps.engine['try_' + createMethods[cm]] = crStr;",
|
|
455
|
+
// If it returned a sys_id, use it as the real flow
|
|
456
|
+
" if (createResult && typeof createResult === 'string' && createResult.length === 32) {",
|
|
457
|
+
" r.steps.engine.engine_created_flow = createResult;",
|
|
458
|
+
" } else if (createResult && createResult.sys_id) {",
|
|
459
|
+
" r.steps.engine.engine_created_flow = createResult.sys_id + '';",
|
|
460
|
+
" }",
|
|
461
|
+
" } catch(cme) { r.steps.engine['try_' + createMethods[cm]] = 'error: ' + (cme.getMessage ? cme.getMessage() : cme + ''); }",
|
|
462
|
+
" }",
|
|
463
|
+
" }",
|
|
464
|
+
"",
|
|
465
|
+
// Try save/checkout/checkin on existing flow
|
|
466
|
+
" if (flowSysId) {",
|
|
467
|
+
" var saveMethods = ['save', 'saveFlow', 'checkout', 'checkin'];",
|
|
468
|
+
" for (var sm = 0; sm < saveMethods.length; sm++) {",
|
|
469
|
+
" if (typeof sn_fd.FlowAPI[saveMethods[sm]] === 'function') {",
|
|
470
|
+
" try {",
|
|
471
|
+
" var saveRes = sn_fd.FlowAPI[saveMethods[sm]](flowSysId);",
|
|
472
|
+
" r.steps.engine['try_' + saveMethods[sm]] = saveRes ? (saveRes + '').substring(0, 200) : 'success (null)';",
|
|
473
|
+
" } catch(se) { r.steps.engine['try_' + saveMethods[sm]] = 'error: ' + (se.getMessage ? se.getMessage() : se + ''); }",
|
|
474
|
+
" }",
|
|
475
|
+
" }",
|
|
476
|
+
" }",
|
|
477
|
+
"",
|
|
478
|
+
// Still try compile on flow (for diagnostics)
|
|
479
|
+
" if (flowSysId) {",
|
|
480
|
+
" try {",
|
|
481
|
+
" var flowCompResult = sn_fd.FlowAPI.compile(flowSysId);",
|
|
482
|
+
" r.steps.engine.compile_flow = flowCompResult ? (flowCompResult + '').substring(0, 200) : 'success (null)';",
|
|
483
|
+
" } catch(fce) { r.steps.engine.compile_flow = 'error: ' + (fce.getMessage ? fce.getMessage() : fce + ''); }",
|
|
484
|
+
" }",
|
|
485
|
+
"",
|
|
486
|
+
// Enumerate other sn_fd top-level objects
|
|
487
|
+
" var snfdKeys = [];",
|
|
488
|
+
" try {",
|
|
489
|
+
" for (var sk in sn_fd) {",
|
|
490
|
+
" snfdKeys.push(sk + ':' + typeof sn_fd[sk]);",
|
|
491
|
+
" }",
|
|
492
|
+
" } catch(e) {}",
|
|
493
|
+
" r.steps.engine.sn_fd_keys = snfdKeys;",
|
|
494
|
+
"",
|
|
495
|
+
// Also check for global FlowDesigner-related objects
|
|
496
|
+
" var globalApis = ['GlideFlowDesigner', 'FlowDesignerService', 'FlowDesignerUtil', 'FlowEngine'];",
|
|
497
|
+
" r.steps.engine.global_apis = {};",
|
|
498
|
+
" for (var ga = 0; ga < globalApis.length; ga++) {",
|
|
499
|
+
" try {",
|
|
500
|
+
" r.steps.engine.global_apis[globalApis[ga]] = eval('typeof ' + globalApis[ga]) !== 'undefined' ? 'available' : 'unavailable';",
|
|
501
|
+
" } catch(e) { r.steps.engine.global_apis[globalApis[ga]] = 'unavailable'; }",
|
|
502
|
+
" }",
|
|
503
|
+
" } else {",
|
|
504
|
+
" r.steps.engine.FlowAPI = 'unavailable';",
|
|
505
|
+
" }",
|
|
415
506
|
" }",
|
|
416
507
|
"",
|
|
417
508
|
" r.flow_sys_id = flowSysId ? flowSysId + '' : null;",
|
|
@@ -1843,16 +1934,38 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
|
|
|
1843
1934
|
createSummary.indented('Version created: ' + diagnostics.version_created + (diagnostics.version_method ? ' (' + diagnostics.version_method + ')' : ''));
|
|
1844
1935
|
if (diagnostics.engine_registration) {
|
|
1845
1936
|
var eng = diagnostics.engine_registration;
|
|
1846
|
-
if (eng.
|
|
1847
|
-
//
|
|
1848
|
-
|
|
1937
|
+
if (eng.mode === 'discover_and_create') {
|
|
1938
|
+
// Discovery mode — show all FlowAPI methods found
|
|
1939
|
+
createSummary.indented('Engine (discover): sn_fd=' + eng.sn_fd + ', FlowAPI=' + (eng.FlowAPI || 'unknown'));
|
|
1940
|
+
if (eng.all_methods) createSummary.indented(' FlowAPI methods: [' + eng.all_methods.join(', ') + ']');
|
|
1941
|
+
if (eng.sn_fd_keys) createSummary.indented(' sn_fd keys: [' + eng.sn_fd_keys.join(', ') + ']');
|
|
1942
|
+
// Show any create/save attempts
|
|
1943
|
+
var tryKeys = Object.keys(eng).filter(function(k: string) { return k.indexOf('try_') === 0; });
|
|
1944
|
+
for (var tk = 0; tk < tryKeys.length; tk++) {
|
|
1945
|
+
createSummary.indented(' ' + tryKeys[tk] + ': ' + eng[tryKeys[tk]]);
|
|
1946
|
+
}
|
|
1947
|
+
if (eng.engine_created_flow) createSummary.indented(' ENGINE CREATED FLOW: ' + eng.engine_created_flow);
|
|
1948
|
+
if (eng.compile_flow) createSummary.indented(' compile(flow): ' + eng.compile_flow);
|
|
1949
|
+
if (eng.global_apis) {
|
|
1950
|
+
var gaList = Object.keys(eng.global_apis).map(function(k: string) { return k + '=' + eng.global_apis[k]; }).join(', ');
|
|
1951
|
+
createSummary.indented(' Global APIs: ' + gaList);
|
|
1952
|
+
}
|
|
1953
|
+
} else if (eng.mode === 'compile') {
|
|
1954
|
+
var engineLabel = 'sn_fd=' + eng.sn_fd + ', FlowAPI=' + (eng.FlowAPI || 'unknown');
|
|
1955
|
+
if (eng.compile_snapshot) engineLabel += ', compile(snapshot)=' + eng.compile_snapshot;
|
|
1956
|
+
if (eng.compile_flow) engineLabel += ', compile(flow)=' + eng.compile_flow;
|
|
1957
|
+
if (eng.label_cache_after_compile) engineLabel += ', label_cache=' + eng.label_cache_after_compile;
|
|
1958
|
+
createSummary.indented('Engine (compile): ' + engineLabel);
|
|
1959
|
+
} else if (eng.sn_fd) {
|
|
1960
|
+
// Legacy probe-only mode (from scheduled job)
|
|
1961
|
+
var legacyLabel = 'sn_fd=' + eng.sn_fd;
|
|
1849
1962
|
if (eng.apis_found && eng.apis_found.length > 0) {
|
|
1850
|
-
|
|
1963
|
+
legacyLabel += ', APIs=[' + eng.apis_found.join(', ') + ']';
|
|
1851
1964
|
}
|
|
1852
|
-
if (eng.publish)
|
|
1853
|
-
if (eng.compile)
|
|
1854
|
-
if (eng.error)
|
|
1855
|
-
createSummary.indented('Engine (server-side): ' +
|
|
1965
|
+
if (eng.publish) legacyLabel += ', publishFlow=' + eng.publish;
|
|
1966
|
+
if (eng.compile) legacyLabel += ', compile=' + eng.compile;
|
|
1967
|
+
if (eng.error) legacyLabel += ', error=' + eng.error;
|
|
1968
|
+
createSummary.indented('Engine (server-side): ' + legacyLabel);
|
|
1856
1969
|
} else if (eng.success !== undefined) {
|
|
1857
1970
|
// REST-based engine registration (Table API path)
|
|
1858
1971
|
createSummary.indented('Engine registration: ' + (eng.success ? eng.method : 'FAILED'));
|