@sonisoft/now-sdk-ext-core 1.0.0-alpha.33 → 2.0.0-alpha.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.
Files changed (105) hide show
  1. package/dist/auth/NowSDKAuthenticationHandler.d.ts +3 -3
  2. package/dist/auth/NowSDKAuthenticationHandler.js +6 -3
  3. package/dist/auth/NowSDKAuthenticationHandler.js.map +1 -1
  4. package/dist/comm/http/RequestHandler.js +17 -17
  5. package/dist/comm/http/RequestHandler.js.map +1 -1
  6. package/dist/index.d.ts +5 -3
  7. package/dist/index.js +5 -3
  8. package/dist/index.js.map +1 -1
  9. package/dist/sn/Application.js +11 -10
  10. package/dist/sn/Application.js.map +1 -1
  11. package/dist/sn/IServiceNowInstance.d.ts +1 -1
  12. package/dist/sn/ProgressWorker.js +2 -2
  13. package/dist/sn/ProgressWorker.js.map +1 -1
  14. package/dist/sn/ServiceNowInstance.d.ts +2 -2
  15. package/dist/sn/ServiceNowInstance.js.map +1 -1
  16. package/dist/sn/amb/AMBClient.d.ts +66 -0
  17. package/dist/sn/amb/AMBClient.js +358 -0
  18. package/dist/sn/amb/AMBClient.js.map +1 -0
  19. package/dist/sn/amb/AMBConstants.d.ts +8 -0
  20. package/dist/sn/amb/AMBConstants.js +10 -0
  21. package/dist/sn/amb/AMBConstants.js.map +1 -0
  22. package/dist/sn/amb/AuthenticatedWebSocket.d.ts +25 -0
  23. package/dist/sn/amb/AuthenticatedWebSocket.js +56 -0
  24. package/dist/sn/amb/AuthenticatedWebSocket.js.map +1 -0
  25. package/dist/sn/amb/Channel.d.ts +67 -0
  26. package/dist/sn/amb/Channel.js +212 -0
  27. package/dist/sn/amb/Channel.js.map +1 -0
  28. package/dist/sn/amb/ChannelListener.d.ts +31 -0
  29. package/dist/sn/amb/ChannelListener.js +60 -0
  30. package/dist/sn/amb/ChannelListener.js.map +1 -0
  31. package/dist/sn/amb/ChannelRedirect.d.ts +13 -0
  32. package/dist/sn/amb/ChannelRedirect.js +50 -0
  33. package/dist/sn/amb/ChannelRedirect.js.map +1 -0
  34. package/dist/sn/amb/CrossClientChannel.d.ts +4 -0
  35. package/dist/sn/amb/CrossClientChannel.js +14 -0
  36. package/dist/sn/amb/CrossClientChannel.js.map +1 -0
  37. package/dist/sn/amb/EventManager.d.ts +13 -0
  38. package/dist/sn/amb/EventManager.js +40 -0
  39. package/dist/sn/amb/EventManager.js.map +1 -0
  40. package/dist/sn/amb/FunctionQueue.d.ts +53 -0
  41. package/dist/sn/amb/FunctionQueue.js +95 -0
  42. package/dist/sn/amb/FunctionQueue.js.map +1 -0
  43. package/dist/sn/amb/GraphQLSubscriptionExtension.d.ts +12 -0
  44. package/dist/sn/amb/GraphQLSubscriptionExtension.js +31 -0
  45. package/dist/sn/amb/GraphQLSubscriptionExtension.js.map +1 -0
  46. package/dist/sn/amb/Helper.d.ts +5 -0
  47. package/dist/sn/amb/Helper.js +6 -0
  48. package/dist/sn/amb/Helper.js.map +1 -0
  49. package/dist/sn/amb/MessageClient.d.ts +73 -0
  50. package/dist/sn/amb/MessageClient.js +154 -0
  51. package/dist/sn/amb/MessageClient.js.map +1 -0
  52. package/dist/sn/amb/MessageClientBuilder.d.ts +24 -0
  53. package/dist/sn/amb/MessageClientBuilder.js +95 -0
  54. package/dist/sn/amb/MessageClientBuilder.js.map +1 -0
  55. package/dist/sn/amb/Properties.d.ts +16 -0
  56. package/dist/sn/amb/Properties.js +32 -0
  57. package/dist/sn/amb/Properties.js.map +1 -0
  58. package/dist/sn/amb/ServerConnection.d.ts +132 -0
  59. package/dist/sn/amb/ServerConnection.js +579 -0
  60. package/dist/sn/amb/ServerConnection.js.map +1 -0
  61. package/dist/sn/amb/SessionExtension.d.ts +8 -0
  62. package/dist/sn/amb/SessionExtension.js +20 -0
  63. package/dist/sn/amb/SessionExtension.js.map +1 -0
  64. package/dist/sn/amb/SubscriptionCommandSender.d.ts +60 -0
  65. package/dist/sn/amb/SubscriptionCommandSender.js +222 -0
  66. package/dist/sn/amb/SubscriptionCommandSender.js.map +1 -0
  67. package/dist/sn/amb/TokenManagementExtension.d.ts +20 -0
  68. package/dist/sn/amb/TokenManagementExtension.js +90 -0
  69. package/dist/sn/amb/TokenManagementExtension.js.map +1 -0
  70. package/dist/sn/amb/XMLHttpRequest.d.ts +31 -0
  71. package/dist/sn/amb/XMLHttpRequest.js +287 -0
  72. package/dist/sn/amb/XMLHttpRequest.js.map +1 -0
  73. package/dist/sn/amb/cometd-nodejs-client.d.ts +1 -0
  74. package/dist/sn/amb/cometd-nodejs-client.js +84 -0
  75. package/dist/sn/amb/cometd-nodejs-client.js.map +1 -0
  76. package/dist/sn/amb/index.d.ts +19 -0
  77. package/dist/sn/amb/index.js +20 -0
  78. package/dist/sn/amb/index.js.map +1 -0
  79. package/dist/sn/application/AppRepoApplication.d.ts +166 -0
  80. package/dist/sn/application/AppRepoApplication.js +167 -0
  81. package/dist/sn/application/AppRepoApplication.js.map +1 -0
  82. package/dist/sn/application/ApplicationDetailModel.d.ts +8 -8
  83. package/dist/sn/application/ApplicationDetailModel.js.map +1 -1
  84. package/dist/sn/application/ApplicationManager.d.ts +92 -1
  85. package/dist/sn/application/ApplicationManager.js +176 -17
  86. package/dist/sn/application/ApplicationManager.js.map +1 -1
  87. package/dist/sn/application/CompanyApplications.d.ts +234 -0
  88. package/dist/sn/application/CompanyApplications.js +91 -0
  89. package/dist/sn/application/CompanyApplications.js.map +1 -0
  90. package/dist/sn/atf/ATFTestExecutor.d.ts +90 -0
  91. package/dist/sn/atf/ATFTestExecutor.js +171 -12
  92. package/dist/sn/atf/ATFTestExecutor.js.map +1 -1
  93. package/dist/sn/syslog/SyslogReader.d.ts +113 -0
  94. package/dist/sn/syslog/SyslogReader.js +369 -0
  95. package/dist/sn/syslog/SyslogReader.js.map +1 -0
  96. package/dist/sn/syslog/SyslogRecord.d.ts +86 -0
  97. package/dist/sn/syslog/SyslogRecord.js +2 -0
  98. package/dist/sn/syslog/SyslogRecord.js.map +1 -0
  99. package/package.json +7 -9
  100. package/dist/comm/http/CookieStore.d.ts +0 -8
  101. package/dist/comm/http/CookieStore.js +0 -21
  102. package/dist/comm/http/CookieStore.js.map +0 -1
  103. package/dist/comm/http/CookieStoreFactory.d.ts +0 -5
  104. package/dist/comm/http/CookieStoreFactory.js +0 -11
  105. package/dist/comm/http/CookieStoreFactory.js.map +0 -1
