@sonisoft/now-sdk-ext-core 2.4.0 β†’ 2.5.2

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 (43) hide show
  1. package/README.md +96 -27
  2. package/dist/index.d.ts +10 -0
  3. package/dist/index.js +10 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/sn/aggregate/AggregateModels.d.ts +89 -0
  6. package/dist/sn/aggregate/AggregateModels.js +5 -0
  7. package/dist/sn/aggregate/AggregateModels.js.map +1 -0
  8. package/dist/sn/aggregate/AggregateQuery.d.ts +50 -0
  9. package/dist/sn/aggregate/AggregateQuery.js +144 -0
  10. package/dist/sn/aggregate/AggregateQuery.js.map +1 -0
  11. package/dist/sn/batch/QueryBatchModels.d.ts +93 -0
  12. package/dist/sn/batch/QueryBatchModels.js +5 -0
  13. package/dist/sn/batch/QueryBatchModels.js.map +1 -0
  14. package/dist/sn/batch/QueryBatchOperations.d.ts +41 -0
  15. package/dist/sn/batch/QueryBatchOperations.js +195 -0
  16. package/dist/sn/batch/QueryBatchOperations.js.map +1 -0
  17. package/dist/sn/cmdb/CMDBModels.d.ts +141 -0
  18. package/dist/sn/cmdb/CMDBModels.js +5 -0
  19. package/dist/sn/cmdb/CMDBModels.js.map +1 -0
  20. package/dist/sn/cmdb/CMDBRelationships.d.ts +60 -0
  21. package/dist/sn/cmdb/CMDBRelationships.js +286 -0
  22. package/dist/sn/cmdb/CMDBRelationships.js.map +1 -0
  23. package/dist/sn/discovery/DiscoveryModels.d.ts +160 -0
  24. package/dist/sn/discovery/DiscoveryModels.js +5 -0
  25. package/dist/sn/discovery/DiscoveryModels.js.map +1 -0
  26. package/dist/sn/discovery/InstanceDiscovery.d.ts +45 -0
  27. package/dist/sn/discovery/InstanceDiscovery.js +163 -0
  28. package/dist/sn/discovery/InstanceDiscovery.js.map +1 -0
  29. package/dist/sn/health/HealthModels.d.ts +124 -0
  30. package/dist/sn/health/HealthModels.js +5 -0
  31. package/dist/sn/health/HealthModels.js.map +1 -0
  32. package/dist/sn/health/InstanceHealth.d.ts +58 -0
  33. package/dist/sn/health/InstanceHealth.js +221 -0
  34. package/dist/sn/health/InstanceHealth.js.map +1 -0
  35. package/dist/sn/scope/ScopeManager.d.ts +7 -7
  36. package/dist/sn/scope/ScopeManager.js +19 -14
  37. package/dist/sn/scope/ScopeManager.js.map +1 -1
  38. package/dist/sn/scope/ScopeModels.d.ts +9 -3
  39. package/dist/sn/updateset/UpdateSetManager.d.ts +3 -3
  40. package/dist/sn/updateset/UpdateSetManager.js +12 -7
  41. package/dist/sn/updateset/UpdateSetManager.js.map +1 -1
  42. package/dist/sn/updateset/UpdateSetModels.d.ts +11 -0
  43. package/package.json +2 -2
