@sonisoft/now-sdk-ext-cli 2.0.1 → 2.1.0

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.
@@ -1678,123 +1678,6 @@
1678
1678
  "update.js"
1679
1679
  ]
1680
1680
  },
1681
- "exec": {
1682
- "aliases": [],
1683
- "args": {
1684
- "scope": {
1685
- "description": "Scope to execute script in. Use \"global\" for global scope.",
1686
- "name": "scope",
1687
- "required": true
1688
- },
1689
- "file": {
1690
- "description": "File to execute in scripts background. If omitted, starts REPL mode.",
1691
- "name": "file",
1692
- "required": false
1693
- }
1694
- },
1695
- "description": "Execute JavaScript on a ServiceNow instance remotely using Scripts - Background.\n\nThis command allows you to run JavaScript either from files or interactively via REPL mode. It mimics the functionality of the Scripts - Background interface in ServiceNow, providing a way to execute scripts programmatically without manual interaction. The output is returned in real-time and can be piped to other commands or saved to files.\n\nModes:\n • File Mode: Provide a file path to execute scripts from a file\n • REPL Mode: Omit the file path to start an interactive session\n\nFeatures:\n • Execute local JavaScript files remotely\n • Interactive REPL for ad-hoc script execution\n • Script parameterization with {placeholder} replacement\n • Multi-line script support in REPL\n • Scope-aware execution (global or custom scope)\n • Real-time console output capture\n • Pipe-able output for command chaining\n • Debug logging support\n • Useful for data migration, testing, and administrative tasks\n\nScript Parameterization:\n Use {paramName} placeholders in your script files, then provide values via --params:\n • Supports any JSON-serializable values (strings, numbers, booleans)\n • Multiple parameters supported\n • All occurrences of each placeholder are replaced\n • Example: {token}, {username}, {environment}\n\nREPL Controls:\n • Press Enter to add a new line\n • Type .exec or press Ctrl+D to execute the script\n • Type .clear to clear the current input\n • Type .exit or press Ctrl+C twice to exit REPL\n\n⚠️ IMPORTANT SECURITY WARNING:\nThis command executes scripts with the same permissions and risks as using Scripts - Background directly\nin ServiceNow. Always:\n • Review scripts before execution\n • Test in non-production environments first\n • Use appropriate scoping to limit access\n • Be aware of data modification risks\n • Follow your organization's security policies\n • Never execute untrusted scripts\n\nScript Capabilities:\n Scripts run with full GlideSystem API access and can:\n • Query and modify database records\n • Create, update, and delete data\n • Execute business rules and workflows\n • Access all APIs available in Scripts - Background\n • Use gs, GlideRecord, GlideAggregate, and other server-side APIs",
1696
- "examples": [
1697
- {
1698
- "description": "Start REPL in global scope",
1699
- "command": "<%= config.bin %> <%= command.id %> global --auth dev-instance"
1700
- },
1701
- {
1702
- "description": "Start REPL in custom application scope",
1703
- "command": "<%= config.bin %> <%= command.id %> x_my_custom_app --auth dev-instance"
1704
- },
1705
- {
1706
- "description": "Execute a script file in global scope",
1707
- "command": "<%= config.bin %> <%= command.id %> global ./scripts/cleanup.js --auth dev-instance"
1708
- },
1709
- {
1710
- "description": "Execute a script file in a custom application scope",
1711
- "command": "<%= config.bin %> <%= command.id %> x_my_custom_app ./scripts/app-config.js --auth dev-instance"
1712
- },
1713
- {
1714
- "description": "Execute a parameterized script with single parameter",
1715
- "command": "<%= config.bin %> <%= command.id %> global ./scripts/query-user.js --auth dev-instance --params '{\"username\":\"admin\"}'"
1716
- },
1717
- {
1718
- "description": "Execute a parameterized script with multiple parameters",
1719
- "command": "<%= config.bin %> <%= command.id %> global ./scripts/update-record.js --auth dev-instance --params '{\"table\":\"incident\",\"field\":\"priority\",\"value\":\"1\"}'"
1720
- },
1721
- {
1722
- "description": "Execute and save output to a file",
1723
- "command": "<%= config.bin %> <%= command.id %> global ./scripts/report.js --auth dev-instance > report.txt"
1724
- },
1725
- {
1726
- "description": "Execute and pipe output to grep for filtering",
1727
- "command": "<%= config.bin %> <%= command.id %> global ./scripts/list-users.js --auth dev-instance | grep \"admin\""
1728
- },
1729
- {
1730
- "description": "Execute with debug logging to troubleshoot issues",
1731
- "command": "<%= config.bin %> <%= command.id %> global ./script.js --auth dev-instance --log-level debug"
1732
- },
1733
- {
1734
- "description": "Execute with parameters for template replacement",
1735
- "command": "<%= config.bin %> <%= command.id %> global ./script.js --auth dev-instance --params '{\"token\":\"abc123\",\"env\":\"dev\"}'"
1736
- }
1737
- ],
1738
- "flags": {
1739
- "json": {
1740
- "description": "Format output as json.",
1741
- "helpGroup": "GLOBAL",
1742
- "name": "json",
1743
- "allowNo": false,
1744
- "type": "boolean"
1745
- },
1746
- "auth": {
1747
- "char": "a",
1748
- "description": "Auth alias to use.",
1749
- "name": "auth",
1750
- "required": false,
1751
- "hasDynamicHelp": false,
1752
- "multiple": false,
1753
- "type": "option"
1754
- },
1755
- "log-level": {
1756
- "helpGroup": "GLOBAL",
1757
- "name": "log-level",
1758
- "summary": "Specify level for logging.",
1759
- "default": "info",
1760
- "hasDynamicHelp": false,
1761
- "multiple": false,
1762
- "options": [
1763
- "debug",
1764
- "warn",
1765
- "error",
1766
- "info",
1767
- "trace"
1768
- ],
1769
- "type": "option"
1770
- },
1771
- "params": {
1772
- "char": "p",
1773
- "description": "JSON object of parameters to replace in script file. Use {paramName} syntax in your script.",
1774
- "name": "params",
1775
- "required": false,
1776
- "hasDynamicHelp": false,
1777
- "multiple": false,
1778
- "type": "option"
1779
- }
1780
- },
1781
- "hasDynamicHelp": false,
1782
- "hiddenAliases": [],
1783
- "id": "exec",
1784
- "pluginAlias": "@sonisoft/now-sdk-ext-cli",
1785
- "pluginName": "@sonisoft/now-sdk-ext-cli",
1786
- "pluginType": "core",
1787
- "strict": true,
1788
- "enableJsonFlag": true,
1789
- "autocomplete": {},
1790
- "isESM": true,
1791
- "relativePath": [
1792
- "dist",
1793
- "commands",
1794
- "exec",
1795
- "index.js"
1796
- ]
1797
- },
1798
1681
  "flow:action": {
1799
1682
  "aliases": [],
1800
1683
  "args": {},
@@ -2257,7 +2140,7 @@
2257
2140
  "flow:run": {
2258
2141
  "aliases": [],
2259
2142
  "args": {},
2260
- "description": "Execute a Flow Designer flow by scoped name.\n\nRuns a flow using the sn_fd.FlowAPI ScriptableFlowRunner. Supports foreground (synchronous) and background (asynchronous) execution modes.\n\nFeatures:\n • Execute flows by scoped name (e.g. global.my_flow)\n • Pass input values as JSON\n • Foreground or background execution mode\n • Quick mode to skip execution detail records\n • Returns context ID, outputs, and debug information",
2143
+ "description": "Execute a published Flow Designer flow by scoped name.\n\nRuns a flow using the sn_fd.FlowAPI ScriptableFlowRunner. Supports foreground (synchronous) and background (asynchronous) execution modes.\n\nNote: This command requires the flow to be published. For testing flows that are not yet published (draft/saved state), use `flow test` instead.\n\nFeatures:\n • Execute flows by scoped name (e.g. global.my_flow)\n • Pass input values as JSON\n • Foreground or background execution mode\n • Quick mode to skip execution detail records\n • Returns context ID, outputs, and debug information",
2261
2144
  "examples": [
2262
2145
  {
2263
2146
  "description": "Run a flow in foreground mode",
@@ -2451,7 +2334,7 @@
2451
2334
  "flow:subflow": {
2452
2335
  "aliases": [],
2453
2336
  "args": {},
2454
- "description": "Execute a Flow Designer subflow by scoped name.\n\nRuns a subflow using the sn_fd.FlowAPI ScriptableFlowRunner.\n\nFeatures:\n • Execute subflows by scoped name\n • Pass input values as JSON\n • Foreground or background execution mode\n • Returns context ID, outputs, and debug information",
2337
+ "description": "Execute a published Flow Designer subflow by scoped name.\n\nRuns a subflow using the sn_fd.FlowAPI ScriptableFlowRunner.\n\nNote: This command requires the subflow to be published. For testing flows that are not yet published (draft/saved state), use `flow test` instead.\n\nFeatures:\n • Execute subflows by scoped name\n • Pass input values as JSON\n • Foreground or background execution mode\n • Returns context ID, outputs, and debug information",
2455
2338
  "examples": [
2456
2339
  {
2457
2340
  "description": "Run a subflow",
@@ -2560,6 +2443,225 @@
2560
2443
  "subflow.js"
2561
2444
  ]
2562
2445
  },
2446
+ "flow:test": {
2447
+ "aliases": [],
2448
+ "args": {},
2449
+ "description": "Test a Flow Designer flow without requiring it to be published.\n\nInvokes the same API as the \"Test\" button in Flow Designer, running the flow in its current saved (draft) state. Unlike `flow run` which requires a published flow and uses sn_fd.FlowAPI, `flow test` works on unpublished drafts via the ProcessFlow REST API.\n\nFeatures:\n • Test flows by sys_id or scoped name\n • Pass trigger output values as JSON via --output-map\n • Auto-resolves scope from flow definition if not provided\n • Synchronous or asynchronous execution",
2450
+ "examples": [
2451
+ {
2452
+ "description": "Test a flow by sys_id",
2453
+ "command": "<%= config.bin %> <%= command.id %> --flow-id 887dda5583237210fdb8f7b6feaad32c --output-map '{\"current\":\"0ecd7552db252200a6a2b31be0b8f5e6\",\"table_name\":\"change_request\"}' --auth dev"
2454
+ },
2455
+ {
2456
+ "description": "Test a flow by scoped name with explicit scope",
2457
+ "command": "<%= config.bin %> <%= command.id %> -f x_myapp.my_flow -o '{\"current\":\"abc123\",\"table_name\":\"incident\"}' --scope x_myapp --auth dev"
2458
+ },
2459
+ {
2460
+ "description": "Test with JSON output",
2461
+ "command": "<%= config.bin %> <%= command.id %> -f 887dda5583237210fdb8f7b6feaad32c -o '{\"current\":\"abc123\"}' --json --auth dev"
2462
+ }
2463
+ ],
2464
+ "flags": {
2465
+ "json": {
2466
+ "char": "j",
2467
+ "description": "Output results as JSON",
2468
+ "name": "json",
2469
+ "required": false,
2470
+ "allowNo": false,
2471
+ "type": "boolean"
2472
+ },
2473
+ "auth": {
2474
+ "char": "a",
2475
+ "description": "Auth alias to use.",
2476
+ "name": "auth",
2477
+ "required": false,
2478
+ "hasDynamicHelp": false,
2479
+ "multiple": false,
2480
+ "type": "option"
2481
+ },
2482
+ "log-level": {
2483
+ "helpGroup": "GLOBAL",
2484
+ "name": "log-level",
2485
+ "summary": "Specify level for logging.",
2486
+ "default": "info",
2487
+ "hasDynamicHelp": false,
2488
+ "multiple": false,
2489
+ "options": [
2490
+ "debug",
2491
+ "warn",
2492
+ "error",
2493
+ "info",
2494
+ "trace"
2495
+ ],
2496
+ "type": "option"
2497
+ },
2498
+ "flow-id": {
2499
+ "char": "f",
2500
+ "description": "Flow sys_id or scoped name (e.g. x_myapp.my_flow)",
2501
+ "name": "flow-id",
2502
+ "required": true,
2503
+ "hasDynamicHelp": false,
2504
+ "multiple": false,
2505
+ "type": "option"
2506
+ },
2507
+ "output-map": {
2508
+ "char": "o",
2509
+ "description": "JSON mapping of trigger output variable names to test values (e.g. '{\"current\":\"<sys_id>\",\"table_name\":\"change_request\"}')",
2510
+ "name": "output-map",
2511
+ "required": true,
2512
+ "hasDynamicHelp": false,
2513
+ "multiple": false,
2514
+ "type": "option"
2515
+ },
2516
+ "scope": {
2517
+ "description": "Scope sys_id for transaction scope (auto-resolved from flow definition if omitted)",
2518
+ "name": "scope",
2519
+ "required": false,
2520
+ "hasDynamicHelp": false,
2521
+ "multiple": false,
2522
+ "type": "option"
2523
+ },
2524
+ "synchronous": {
2525
+ "description": "Run test synchronously (default: true)",
2526
+ "name": "synchronous",
2527
+ "required": false,
2528
+ "allowNo": true,
2529
+ "type": "boolean"
2530
+ }
2531
+ },
2532
+ "hasDynamicHelp": false,
2533
+ "hiddenAliases": [],
2534
+ "id": "flow:test",
2535
+ "pluginAlias": "@sonisoft/now-sdk-ext-cli",
2536
+ "pluginName": "@sonisoft/now-sdk-ext-cli",
2537
+ "pluginType": "core",
2538
+ "strict": true,
2539
+ "enableJsonFlag": true,
2540
+ "isESM": true,
2541
+ "relativePath": [
2542
+ "dist",
2543
+ "commands",
2544
+ "flow",
2545
+ "test.js"
2546
+ ]
2547
+ },
2548
+ "exec": {
2549
+ "aliases": [],
2550
+ "args": {
2551
+ "scope": {
2552
+ "description": "Scope to execute script in. Use \"global\" for global scope.",
2553
+ "name": "scope",
2554
+ "required": true
2555
+ },
2556
+ "file": {
2557
+ "description": "File to execute in scripts background. If omitted, starts REPL mode.",
2558
+ "name": "file",
2559
+ "required": false
2560
+ }
2561
+ },
2562
+ "description": "Execute JavaScript on a ServiceNow instance remotely using Scripts - Background.\n\nThis command allows you to run JavaScript either from files or interactively via REPL mode. It mimics the functionality of the Scripts - Background interface in ServiceNow, providing a way to execute scripts programmatically without manual interaction. The output is returned in real-time and can be piped to other commands or saved to files.\n\nModes:\n • File Mode: Provide a file path to execute scripts from a file\n • REPL Mode: Omit the file path to start an interactive session\n\nFeatures:\n • Execute local JavaScript files remotely\n • Interactive REPL for ad-hoc script execution\n • Script parameterization with {placeholder} replacement\n • Multi-line script support in REPL\n • Scope-aware execution (global or custom scope)\n • Real-time console output capture\n • Pipe-able output for command chaining\n • Debug logging support\n • Useful for data migration, testing, and administrative tasks\n\nScript Parameterization:\n Use {paramName} placeholders in your script files, then provide values via --params:\n • Supports any JSON-serializable values (strings, numbers, booleans)\n • Multiple parameters supported\n • All occurrences of each placeholder are replaced\n • Example: {token}, {username}, {environment}\n\nREPL Controls:\n • Press Enter to add a new line\n • Type .exec or press Ctrl+D to execute the script\n • Type .clear to clear the current input\n • Type .exit or press Ctrl+C twice to exit REPL\n\n⚠️ IMPORTANT SECURITY WARNING:\nThis command executes scripts with the same permissions and risks as using Scripts - Background directly\nin ServiceNow. Always:\n • Review scripts before execution\n • Test in non-production environments first\n • Use appropriate scoping to limit access\n • Be aware of data modification risks\n • Follow your organization's security policies\n • Never execute untrusted scripts\n\nScript Capabilities:\n Scripts run with full GlideSystem API access and can:\n • Query and modify database records\n • Create, update, and delete data\n • Execute business rules and workflows\n • Access all APIs available in Scripts - Background\n • Use gs, GlideRecord, GlideAggregate, and other server-side APIs",
2563
+ "examples": [
2564
+ {
2565
+ "description": "Start REPL in global scope",
2566
+ "command": "<%= config.bin %> <%= command.id %> global --auth dev-instance"
2567
+ },
2568
+ {
2569
+ "description": "Start REPL in custom application scope",
2570
+ "command": "<%= config.bin %> <%= command.id %> x_my_custom_app --auth dev-instance"
2571
+ },
2572
+ {
2573
+ "description": "Execute a script file in global scope",
2574
+ "command": "<%= config.bin %> <%= command.id %> global ./scripts/cleanup.js --auth dev-instance"
2575
+ },
2576
+ {
2577
+ "description": "Execute a script file in a custom application scope",
2578
+ "command": "<%= config.bin %> <%= command.id %> x_my_custom_app ./scripts/app-config.js --auth dev-instance"
2579
+ },
2580
+ {
2581
+ "description": "Execute a parameterized script with single parameter",
2582
+ "command": "<%= config.bin %> <%= command.id %> global ./scripts/query-user.js --auth dev-instance --params '{\"username\":\"admin\"}'"
2583
+ },
2584
+ {
2585
+ "description": "Execute a parameterized script with multiple parameters",
2586
+ "command": "<%= config.bin %> <%= command.id %> global ./scripts/update-record.js --auth dev-instance --params '{\"table\":\"incident\",\"field\":\"priority\",\"value\":\"1\"}'"
2587
+ },
2588
+ {
2589
+ "description": "Execute and save output to a file",
2590
+ "command": "<%= config.bin %> <%= command.id %> global ./scripts/report.js --auth dev-instance > report.txt"
2591
+ },
2592
+ {
2593
+ "description": "Execute and pipe output to grep for filtering",
2594
+ "command": "<%= config.bin %> <%= command.id %> global ./scripts/list-users.js --auth dev-instance | grep \"admin\""
2595
+ },
2596
+ {
2597
+ "description": "Execute with debug logging to troubleshoot issues",
2598
+ "command": "<%= config.bin %> <%= command.id %> global ./script.js --auth dev-instance --log-level debug"
2599
+ },
2600
+ {
2601
+ "description": "Execute with parameters for template replacement",
2602
+ "command": "<%= config.bin %> <%= command.id %> global ./script.js --auth dev-instance --params '{\"token\":\"abc123\",\"env\":\"dev\"}'"
2603
+ }
2604
+ ],
2605
+ "flags": {
2606
+ "json": {
2607
+ "description": "Format output as json.",
2608
+ "helpGroup": "GLOBAL",
2609
+ "name": "json",
2610
+ "allowNo": false,
2611
+ "type": "boolean"
2612
+ },
2613
+ "auth": {
2614
+ "char": "a",
2615
+ "description": "Auth alias to use.",
2616
+ "name": "auth",
2617
+ "required": false,
2618
+ "hasDynamicHelp": false,
2619
+ "multiple": false,
2620
+ "type": "option"
2621
+ },
2622
+ "log-level": {
2623
+ "helpGroup": "GLOBAL",
2624
+ "name": "log-level",
2625
+ "summary": "Specify level for logging.",
2626
+ "default": "info",
2627
+ "hasDynamicHelp": false,
2628
+ "multiple": false,
2629
+ "options": [
2630
+ "debug",
2631
+ "warn",
2632
+ "error",
2633
+ "info",
2634
+ "trace"
2635
+ ],
2636
+ "type": "option"
2637
+ },
2638
+ "params": {
2639
+ "char": "p",
2640
+ "description": "JSON object of parameters to replace in script file. Use {paramName} syntax in your script.",
2641
+ "name": "params",
2642
+ "required": false,
2643
+ "hasDynamicHelp": false,
2644
+ "multiple": false,
2645
+ "type": "option"
2646
+ }
2647
+ },
2648
+ "hasDynamicHelp": false,
2649
+ "hiddenAliases": [],
2650
+ "id": "exec",
2651
+ "pluginAlias": "@sonisoft/now-sdk-ext-cli",
2652
+ "pluginName": "@sonisoft/now-sdk-ext-cli",
2653
+ "pluginType": "core",
2654
+ "strict": true,
2655
+ "enableJsonFlag": true,
2656
+ "autocomplete": {},
2657
+ "isESM": true,
2658
+ "relativePath": [
2659
+ "dist",
2660
+ "commands",
2661
+ "exec",
2662
+ "index.js"
2663
+ ]
2664
+ },
2563
2665
  "health:check": {
2564
2666
  "aliases": [],
2565
2667
  "args": {},
@@ -6024,5 +6126,5 @@
6024
6126
  ]
6025
6127
  }
6026
6128
  },
6027
- "version": "2.0.1"
6129
+ "version": "2.1.0"
6028
6130
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sonisoft/now-sdk-ext-cli",
3
3
  "description": "A CLI extending the functionality of the ServiceNow SDK.",
4
- "version": "2.0.1",
4
+ "version": "2.1.0",
5
5
  "author": "Chris Nanda",
6
6
  "bin": {
7
7
  "nex": "./bin/run.js"
@@ -17,7 +17,7 @@
17
17
  "@servicenow/sdk-cli": "4.3.0",
18
18
  "@servicenow/sdk-cli-core": "3.0.3",
19
19
  "@servicenow/sdk-core": "4.3.0",
20
- "@sonisoft/now-sdk-ext-core": "^3.4.0",
20
+ "@sonisoft/now-sdk-ext-core": "^3.6.0",
21
21
  "@ts-morph/common": "^0.24.0",
22
22
  "chalk": "^4.1.2",
23
23
  "cometd": "^8.0.4",