@@ -0,0 +1,234 @@
1
+ import { ServiceNowInstance } from "../ServiceNowInstance.js";
2
+ /**
3
+ * CompanyApplications class for retrieving company application information
4
+ * Provides methods to get applications shared internally within the company
5
+ */
6
+ export declare class CompanyApplications {
7
+ private readonly COMPANY_APPS_API_URL;
8
+ private _logger;
9
+ private _req;
10
+ private _instance;
11
+ constructor(instance: ServiceNowInstance);
12
+ /**
13
+ * Gets the list of company applications shared internally
14
+ * @param sharedInternally Filter for internally shared applications (default: true)
15
+ * @param isFirstLoad Indicates if this is the first load (default: true)
16
+ * @returns Promise<CompanyApplicationsResponse> Response containing list of applications
17
+ */
18
+ getCompanyApplications(sharedInternally?: boolean, isFirstLoad?: boolean): Promise<CompanyApplicationsResponse>;
19
+ /**
20
+ * Gets a specific company application by scope
21
+ * @param scope The application scope to search for
22
+ * @param sharedInternally Filter for internally shared applications (default: true)
23
+ * @returns Promise<CompanyApplication | null> The application if found, null otherwise
24
+ */
25
+ getCompanyApplicationByScope(scope: string, sharedInternally?: boolean): Promise<CompanyApplication | null>;
26
+ /**
27
+ * Gets a specific company application by sys_id
28
+ * @param sysId The application sys_id to search for
29
+ * @param sharedInternally Filter for internally shared applications (default: true)
30
+ * @returns Promise<CompanyApplication | null> The application if found, null otherwise
31
+ */
32
+ getCompanyApplicationBySysId(sysId: string, sharedInternally?: boolean): Promise<CompanyApplication | null>;
33
+ /**
34
+ * Gets only installed company applications
35
+ * @param sharedInternally Filter for internally shared applications (default: true)
36
+ * @returns Promise<CompanyApplication[]> Array of installed applications
37
+ */
38
+ getInstalledCompanyApplications(sharedInternally?: boolean): Promise<CompanyApplication[]>;
39
+ }
40
+ /**
41
+ * Response from company applications API
42
+ */
43
+ export interface CompanyApplicationsResponse {
44
+ /** Application server URL */
45
+ appServer: string;
46
+ /** Array of company applications */
47
+ data: CompanyApplication[];
48
+ /** Data processing time in milliseconds */
49
+ dataProcessingTime: number;
50
+ /** Repository response time in milliseconds */
51
+ reporesponsetime: number;
52
+ /** Store URL */
53
+ storeURL: string;
54
+ /** Store tracker ID */
55
+ storetrackerId: string;
56
+ }
57
+ /**
58
+ * Represents a company application
59
+ */
60
+ export interface CompanyApplication {
61
+ /** Whether the application is active */
62
+ active: boolean;
63
+ /** Application schedule details */
64
+ app_schedule_details: Record<string, unknown>;
65
+ /** Assigned version */
66
+ assigned_version: string;
67
+ /** Whether installation is blocked */
68
+ block_install: boolean;
69
+ /** Block message if installation is blocked */
70
+ block_message: string;
71
+ /** Whether the app can be edited in Studio */
72
+ can_edit_in_studio: boolean;
73
+ /** Whether the app can be installed or upgraded */
74
+ can_install_or_upgrade: boolean;
75
+ /** Whether customization can be installed or upgraded */
76
+ can_install_or_upgrade_customization: boolean;
77
+ /** Whether the app can be opened in Studio */
78
+ can_open_in_studio: boolean;
79
+ /** Compatibility information */
80
+ compatibilities: string;
81
+ /** Whether the app contains plugins */
82
+ contains_plugins: boolean;
83
+ /** Custom table count */
84
+ custom_table_count: string;
85
+ /** Customized version information */
86
+ customized_version_info: Record<string, unknown>;
87
+ /** Demo data status */
88
+ demo_data: string;
89
+ /** Application dependencies */
90
+ dependencies: string | null;
91
+ /** Display message */
92
+ display_message: string | null;
93
+ /** Whether the app has a manifest */
94
+ has_manifest: boolean;
95
+ /** Indicators array */
96
+ indicators: unknown[];
97
+ /** Installation date */
98
+ install_date: string;
99
+ /** Whether installed as a dependency */
100
+ installed_as_dependency: boolean;
101
+ /** Whether this is an App Store plugin */
102
+ isAppstorePlugin: boolean;
103
+ /** Whether the application is installed */
104
+ isInstalled: boolean;
105
+ /** Whether this is a customized app */
106
+ is_customized_app: boolean;
107
+ /** Whether this is a store app */
108
+ is_store_app: boolean;
109
+ /** Latest version available */
110
+ latest_version: string;
111
+ /** Latest version display name */
112
+ latest_version_display: string;
113
+ /** Link to the application */
114
+ link: string;
115
+ /** Line of business array */
116
+ lob: unknown[];
117
+ /** Logo URL */
118
+ logo: string;
119
+ /** Application name */
120
+ name: string;
121
+ /** Whether App Engine licensing is needed */
122
+ needs_app_engine_licensing: boolean;
123
+ /** Whether optional apps are available */
124
+ optional_apps_available: boolean;
125
+ /** Price type */
126
+ price_type: string;
127
+ /** Products array */
128
+ products: unknown[];
129
+ /** Publish date display */
130
+ publish_date_display: string;
131
+ /** Application scope */
132
+ scope: string;
133
+ /** Whether shared internally */
134
+ shared_internally: string;
135
+ /** Short description */
136
+ short_description: string;
137
+ /** Source information */
138
+ source: string;
139
+ /** Store link URL */
140
+ store_link: string;
141
+ /** System code */
142
+ sys_code: string | null;
143
+ /** System created on timestamp */
144
+ sys_created_on: string;
145
+ /** System created on display */
146
+ sys_created_on_display: string;
147
+ /** System ID */
148
+ sys_id: string;
149
+ /** System updated on timestamp */
150
+ sys_updated_on: string;
151
+ /** System updated on display */
152
+ sys_updated_on_display: string;
153
+ /** Whether uninstall is blocked */
154
+ uninstall_blocked: boolean;
155
+ /** Update date */
156
+ update_date: string;
157
+ /** Upload information */
158
+ upload_info: string;
159
+ /** Vendor name */
160
+ vendor: string;
161
+ /** Vendor prefix */
162
+ vendor_prefix: string;
163
+ /** Current version (if installed) */
164
+ version: string;
165
+ /** Array of available versions */
166
+ versions: CompanyApplicationVersion[];
167
+ }
168
+ /**
169
+ * Represents a version of a company application
170
+ */
171
+ export interface CompanyApplicationVersion {
172
+ /** Auto-update flag */
173
+ auto_update: string;
174
+ /** Whether installation is blocked for this version */
175
+ block_install: boolean;
176
+ /** Block message if installation is blocked */
177
+ block_message: string | null;
178
+ /** Compatibility information */
179
+ compatibilities: string;
180
+ /** Whether this version contains plugins */
181
+ contains_plugins: boolean;
182
+ /** Custom table count */
183
+ custom_table_count: string;
184
+ /** Whether this version has demo data */
185
+ demo_data: boolean;
186
+ /** Dependencies for this version */
187
+ dependencies: string | null;
188
+ /** Display message */
189
+ display_message: string;
190
+ /** Whether this version has a manifest */
191
+ has_manifest: boolean;
192
+ /** Indicators array */
193
+ indicators: unknown[];
194
+ /** Line of business array */
195
+ lob: unknown[];
196
+ /** Application name */
197
+ name: string;
198
+ /** Whether App Engine licensing is needed */
199
+ needs_app_engine_licensing: boolean;
200
+ /** Version number in repository */
201
+ number: string;
202
+ /** Price type */
203
+ price_type: string;
204
+ /** Publish date timestamp */
205
+ publish_date: string;
206
+ /** Publish date display */
207
+ publish_date_display: string;
208
+ /** Remote application sys_id */
209
+ remote_application: string;
210
+ /** Application scope */
211
+ scope: string;
212
+ /** Short description */
213
+ short_description: string | null;
214
+ /** Sortable version number */
215
+ sortable_version: number;
216
+ /** Source application ID */
217
+ source_app_id: string;
218
+ /** Store link URL */
219
+ store_link: string;
220
+ /** System ID of this version */
221
+ sys_id: string;
222
+ /** Title of this version */
223
+ title: string;
224
+ /** Upload information */
225
+ upload_info: string;
226
+ /** Vendor name */
227
+ vendor: string;
228
+ /** Vendor key */
229
+ vendor_key: string;
230
+ /** Version number */
231
+ version: string;
232
+ /** Version display name */
233
+ version_display: string;
234
+ }
@@ -0,0 +1,91 @@
1
+ import { Logger } from "../../util/Logger.js";
2
+ import { ServiceNowRequest } from "../../comm/http/ServiceNowRequest.js";
3
+ /**
4
+ * CompanyApplications class for retrieving company application information
5
+ * Provides methods to get applications shared internally within the company
6
+ */
7
+ export class CompanyApplications {
8
+ COMPANY_APPS_API_URL = "/sn_appclient_api_v1.do";
9
+ _logger = new Logger("CompanyApplications");
10
+ _req;
11
+ _instance;
12
+ constructor(instance) {
13
+ this._instance = instance;
14
+ this._req = new ServiceNowRequest(instance);
15
+ }
16
+ /**
17
+ * Gets the list of company applications shared internally
18
+ * @param sharedInternally Filter for internally shared applications (default: true)
19
+ * @param isFirstLoad Indicates if this is the first load (default: true)
20
+ * @returns Promise<CompanyApplicationsResponse> Response containing list of applications
21
+ */
22
+ async getCompanyApplications(sharedInternally = true, isFirstLoad = true) {
23
+ const queryParams = {
24
+ app_request_type: 'list_apps_versions',
25
+ shared_internally: sharedInternally,
26
+ isFirstLoad: isFirstLoad,
27
+ uniq_param: Date.now().toString()
28
+ };
29
+ const httpRequest = {
30
+ method: 'GET',
31
+ path: this.COMPANY_APPS_API_URL,
32
+ headers: {
33
+ 'Accept': 'application/json',
34
+ 'Content-Type': 'application/json'
35
+ },
36
+ query: queryParams,
37
+ body: null
38
+ };
39
+ this._logger.info(`Fetching company applications (shared_internally: ${sharedInternally})`);
40
+ const resp = await this._req.get(httpRequest);
41
+ if (resp.status === 200 && resp.bodyObject) {
42
+ this._logger.info(`Successfully retrieved ${resp.bodyObject.data?.length || 0} company applications`);
43
+ return resp.bodyObject;
44
+ }
45
+ throw new Error(`Failed to get company applications. Status: ${resp.status}, Response: ${JSON.stringify(resp.bodyObject)}`);
46
+ }
47
+ /**
48
+ * Gets a specific company application by scope
49
+ * @param scope The application scope to search for
50
+ * @param sharedInternally Filter for internally shared applications (default: true)
51
+ * @returns Promise<CompanyApplication | null> The application if found, null otherwise
52
+ */
53
+ async getCompanyApplicationByScope(scope, sharedInternally = true) {
54
+ const response = await this.getCompanyApplications(sharedInternally);
55
+ const application = response.data?.find(app => app.scope === scope);
56
+ if (application) {
57
+ this._logger.info(`Found application: ${application.name} (${scope})`);
58
+ return application;
59
+ }
60
+ this._logger.warn(`Application with scope '${scope}' not found`);
61
+ return null;
62
+ }
63
+ /**
64
+ * Gets a specific company application by sys_id
65
+ * @param sysId The application sys_id to search for
66
+ * @param sharedInternally Filter for internally shared applications (default: true)
67
+ * @returns Promise<CompanyApplication | null> The application if found, null otherwise
68
+ */
69
+ async getCompanyApplicationBySysId(sysId, sharedInternally = true) {
70
+ const response = await this.getCompanyApplications(sharedInternally);
71
+ const application = response.data?.find(app => app.sys_id === sysId);
72
+ if (application) {
73
+ this._logger.info(`Found application: ${application.name} (${sysId})`);
74
+ return application;
75
+ }
76
+ this._logger.warn(`Application with sys_id '${sysId}' not found`);
77
+ return null;
78
+ }
79
+ /**
80
+ * Gets only installed company applications
81
+ * @param sharedInternally Filter for internally shared applications (default: true)
82
+ * @returns Promise<CompanyApplication[]> Array of installed applications
83
+ */
84
+ async getInstalledCompanyApplications(sharedInternally = true) {
85
+ const response = await this.getCompanyApplications(sharedInternally);
86
+ const installedApps = response.data?.filter(app => app.isInstalled) || [];
87
+ this._logger.info(`Found ${installedApps.length} installed company applications`);
88
+ return installedApps;
89
+ }
90
+ }
91
+ //# sourceMappingURL=CompanyApplications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompanyApplications.js","sourceRoot":"","sources":["../../../src/sn/application/CompanyApplications.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IACX,oBAAoB,GAAG,yBAAyB,CAAC;IAE1D,OAAO,GAAW,IAAI,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACpD,IAAI,CAAoB;IACxB,SAAS,CAAqB;IAEtC,YAAmB,QAA4B;QAC3C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,sBAAsB,CAC/B,mBAA4B,IAAI,EAChC,cAAuB,IAAI;QAE3B,MAAM,WAAW,GAAqC;YAClD,gBAAgB,EAAE,oBAAoB;YACtC,iBAAiB,EAAE,gBAAgB;YACnC,WAAW,EAAE,WAAW;YACxB,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;SACpC,CAAC;QAEF,MAAM,WAAW,GAAgB;YAC7B,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI,CAAC,oBAAoB;YAC/B,OAAO,EAAE;gBACL,QAAQ,EAAE,kBAAkB;gBAC5B,cAAc,EAAE,kBAAkB;aACrC;YACD,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,IAAI;SACb,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,qDAAqD,gBAAgB,GAAG,CAAC,CAAC;QAE5F,MAAM,IAAI,GAA+C,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAA8B,WAAW,CAAC,CAAC;QAEvH,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACzC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,0BAA0B,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,uBAAuB,CAAC,CAAC;YACtG,OAAO,IAAI,CAAC,UAAU,CAAC;QAC3B,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,+CAA+C,IAAI,CAAC,MAAM,eAAe,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAChI,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,4BAA4B,CACrC,KAAa,EACb,mBAA4B,IAAI;QAEhC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;QAErE,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAEpE,IAAI,WAAW,EAAE,CAAC;YACd,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,sBAAsB,WAAW,CAAC,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC;YACvE,OAAO,WAAW,CAAC;QACvB,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,2BAA2B,KAAK,aAAa,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,4BAA4B,CACrC,KAAa,EACb,mBAA4B,IAAI;QAEhC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;QAErE,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC;QAErE,IAAI,WAAW,EAAE,CAAC;YACd,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,sBAAsB,WAAW,CAAC,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC;YACvE,OAAO,WAAW,CAAC;QACvB,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,4BAA4B,KAAK,aAAa,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,+BAA+B,CACxC,mBAA4B,IAAI;QAEhC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;QAErE,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAE1E,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,aAAa,CAAC,MAAM,iCAAiC,CAAC,CAAC;QAClF,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ"}
@@ -10,6 +10,55 @@ export declare class ATFTestExecutor {
10
10
  private doGetTestProgress;
11
11
  private getTestProgress;
12
12
  private getTestResult;
13
+ /**
14
+ * Executes a test suite by sys_id using the ServiceNow CI/CD API
15
+ * @param testSuiteSysId The sys_id of the test suite to execute
16
+ * @param options Optional execution parameters
17
+ * @returns Promise<TestSuiteExecutionResponse> The execution response with progress information
18
+ */
19
+ executeTestSuite(testSuiteSysId: string, options?: Partial<TestSuiteExecutionRequest>): Promise<TestSuiteExecutionResponse>;
20
+ /**
21
+ * Executes a test suite by name using the ServiceNow CI/CD API
22
+ * @param testSuiteName The name of the test suite to execute
23
+ * @param options Optional execution parameters
24
+ * @returns Promise<TestSuiteExecutionResponse> The execution response with progress information
25
+ */
26
+ executeTestSuiteByName(testSuiteName: string, options?: Partial<TestSuiteExecutionRequest>): Promise<TestSuiteExecutionResponse>;
27
+ /**
28
+ * Gets the progress of a test suite execution
29
+ * @param progressId The progress ID from the execution response
30
+ * @returns Promise<TestSuiteExecutionResponse> The current progress information
31
+ */
32
+ getTestSuiteProgress(progressId: string): Promise<TestSuiteExecutionResponse>;
33
+ /**
34
+ * Waits for test suite execution to complete and returns the results
35
+ * @param progressId The progress ID from the execution response
36
+ * @param pollIntervalMs Polling interval in milliseconds (default: 5000)
37
+ * @returns Promise<TestSuiteExecutionResult> The final execution results
38
+ */
39
+ waitForTestSuiteCompletion(progressId: string, pollIntervalMs?: number): Promise<TestSuiteExecutionResult>;
40
+ /**
41
+ * Gets the results of a completed test suite execution
42
+ * @param resultsId The results ID from the progress response
43
+ * @returns Promise<TestSuiteExecutionResult> The execution results
44
+ */
45
+ getTestSuiteResults(resultsId: string): Promise<TestSuiteExecutionResult>;
46
+ /**
47
+ * Executes a test suite and waits for completion
48
+ * @param testSuiteSysId The sys_id of the test suite to execute
49
+ * @param options Optional execution parameters
50
+ * @param pollIntervalMs Polling interval in milliseconds (default: 5000)
51
+ * @returns Promise<TestSuiteExecutionResult> The final execution results
52
+ */
53
+ executeTestSuiteAndWait(testSuiteSysId: string, options?: Partial<TestSuiteExecutionRequest>, pollIntervalMs?: number): Promise<TestSuiteExecutionResult>;
54
+ /**
55
+ * Executes a test suite by name and waits for completion
56
+ * @param testSuiteName The name of the test suite to execute
57
+ * @param options Optional execution parameters
58
+ * @param pollIntervalMs Polling interval in milliseconds (default: 5000)
59
+ * @returns Promise<TestSuiteExecutionResult> The final execution results
60
+ */
61
+ executeTestSuiteByNameAndWait(testSuiteName: string, options?: Partial<TestSuiteExecutionRequest>, pollIntervalMs?: number): Promise<TestSuiteExecutionResult>;
13
62
  }