package/README.md CHANGED
@@ -2,17 +2,31 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@sonisoft/now-sdk-ext-core.svg)](https://www.npmjs.com/package/@sonisoft/now-sdk-ext-core)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
- [![Node.js Version](https://img.shields.io/badge/node-%3E%3D14.0.0-brightgreen)](https://nodejs.org)
5
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org)
6
6
 
7
7
  A comprehensive TypeScript library that extends the ServiceNow SDK with powerful features for application management, automated testing, log monitoring, and more. Perfect for CI/CD pipelines, development automation, and DevOps workflows.
8
8
 
9
9
  ## ✨ Features
10
10
 
11
11
  - πŸš€ **Application Management** - Install, upgrade, and manage ServiceNow applications programmatically
12
+ - πŸͺ **Store Application Management** - Search, install, and update apps from the ServiceNow Store
12
13
  - πŸ§ͺ **ATF Test Execution** - Run automated tests and get detailed results
13
14
  - πŸ“Š **Real-time Log Monitoring** - Tail ServiceNow logs with two efficient methods
14
15
  - πŸ”„ **AMB (Asynchronous Message Bus)** - WebSocket-based real-time event monitoring
15
16
  - πŸ“ **Background Script Execution** - Execute server-side scripts programmatically
17
+ - πŸ“‹ **Scope Management** - Set/get current application scope programmatically
18
+ - πŸ“¦ **Update Set Management** - Create, clone, inspect, and manage update sets
19
+ - πŸ” **Code Search** - Search across platform code, apps, and tables
20
+ - πŸ—„οΈ **Schema Discovery** - Discover table schemas, explain fields, validate catalogs
21
+ - πŸ“Ž **Attachment Management** - Upload, list, and retrieve file attachments
22
+ - ⚑ **Batch Operations** - Bulk create/update with variable substitution and query-based bulk operations
23
+ - πŸ”§ **Workflow Management** - Create complete workflows programmatically
24
+ - πŸ“Œ **Task Operations** - Add comments, assign tasks, resolve/close incidents
25
+ - πŸ”— **Script Sync** - Bidirectional sync of scripts between local files and instance
26
+ - πŸ“ˆ **Aggregate Queries** - COUNT, AVG, MIN, MAX, SUM with GROUP BY via Stats API
27
+ - πŸ₯ **Instance Health** - Version, cluster, stuck jobs, semaphore monitoring
28
+ - πŸ—ΊοΈ **CMDB Relationships** - Query and traverse CI relationship graphs
29
+ - πŸ”Ž **Instance Discovery** - List tables, scoped apps, store apps, and plugins
16
30
  - πŸ” **Authentication** - Seamless integration with ServiceNow CLI authentication
17
31
  - πŸ“‘ **Table API** - Full CRUD operations on ServiceNow tables
18
32
  - πŸ› οΈ **Type-Safe** - Complete TypeScript definitions for all APIs
@@ -25,9 +39,9 @@ npm install @sonisoft/now-sdk-ext-core
25
39
 
26
40
  ### Prerequisites
27
41
 
28
- - Node.js 14.x or higher
42
+ - Node.js 18.x or higher
29
43
  - ServiceNow CLI configured with instance credentials
30
- - TypeScript 4.x or higher (optional, for TypeScript projects)
44
+ - TypeScript 5.x or higher (optional, for TypeScript projects)
31
45
 
32
46
  ### ServiceNow CLI Setup
33
47
 
@@ -359,29 +373,60 @@ console.log('Return value:', result.result);
359
373
 
360
374
  - **`ServiceNowInstance`** - Instance connection and configuration
361
375
  - **`ServiceNowRequest`** - HTTP request handling with authentication
362
- - **`TableAPIRequest`** - ServiceNow Table API wrapper
376
+ - **`TableAPIRequest`** - ServiceNow Table API wrapper (CRUD)
363
377
 
364
378
  ### Application Management
365
379
 
366
- - **`ApplicationManager`** - High-level application management
380
+ - **`ApplicationManager`** - Install, upgrade, and validate applications via batch definitions
367
381
  - **`AppRepoApplication`** - App repository operations
368
- - **`BatchDefinition`** - Batch installation definitions
369
- - **`CompanyApplications`** - Company application queries
382
+ - **`CompanyApplications`** - Store application search, install, update, and progress tracking
383
+
384
+ ### Scope & Configuration
385
+
386
+ - **`ScopeManager`** - Set/get current application scope, list and retrieve applications
387
+ - **`UpdateSetManager`** - Create, clone, inspect, move records, and manage update sets
370
388
 
371
389
  ### Testing & Automation
372
390
 
373
- - **`ATFTestExecutor`** - ATF test execution and monitoring
374
- - **`BackgroundScriptExecutor`** - Server-side script execution
391
+ - **`ATFTestExecutor`** - ATF test execution and monitoring with progress tracking
392
+ - **`BackgroundScriptExecutor`** - Server-side GlideScript execution
393
+
394
+ ### Code & Schema
395
+
396
+ - **`CodeSearch`** - Search across platform code by term, app, or table
397
+ - **`SchemaDiscovery`** - Discover table schemas, explain fields, validate catalog items
398
+
399
+ ### Data Operations
400
+
401
+ - **`AttachmentManager`** - Upload, list, and retrieve file attachments
402
+ - **`BatchOperations`** - Sequential bulk create/update with variable substitution
403
+ - **`QueryBatchOperations`** - Query-based bulk update/delete with dry-run safety
404
+
405
+ ### Workflow & Task
406
+
407
+ - **`WorkflowManager`** - Create complete workflows with activities, transitions, and conditions
408
+ - **`TaskOperations`** - Add comments, assign tasks, resolve/close incidents, approve changes
409
+
410
+ ### Scripting
411
+
412
+ - **`ScriptSync`** - Bidirectional sync of Script Includes, Business Rules, and more
375
413
 
376
- ### Logging & Monitoring
414
+ ### Monitoring & Discovery
377
415
 
378
- - **`SyslogReader`** - Log querying and real-time monitoring
379
- - **`AMBClient`** - Real-time event subscriptions
416
+ - **`AggregateQuery`** - COUNT, AVG, MIN, MAX, SUM with GROUP BY via Stats API
417
+ - **`InstanceHealth`** - Version, cluster nodes, stuck jobs, semaphores, operational counts
418
+ - **`CMDBRelationships`** - Query direct relationships and traverse CI graphs (BFS)
419
+ - **`InstanceDiscovery`** - List tables, scoped apps, store apps, and plugins
420
+
421
+ ### Logging & Real-time Events
422
+
423
+ - **`SyslogReader`** - Log querying, formatting, export, and real-time tailing
424
+ - **`AMBClient`** - WebSocket-based real-time event subscriptions
380
425
  - **`MessageClientBuilder`** - AMB client configuration
381
426
 
382
427
  ### Utilities
383
428
 
384
- - **`Logger`** - Winston-based logging
429
+ - **`Logger`** - Winston-based logging with file output
385
430
  - **`NowStringUtil`** - String manipulation utilities
386
431
  - **`AppUtil`** - Application utility functions
387
432
 
@@ -460,14 +505,41 @@ node docs/examples/syslog-tail.mjs your-instance error ./logs/errors.log
460
505
 
461
506
  Comprehensive documentation is available in the `/docs` directory:
462
507
 
508
+ **Getting Started:**
463
509
  - **[Getting Started](./docs/GettingStarted.md)** - Setup and basic usage
464
510
  - **[API Reference](./docs/APIReference.md)** - Complete API documentation
511
+ - **[Examples](./docs/examples/)** - Working code examples
512
+
513
+ **Application & Scope Management:**
465
514
  - **[Application Manager](./docs/ApplicationManager.md)** - Application management guide
515
+ - **[Store Applications](./docs/CompanyApplications.md)** - Store app search, install, and update
516
+ - **[Scope Manager](./docs/ScopeManager.md)** - Application scope management
517
+ - **[Update Set Manager](./docs/UpdateSetManager.md)** - Update set lifecycle management
518
+
519
+ **Code, Schema & Search:**
520
+ - **[Code Search](./docs/CodeSearch.md)** - Platform code search
521
+ - **[Schema Discovery](./docs/SchemaDiscovery.md)** - Table schema and field discovery
522
+
523
+ **Data Operations:**
524
+ - **[Attachment Manager](./docs/AttachmentManager.md)** - File attachment operations
525
+ - **[Batch Operations](./docs/BatchOperations.md)** - Bulk create/update with variable substitution
526
+ - **[Query Batch Operations](./docs/QueryBatchOperations.md)** - Query-based bulk update/delete
527
+
528
+ **Workflow, Task & Scripting:**
529
+ - **[Workflow Manager](./docs/WorkflowManager.md)** - Programmatic workflow creation
530
+ - **[Task Operations](./docs/TaskOperations.md)** - ITSM task management
531
+ - **[Script Sync](./docs/ScriptSync.md)** - Bidirectional script synchronization
532
+
533
+ **Monitoring & Discovery:**
534
+ - **[Aggregate Query](./docs/AggregateQuery.md)** - Stats API aggregations
535
+ - **[Instance Health](./docs/InstanceHealth.md)** - Health monitoring
536
+ - **[CMDB Relationships](./docs/CMDBRelationships.md)** - CI relationship graph traversal
537
+ - **[Instance Discovery](./docs/InstanceDiscovery.md)** - Table, app, and plugin discovery
538
+
539
+ **Testing & Logging:**
466
540
  - **[ATF Test Executor](./docs/ATFTestExecutor.md)** - Testing automation
467
541
  - **[Syslog Reader](./docs/SyslogReader.md)** - Log monitoring guide
468
542
  - **[ChannelAjax Tailing](./docs/SyslogReaderChannelAjax.md)** - Advanced log tailing
469
- - **[AMB Guide](./docs/AMB_FIX_SUMMARY.md)** - Real-time event monitoring
470
- - **[Examples](./docs/examples/)** - Working code examples
471
543
 
472
544
  ## πŸ”§ Advanced Configuration
473
545
 
@@ -559,12 +631,14 @@ try {
559
631
 
560
632
  ## πŸ“¦ Dependencies
561
633
 
562
- - `@servicenow/sdk` - ServiceNow SDK
563
- - `@servicenow/sdk-cli` - ServiceNow CLI tools
564
- - `cometd` - WebSocket support for AMB
565
- - `xml2js` - XML parsing
566
- - `winston` - Logging
634
+ - `@servicenow/sdk` / `@servicenow/sdk-cli` / `@servicenow/sdk-core` - ServiceNow SDK and CLI tools
567
635
  - `axios` - HTTP client
636
+ - `cometd` / `cometd-nodejs-client` - WebSocket support for AMB
637
+ - `winston` - Logging
638
+ - `xml2js` / `fast-xml-parser` - XML parsing
639
+ - `ws` - WebSocket client
640
+ - `zod` - Runtime schema validation
641
+ - `lodash` - Utility functions
568
642
 
569
643
  ## πŸ§ͺ Testing
570
644
 
@@ -623,15 +697,10 @@ For issues, questions, or contributions:
623
697
 
624
698
  - [ ] GraphQL API support
625
699
  - [ ] Webhook integration
626
- - [ ] Enhanced batch operations
627
- - [ ] Performance metrics
628
- - [ ] CLI tool package
700
+ - [ ] Performance metrics dashboard
701
+ - [ ] Standalone CLI tool package
629
702
  - [ ] Plugin development tools
630
703
 
631
- ## πŸ“ˆ Version History
632
-
633
- See [CHANGELOG](./CHANGELOG.md) for version history and release notes.
634
-
635
704
  ---
636
705
 
637
706
  **Made with ❀️ for the ServiceNow Developer Community**
package/dist/index.d.ts CHANGED
@@ -29,6 +29,8 @@ export * from './comm/http/ServiceNowProcessorRequest.js';
29
29
  export * from './comm/http/ServiceNowRequest.js';
30
30
  export * from './comm/http/TableAPIRequest.js';
31
31
  export * from './comm/ws/ATFMessageHandler.js';
32
+ export * from './sn/aggregate/AggregateModels.js';
33
+ export * from './sn/aggregate/AggregateQuery.js';
32
34
  export * from './sn/amb/AuthenticatedWebSocket.js';
33
35
  export * from './sn/application/ApplicationDetailModel.js';
34
36
  export * from './sn/application/ApplicationManager.js';
@@ -44,8 +46,16 @@ export * from './sn/attachment/AttachmentManager.js';
44
46
  export * from './sn/attachment/AttachmentModels.js';
45
47
  export * from './sn/batch/BatchModels.js';
46
48
  export * from './sn/batch/BatchOperations.js';
49
+ export * from './sn/batch/QueryBatchModels.js';
50
+ export * from './sn/batch/QueryBatchOperations.js';
51
+ export * from './sn/cmdb/CMDBModels.js';
52
+ export * from './sn/cmdb/CMDBRelationships.js';
47
53
  export * from './sn/codesearch/CodeSearch.js';
48
54
  export * from './sn/codesearch/CodeSearchModels.js';
55
+ export * from './sn/discovery/DiscoveryModels.js';
56
+ export * from './sn/discovery/InstanceDiscovery.js';
57
+ export * from './sn/health/HealthModels.js';
58
+ export * from './sn/health/InstanceHealth.js';
49
59
  export * from './sn/schema/SchemaDiscovery.js';
50
60
  export * from './sn/schema/SchemaModels.js';
51
61
  export * from './sn/scope/ScopeManager.js';
package/dist/index.js CHANGED
@@ -29,6 +29,8 @@ export * from './comm/http/ServiceNowProcessorRequest.js';
29
29
  export * from './comm/http/ServiceNowRequest.js';
30
30
  export * from './comm/http/TableAPIRequest.js';
31
31
  export * from './comm/ws/ATFMessageHandler.js';
32
+ export * from './sn/aggregate/AggregateModels.js';
33
+ export * from './sn/aggregate/AggregateQuery.js';
32
34
  export * from './sn/amb/AuthenticatedWebSocket.js';
33
35
  export * from './sn/application/ApplicationDetailModel.js';
34
36
  export * from './sn/application/ApplicationManager.js';
@@ -44,8 +46,16 @@ export * from './sn/attachment/AttachmentManager.js';
44
46
  export * from './sn/attachment/AttachmentModels.js';
45
47
  export * from './sn/batch/BatchModels.js';
46
48
  export * from './sn/batch/BatchOperations.js';
49
+ export * from './sn/batch/QueryBatchModels.js';
50
+ export * from './sn/batch/QueryBatchOperations.js';
51
+ export * from './sn/cmdb/CMDBModels.js';
52
+ export * from './sn/cmdb/CMDBRelationships.js';
47
53
  export * from './sn/codesearch/CodeSearch.js';
48
54
  export * from './sn/codesearch/CodeSearchModels.js';
55
+ export * from './sn/discovery/DiscoveryModels.js';
56
+ export * from './sn/discovery/InstanceDiscovery.js';
57
+ export * from './sn/health/HealthModels.js';
58
+ export * from './sn/health/InstanceHealth.js';
49
59
  export * from './sn/schema/SchemaDiscovery.js';
50
60
  export * from './sn/schema/SchemaModels.js';
51
61
  export * from './sn/scope/ScopeManager.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0CAA0C,CAAC;AACzD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,u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uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Options for an aggregate query against a ServiceNow table.
3
+ */
4
+ export interface AggregateQueryOptions {
5
+ /** The table name to aggregate (required) */
6
+ table: string;
7
+ /** Encoded query to filter records before aggregation */
8
+ query?: string;
9
+ /** When true, includes record count in the result */
10
+ count?: boolean;
11
+ /** Field names to compute AVG on */
12
+ avgFields?: string[];
13
+ /** Field names to compute MIN on */
14
+ minFields?: string[];
15
+ /** Field names to compute MAX on */
16
+ maxFields?: string[];
17
+ /** Field names to compute SUM on */
18
+ sumFields?: string[];
19
+ /** Field names to GROUP BY */
20
+ groupBy?: string[];
21
+ /** HAVING clause for group filtering */
22
+ having?: string;
23
+ /** Display value handling: "true", "false", or "all" */
24
+ displayValue?: "true" | "false" | "all";
25
+ }
26
+ /**
27
+ * Convenience options for a simple count query.
28
+ */
29
+ export interface CountQueryOptions {
30
+ /** The table name to count records from (required) */
31
+ table: string;
32
+ /** Encoded query to filter records */
33
+ query?: string;
34
+ }
35
+ /**
36
+ * Statistics block returned in the aggregate response.
37
+ * Keys follow ServiceNow naming: count, avg.{field}, min.{field}, max.{field}, sum.{field}
38
+ */
39
+ export interface AggregateStats {
40
+ /** Record count (when count was requested) */
41
+ count?: string;
42
+ /** Additional stat fields keyed by "avg.{field}", "min.{field}", etc. */
43
+ [key: string]: unknown;
44
+ }
45
+ /**
46
+ * A single group in a grouped aggregate result.
47
+ */
48
+ export interface AggregateGroupResult {
49
+ /** The group-by field values */
50
+ groupby_fields: Array<{
51
+ field: string;
52
+ value: string;
53
+ display_value?: string;
54
+ }>;
55
+ /** The stats for this group */
56
+ stats: AggregateStats;
57
+ /** Additional fields */
58
+ [key: string]: unknown;
59
+ }
60
+ /**
61
+ * Result of an aggregate query (non-grouped).
62
+ */
63
+ export interface AggregateResult {
64
+ /** The stats for the entire result set */
65
+ stats: AggregateStats;
66
+ }
67
+ /**
68
+ * Result of a grouped aggregate query.
69
+ */
70
+ export interface GroupedAggregateResult {
71
+ /** Array of group results */
72
+ groups: AggregateGroupResult[];
73
+ }
74
+ /**
75
+ * Response wrapper for non-grouped aggregate queries.
76
+ * The API returns { result: { stats: { count: "123", ... } } }
77
+ */
78
+ export interface AggregateResponse {
79
+ result: {
80
+ stats: AggregateStats;
81
+ };
82
+ }
83
+ /**
84
+ * Response wrapper for grouped aggregate queries.
85
+ * The API returns { result: [ { groupby_fields: [...], stats: {...} }, ... ] }
86
+ */
87
+ export interface GroupedAggregateResponse {
88
+ result: AggregateGroupResult[];
89
+ }
@@ -0,0 +1,5 @@
1
+ // ============================================================
2
+ // Options Types
3
+ // ============================================================
4
+ export {};
5
+ //# sourceMappingURL=AggregateModels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AggregateModels.js","sourceRoot":"","sources":["../../../src/sn/aggregate/AggregateModels.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,gBAAgB;AAChB,+DAA+D"}
@@ -0,0 +1,50 @@
1
+ import { ServiceNowInstance } from "../ServiceNowInstance.js";
2
+ import { AggregateQueryOptions, CountQueryOptions, AggregateResult, GroupedAggregateResult } from './AggregateModels.js';
3
+ /**
4
+ * AggregateQuery provides aggregate operations (COUNT, AVG, MIN, MAX, SUM)
5
+ * against ServiceNow tables via the Stats API (/api/now/stats/).
6
+ * Supports GROUP BY for grouped aggregations.
7
+ */
8
+ export declare class AggregateQuery {
9
+ private static readonly STATS_API_BASE;
10
+ private _logger;
11
+ private _req;
12
+ private _instance;
13
+ private _headers;
14
+ constructor(instance: ServiceNowInstance);
15
+ /**
16
+ * Count records matching an optional query on a table.
17
+ * Convenience method that returns a parsed integer.
18
+ *
19
+ * @param options Count query options (table required, query optional)
20
+ * @returns The number of matching records
21
+ * @throws Error if table name is empty or the API call fails
22
+ */
23
+ count(options: CountQueryOptions): Promise<number>;
24
+ /**
25
+ * Run an aggregate query (COUNT, AVG, MIN, MAX, SUM) without grouping.
26
+ *
27
+ * @param options Aggregate query options
28
+ * @returns AggregateResult containing the computed statistics
29
+ * @throws Error if table name is empty or the API call fails
30
+ */
31
+ aggregate(options: AggregateQueryOptions): Promise<AggregateResult>;
32
+ /**
33
+ * Run a grouped aggregate query with GROUP BY.
34
+ *
35
+ * @param options Aggregate query options (groupBy is required)
36
+ * @returns GroupedAggregateResult with groups and their stats
37
+ * @throws Error if table name is empty, groupBy is missing/empty, or the API call fails
38
+ */
39
+ groupBy(options: AggregateQueryOptions): Promise<GroupedAggregateResult>;
40
+ /**
41
+ * Build query parameters from aggregate options.
42
+ * @private
43
+ */
44
+ private _buildQueryParams;
45
+ /**
46
+ * Execute a GET request against the Stats API.
47
+ * @private
48
+ */
49
+ private _executeStatsRequest;
50
+ }
@@ -0,0 +1,144 @@
1
+ import { Logger } from "../../util/Logger.js";
2
+ import { ServiceNowRequest } from "../../comm/http/ServiceNowRequest.js";
3
+ /**
4
+ * AggregateQuery provides aggregate operations (COUNT, AVG, MIN, MAX, SUM)
5
+ * against ServiceNow tables via the Stats API (/api/now/stats/).
6
+ * Supports GROUP BY for grouped aggregations.
7
+ */
8
+ export class AggregateQuery {
9
+ static STATS_API_BASE = '/api/now/stats/';
10
+ _logger = new Logger("AggregateQuery");
11
+ _req;
12
+ _instance;
13
+ _headers = {
14
+ "Content-Type": "application/json",
15
+ "Accept": "application/json"
16
+ };
17
+ constructor(instance) {
18
+ this._instance = instance;
19
+ this._req = new ServiceNowRequest(instance);
20
+ }
21
+ /**
22
+ * Count records matching an optional query on a table.
23
+ * Convenience method that returns a parsed integer.
24
+ *
25
+ * @param options Count query options (table required, query optional)
26
+ * @returns The number of matching records
27
+ * @throws Error if table name is empty or the API call fails
28
+ */
29
+ async count(options) {
30
+ if (!options.table || options.table.trim().length === 0) {
31
+ throw new Error('Table name is required');
32
+ }
33
+ this._logger.info(`Counting records in table: ${options.table}${options.query ? ` with query: ${options.query}` : ''}`);
34
+ const queryParams = {
35
+ sysparm_count: 'true'
36
+ };
37
+ if (options.query) {
38
+ queryParams.sysparm_query = options.query;
39
+ }
40
+ const response = await this._executeStatsRequest(options.table, queryParams);
41
+ if (response && response.status === 200 && response.bodyObject?.result?.stats) {
42
+ const count = parseInt(response.bodyObject.result.stats.count || '0', 10);
43
+ this._logger.info(`Count result for ${options.table}: ${count}`);
44
+ return count;
45
+ }
46
+ throw new Error(`Failed to count records in table '${options.table}'. Status: ${response?.status ?? 'unknown'}`);
47
+ }
48
+ /**
49
+ * Run an aggregate query (COUNT, AVG, MIN, MAX, SUM) without grouping.
50
+ *
51
+ * @param options Aggregate query options
52
+ * @returns AggregateResult containing the computed statistics
53
+ * @throws Error if table name is empty or the API call fails
54
+ */
55
+ async aggregate(options) {
56
+ if (!options.table || options.table.trim().length === 0) {
57
+ throw new Error('Table name is required');
58
+ }
59
+ this._logger.info(`Running aggregate query on table: ${options.table}`);
60
+ const queryParams = this._buildQueryParams(options);
61
+ const response = await this._executeStatsRequest(options.table, queryParams);
62
+ if (response && response.status === 200 && response.bodyObject?.result?.stats) {
63
+ this._logger.info(`Aggregate query complete for ${options.table}`);
64
+ return { stats: response.bodyObject.result.stats };
65
+ }
66
+ throw new Error(`Failed to run aggregate query on table '${options.table}'. Status: ${response?.status ?? 'unknown'}`);
67
+ }
68
+ /**
69
+ * Run a grouped aggregate query with GROUP BY.
70
+ *
71
+ * @param options Aggregate query options (groupBy is required)
72
+ * @returns GroupedAggregateResult with groups and their stats
73
+ * @throws Error if table name is empty, groupBy is missing/empty, or the API call fails
74
+ */
75
+ async groupBy(options) {
76
+ if (!options.table || options.table.trim().length === 0) {
77
+ throw new Error('Table name is required');
78
+ }
79
+ if (!options.groupBy || options.groupBy.length === 0) {
80
+ throw new Error('groupBy fields are required for grouped aggregation');
81
+ }
82
+ this._logger.info(`Running grouped aggregate on table: ${options.table}, groupBy: ${options.groupBy.join(',')}`);
83
+ const queryParams = this._buildQueryParams(options);
84
+ const response = await this._executeStatsRequest(options.table, queryParams);
85
+ if (response && response.status === 200 && response.bodyObject?.result) {
86
+ const groups = Array.isArray(response.bodyObject.result)
87
+ ? response.bodyObject.result
88
+ : [];
89
+ this._logger.info(`Grouped aggregate complete for ${options.table}: ${groups.length} groups`);
90
+ return { groups };
91
+ }
92
+ throw new Error(`Failed to run grouped aggregate on table '${options.table}'. Status: ${response?.status ?? 'unknown'}`);
93
+ }
94
+ /**
95
+ * Build query parameters from aggregate options.
96
+ * @private
97
+ */
98
+ _buildQueryParams(options) {
99
+ const params = {};
100
+ if (options.count) {
101
+ params.sysparm_count = 'true';
102
+ }
103
+ if (options.avgFields && options.avgFields.length > 0) {
104
+ params.sysparm_avg_fields = options.avgFields.join(',');
105
+ }
106
+ if (options.minFields && options.minFields.length > 0) {
107
+ params.sysparm_min_fields = options.minFields.join(',');
108
+ }
109
+ if (options.maxFields && options.maxFields.length > 0) {
110
+ params.sysparm_max_fields = options.maxFields.join(',');
111
+ }
112
+ if (options.sumFields && options.sumFields.length > 0) {
113
+ params.sysparm_sum_fields = options.sumFields.join(',');
114
+ }
115
+ if (options.groupBy && options.groupBy.length > 0) {
116
+ params.sysparm_group_by = options.groupBy.join(',');
117
+ }
118
+ if (options.query) {
119
+ params.sysparm_query = options.query;
120
+ }
121
+ if (options.having) {
122
+ params.sysparm_having = options.having;
123
+ }
124
+ if (options.displayValue) {
125
+ params.sysparm_display_value = options.displayValue;
126
+ }
127
+ return params;
128
+ }
129
+ /**
130
+ * Execute a GET request against the Stats API.
131
+ * @private
132
+ */
133
+ async _executeStatsRequest(tableName, queryParams) {
134
+ const request = {
135
+ path: AggregateQuery.STATS_API_BASE + tableName,
136
+ method: 'get',
137
+ headers: this._headers,
138
+ query: queryParams,
139
+ body: null
140
+ };
141
+ return await this._req.executeRequest(request);
142
+ }
143
+ }
144
+ //# sourceMappingURL=AggregateQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AggregateQuery.js","sourceRoot":"","sources":["../../../src/sn/aggregate/AggregateQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAYtE;;;;GAIG;AACH,MAAM,OAAO,cAAc;IACf,MAAM,CAAU,cAAc,GAAG,iBAAiB,CAAC;IAEnD,OAAO,GAAW,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC/C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GAAG,OAAO,CAAC,MAAM,CAAC;QAC3C,CAAC;QAED,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,CAAC,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC;QACxD,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,oBAAoB,CAAI,SAAiB,EAAE,WAAmC;QACxF,MAAM,OAAO,GAAgB;YACzB,IAAI,EAAE,cAAc,CAAC,cAAc,GAAG,SAAS;YAC/C,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,IAAI;SACb,CAAC;QAEF,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAI,OAAO,CAAC,CAAC;IACtD,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Options for a query-based batch update operation.
3
+ */
4
+ export interface QueryUpdateOptions {
5
+ /** The table to update records in (required) */
6
+ table: string;
7
+ /** Encoded query to find matching records (required) */
8
+ query: string;
9
+ /** The field data to apply to all matching records (required) */
10
+ data: Record<string, unknown>;
11
+ /**
12
+ * When true, actually executes the update.
13
+ * When false (default), performs a dry run and returns match count only.
14
+ */
15
+ confirm?: boolean;
16
+ /**
17
+ * Maximum number of records to update.
18
+ * Defaults to 200. Maximum allowed: 10000.
19
+ */
20
+ limit?: number;
21
+ /** Optional progress callback invoked periodically */
22
+ onProgress?: (message: string) => void;
23
+ }
24
+ /**
25
+ * Options for a query-based batch delete operation.
26
+ */
27
+ export interface QueryDeleteOptions {
28
+ /** The table to delete records from (required) */
29
+ table: string;
30
+ /** Encoded query to find matching records (required) */
31
+ query: string;
32
+ /**
33
+ * When true, actually executes the delete.
34
+ * When false (default), performs a dry run and returns match count only.
35
+ */
36
+ confirm?: boolean;
37
+ /**
38
+ * Maximum number of records to delete.
39
+ * Defaults to 200. Maximum allowed: 10000.
40
+ */
41
+ limit?: number;
42
+ /** Optional progress callback invoked periodically */
43
+ onProgress?: (message: string) => void;
44
+ }
45
+ /**
46
+ * Result of a query-based batch update operation.
47
+ */
48
+ export interface QueryUpdateResult {
49
+ /** Whether this was a dry run or live execution */
50
+ dryRun: boolean;
51
+ /** Number of records that matched the query */
52
+ matchCount: number;
53
+ /** Number of records successfully updated (0 if dry run) */
54
+ updatedCount: number;
55
+ /** True if all matched records were updated without error (or if dry run) */
56
+ success: boolean;
57
+ /** Details of any errors encountered during execution */
58
+ errors: Array<{
59
+ sysId: string;
60
+ error: string;
61
+ }>;
62
+ /** Total execution time in milliseconds */
63
+ executionTimeMs: number;
64
+ }
65
+ /**
66
+ * Result of a query-based batch delete operation.
67
+ */
68
+ export interface QueryDeleteResult {
69
+ /** Whether this was a dry run or live execution */
70
+ dryRun: boolean;
71
+ /** Number of records that matched the query */
72
+ matchCount: number;
73
+ /** Number of records successfully deleted (0 if dry run) */
74
+ deletedCount: number;
75
+ /** True if all matched records were deleted without error (or if dry run) */
76
+ success: boolean;
77
+ /** Details of any errors encountered during execution */
78
+ errors: Array<{
79
+ sysId: string;
80
+ error: string;
81
+ }>;
82
+ /** Total execution time in milliseconds */
83
+ executionTimeMs: number;
84
+ }
85
+ /**
86
+ * Response from table query used to find matching records.
87
+ */
88
+ export interface QueryMatchResponse {
89
+ result: Array<{
90
+ sys_id: string;
91
+ [key: string]: unknown;
92
+ }>;
93
+ }
@@ -0,0 +1,5 @@
1
+ // ============================================================
2
+ // Options Types
3
+ // ============================================================
4
+ export {};
5
+ //# sourceMappingURL=QueryBatchModels.js.map