14
63
  export type TestResult = {
15
64
  "end_time_millis": string;
@@ -23,3 +72,44 @@ export type TestResult = {
23
72
  "run_time": string;
24
73
  "status": string;
25
74
  };
75
+ export interface TestSuiteExecutionRequest {
76
+ test_suite_sys_id?: string;
77
+ test_suite_name?: string;
78
+ browser_name?: string;
79
+ browser_version?: string;
80
+ is_performance_run?: boolean;
81
+ os_name?: string;
82
+ os_version?: string;
83
+ run_in_cloud?: boolean;
84
+ }
85
+ export interface TestSuiteExecutionResponse {
86
+ links: {
87
+ progress: {
88
+ id: string;
89
+ url: string;
90
+ };
91
+ results?: {
92
+ id: string;
93
+ url: string;
94
+ };
95
+ };
96
+ status: string;
97
+ status_label: string;
98
+ status_message: string;
99
+ status_detail: string;
100
+ error: string;
101
+ percent_complete: number;
102
+ }
103
+ export interface TestSuiteExecutionResult {
104
+ sys_id: string;
105
+ test_suite: ReferenceLink;
106
+ status: string;
107
+ start_time: string;
108
+ end_time: string;
109
+ duration: string;
110
+ total_tests: number;
111
+ passed_tests: number;
112
+ failed_tests: number;
113
+ skipped_tests: number;
114
+ output: string;
115
+ }
@@ -8,7 +8,7 @@ export class ATFTestExecutor {
8
8
  this._req = new ServiceNowRequest(instance);
9
9
  }
10
10
  async executeTest(testId) {
11
- let dataObj = {
11
+ const dataObj = {
12
12
  'sysparm_want_session_messages': 'true',
13
13
  'sysparm_ajax_processor_ut_test_id': testId,
14
14
  'sysparm_ajax_processor_test_runner_session_id': '',
@@ -19,13 +19,13 @@ export class ATFTestExecutor {
19
19
  'ni.nolog.x_referer': 'ignore',
20
20
  'x_referer': 'sys_atf_test.do%3Fsys_id%3D817a3214835b4210a9f8aec0deaad3f4%26sysparm_view%3D%26sysparm_domain%3Dnull%26sysparm_domain_scope%3Dnull'
21
21
  };
22
- let proc = new ServiceNowProcessorRequest(this._instance);
23
- let result = await proc.execute("TestExecutorAjax", "start", "global", dataObj);
22
+ const proc = new ServiceNowProcessorRequest(this._instance);
23
+ const result = await proc.execute("TestExecutorAjax", "start", "global", dataObj);
24
24
  //In this case, result is the progress worker id.
25
25
  if (result != null) {
26
- let resultId = await this.waitForTestCompletion(result);
26
+ const resultId = await this.waitForTestCompletion(result);
27
27
  if (resultId) {
28
- let testResult = await this.getTestResult(resultId);
28
+ const testResult = await this.getTestResult(resultId);
29
29
  if (testResult)
30
30
  return testResult;
31
31
  }
@@ -46,35 +46,194 @@ export class ATFTestExecutor {
46
46
  return null;
47
47
  }
48
48
  async doGetTestProgress(progressId) {
49
- let data = await this.getTestProgress(progressId);
49
+ const data = await this.getTestProgress(progressId);
50
50
  try {
51
51
  if (data.result) {
52
52
  return data.result;
53
53
  }
54
54
  }
55
- catch (err) {
55
+ catch {
56
56
  return null;
57
57
  }
58
58
  return null;
59
59
  }
60
60
  async getTestProgress(progressId) {
61
- let request = { path: "/api/sn_cicd/progress/" + progressId, headers: null, query: null, body: null };
62
- let resp = await this._req.get(request);
61
+ const request = { path: "/api/sn_cicd/progress/" + progressId, headers: null, query: null, body: null };
62
+ const resp = await this._req.get(request);
63
63
  if (resp.status == 200) {
64
64
  return resp.bodyObject;
65
65
  }
66
66
  return null;
67
67
  }
68
68
  async getTestResult(testResultId) {
69
- let request = { path: "/api/now/table/sys_atf_test_result?sysparm_query=sys_id=" + testResultId, headers: null, query: null, body: null };
70
- let resp = await this._req.get(request);
69
+ const request = { path: "/api/now/table/sys_atf_test_result?sysparm_query=sys_id=" + testResultId, headers: null, query: null, body: null };
70
+ const resp = await this._req.get(request);
71
71
  if (resp.status == 200) {
72
- let tableResp = resp.bodyObject;
72
+ const tableResp = resp.bodyObject;
73
73
  if (tableResp.result && tableResp.result.length > 0) {
74
74
  return tableResp.result[0];
75
75
  }
76
76
  }
77
77
  return null;
78
78
  }
79
+ // private async getTestStepResults(){
80
+ // }
81
+ /**
82
+ * Executes a test suite by sys_id using the ServiceNow CI/CD API
83
+ * @param testSuiteSysId The sys_id of the test suite to execute
84
+ * @param options Optional execution parameters
85
+ * @returns Promise<TestSuiteExecutionResponse> The execution response with progress information
86
+ */
87
+ async executeTestSuite(testSuiteSysId, options) {
88
+ const queryParams = {
89
+ test_suite_sys_id: testSuiteSysId
90
+ };
91
+ // Add optional parameters if provided
92
+ if (options) {
93
+ if (options.browser_name)
94
+ queryParams.browser_name = options.browser_name;
95
+ if (options.browser_version)
96
+ queryParams.browser_version = options.browser_version;
97
+ if (options.is_performance_run !== undefined)
98
+ queryParams.is_performance_run = options.is_performance_run;
99
+ if (options.os_name)
100
+ queryParams.os_name = options.os_name;
101
+ if (options.os_version)
102
+ queryParams.os_version = options.os_version;
103
+ if (options.run_in_cloud !== undefined)
104
+ queryParams.run_in_cloud = options.run_in_cloud;
105
+ }
106
+ const request = {
107
+ path: "/api/sn_cicd/testsuite/run",
108
+ headers: {
109
+ 'Accept': 'application/json'
110
+ },
111
+ query: queryParams,
112
+ body: null
113
+ };
114
+ const resp = await this._req.post(request);
115
+ if (resp.status === 200 && resp.bodyObject && resp.bodyObject.result) {
116
+ return resp.bodyObject.result;
117
+ }
118
+ throw new Error(`Failed to execute test suite. Status: ${resp.status}, Response: ${JSON.stringify(resp.bodyObject)}`);
119
+ }
120
+ /**
121
+ * Executes a test suite by name using the ServiceNow CI/CD API
122
+ * @param testSuiteName The name of the test suite to execute
123
+ * @param options Optional execution parameters
124
+ * @returns Promise<TestSuiteExecutionResponse> The execution response with progress information
125
+ */
126
+ async executeTestSuiteByName(testSuiteName, options) {
127
+ const queryParams = {
128
+ test_suite_name: testSuiteName
129
+ };
130
+ // Add optional parameters if provided
131
+ if (options) {
132
+ if (options.browser_name)
133
+ queryParams.browser_name = options.browser_name;
134
+ if (options.browser_version)
135
+ queryParams.browser_version = options.browser_version;
136
+ if (options.is_performance_run !== undefined)
137
+ queryParams.is_performance_run = options.is_performance_run;
138
+ if (options.os_name)
139
+ queryParams.os_name = options.os_name;
140
+ if (options.os_version)
141
+ queryParams.os_version = options.os_version;
142
+ if (options.run_in_cloud !== undefined)
143
+ queryParams.run_in_cloud = options.run_in_cloud;
144
+ }
145
+ const request = {
146
+ path: "/api/sn_cicd/testsuite/run",
147
+ headers: {
148
+ 'Accept': 'application/json'
149
+ },
150
+ query: queryParams,
151
+ body: null
152
+ };
153
+ const resp = await this._req.post(request);
154
+ if (resp.status === 200 && resp.bodyObject && resp.bodyObject.result) {
155
+ return resp.bodyObject.result;
156
+ }
157
+ throw new Error(`Failed to execute test suite by name. Status: ${resp.status}, Response: ${JSON.stringify(resp.bodyObject)}`);
158
+ }
159
+ /**
160
+ * Gets the progress of a test suite execution
161
+ * @param progressId The progress ID from the execution response
162
+ * @returns Promise<TestSuiteExecutionResponse> The current progress information
163
+ */
164
+ async getTestSuiteProgress(progressId) {
165
+ const request = {
166
+ path: `/api/sn_cicd/progress/${progressId}`,
167
+ headers: {
168
+ 'Accept': 'application/json'
169
+ },
170
+ query: null,
171
+ body: null
172
+ };
173
+ const resp = await this._req.get(request);
174
+ if (resp.status === 200 && resp.bodyObject && resp.bodyObject.result) {
175
+ return resp.bodyObject.result;
176
+ }
177
+ throw new Error(`Failed to get test suite progress. Status: ${resp.status}, Response: ${JSON.stringify(resp.bodyObject)}`);
178
+ }
179
+ /**
180
+ * Waits for test suite execution to complete and returns the results
181
+ * @param progressId The progress ID from the execution response
182
+ * @param pollIntervalMs Polling interval in milliseconds (default: 5000)
183
+ * @returns Promise<TestSuiteExecutionResult> The final execution results
184
+ */
185
+ async waitForTestSuiteCompletion(progressId, pollIntervalMs = 5000) {
186
+ let progress = await this.getTestSuiteProgress(progressId);
187
+ while (progress.percent_complete < 100 && progress.status !== "3" && progress.status !== "4") {
188
+ await new Promise(resolve => setTimeout(resolve, pollIntervalMs));
189
+ progress = await this.getTestSuiteProgress(progressId);
190
+ }
191
+ if (progress.links && progress.links.results && progress.links.results.id) {
192
+ return await this.getTestSuiteResults(progress.links.results.id);
193
+ }
194
+ throw new Error(`Test suite execution did not complete successfully. Status: ${progress.status_label}, Error: ${progress.error}`);
195
+ }
196
+ /**
197
+ * Gets the results of a completed test suite execution
198
+ * @param resultsId The results ID from the progress response
199
+ * @returns Promise<TestSuiteExecutionResult> The execution results
200
+ */
201
+ async getTestSuiteResults(resultsId) {
202
+ const request = {
203
+ path: `/api/now/table/sys_atf_test_suite_result?sysparm_query=sys_id=${resultsId}`,
204
+ headers: {
205
+ 'Accept': 'application/json'
206
+ },
207
+ query: null,
208
+ body: null
209
+ };
210
+ const resp = await this._req.get(request);
211
+ if (resp.status === 200 && resp.bodyObject && resp.bodyObject.result && resp.bodyObject.result.length > 0) {
212
+ return resp.bodyObject.result[0];
213
+ }
214
+ throw new Error(`Failed to get test suite results. Status: ${resp.status}, Response: ${JSON.stringify(resp.bodyObject)}`);
215
+ }
216
+ /**
217
+ * Executes a test suite and waits for completion
218
+ * @param testSuiteSysId The sys_id of the test suite to execute
219
+ * @param options Optional execution parameters
220
+ * @param pollIntervalMs Polling interval in milliseconds (default: 5000)
221
+ * @returns Promise<TestSuiteExecutionResult> The final execution results
222
+ */
223
+ async executeTestSuiteAndWait(testSuiteSysId, options, pollIntervalMs = 5000) {
224
+ const executionResponse = await this.executeTestSuite(testSuiteSysId, options);
225
+ return await this.waitForTestSuiteCompletion(executionResponse.links.progress.id, pollIntervalMs);
226
+ }
227
+ /**
228
+ * Executes a test suite by name and waits for completion
229
+ * @param testSuiteName The name of the test suite to execute
230
+ * @param options Optional execution parameters
231
+ * @param pollIntervalMs Polling interval in milliseconds (default: 5000)
232
+ * @returns Promise<TestSuiteExecutionResult> The final execution results
233
+ */
234
+ async executeTestSuiteByNameAndWait(testSuiteName, options, pollIntervalMs = 5000) {
235
+ const executionResponse = await this.executeTestSuiteByName(testSuiteName, options);
236
+ return await this.waitForTestSuiteCompletion(executionResponse.links.progress.id, pollIntervalMs);
237
+ }
79
238
  }
80
239
  //# sourceMappingURL=ATFTestExecutor.js.map