@sonisoft/now-sdk-ext-core 2.2.0 → 2.4.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.
- package/dist/comm/http/RequestHandler.js +7 -11
- package/dist/comm/http/RequestHandler.js.map +1 -1
- package/dist/comm/http/TableAPIRequest.js +3 -10
- package/dist/comm/http/TableAPIRequest.js.map +1 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/dist/sn/BackgroundScriptExecutor.d.ts +40 -0
- package/dist/sn/BackgroundScriptExecutor.js +129 -8
- package/dist/sn/BackgroundScriptExecutor.js.map +1 -1
- package/dist/sn/application/ApplicationManager.d.ts +58 -1
- package/dist/sn/application/ApplicationManager.js +202 -11
- package/dist/sn/application/ApplicationManager.js.map +1 -1
- package/dist/sn/application/StoreApplicationModels.d.ts +99 -0
- package/dist/sn/application/StoreApplicationModels.js +2 -0
- package/dist/sn/application/StoreApplicationModels.js.map +1 -0
- package/dist/sn/attachment/AttachmentManager.d.ts +32 -0
- package/dist/sn/attachment/AttachmentManager.js +87 -0
- package/dist/sn/attachment/AttachmentManager.js.map +1 -0
- package/dist/sn/attachment/AttachmentModels.d.ts +28 -0
- package/dist/sn/attachment/AttachmentModels.js +2 -0
- package/dist/sn/attachment/AttachmentModels.js.map +1 -0
- package/dist/sn/batch/BatchModels.d.ts +90 -0
- package/dist/sn/batch/BatchModels.js +5 -0
- package/dist/sn/batch/BatchModels.js.map +1 -0
- package/dist/sn/batch/BatchOperations.d.ts +40 -0
- package/dist/sn/batch/BatchOperations.js +169 -0
- package/dist/sn/batch/BatchOperations.js.map +1 -0
- package/dist/sn/schema/SchemaDiscovery.d.ts +68 -0
- package/dist/sn/schema/SchemaDiscovery.js +346 -0
- package/dist/sn/schema/SchemaDiscovery.js.map +1 -0
- package/dist/sn/schema/SchemaModels.d.ts +277 -0
- package/dist/sn/schema/SchemaModels.js +5 -0
- package/dist/sn/schema/SchemaModels.js.map +1 -0
- package/dist/sn/scope/ScopeManager.d.ts +51 -0
- package/dist/sn/scope/ScopeManager.js +177 -0
- package/dist/sn/scope/ScopeManager.js.map +1 -0
- package/dist/sn/scope/ScopeModels.d.ts +66 -0
- package/dist/sn/scope/ScopeModels.js +5 -0
- package/dist/sn/scope/ScopeModels.js.map +1 -0
- package/dist/sn/scriptsync/ScriptSync.d.ts +38 -0
- package/dist/sn/scriptsync/ScriptSync.js +266 -0
- package/dist/sn/scriptsync/ScriptSync.js.map +1 -0
- package/dist/sn/scriptsync/ScriptSyncModels.d.ts +55 -0
- package/dist/sn/scriptsync/ScriptSyncModels.js +8 -0
- package/dist/sn/scriptsync/ScriptSyncModels.js.map +1 -0
- package/dist/sn/scriptsync/ScriptWatcher.d.ts +30 -0
- package/dist/sn/scriptsync/ScriptWatcher.js +74 -0
- package/dist/sn/scriptsync/ScriptWatcher.js.map +1 -0
- package/dist/sn/task/TaskModels.d.ts +85 -0
- package/dist/sn/task/TaskModels.js +5 -0
- package/dist/sn/task/TaskModels.js.map +1 -0
- package/dist/sn/task/TaskOperations.d.ts +63 -0
- package/dist/sn/task/TaskOperations.js +195 -0
- package/dist/sn/task/TaskOperations.js.map +1 -0
- package/dist/sn/updateset/UpdateSetManager.d.ts +78 -0
- package/dist/sn/updateset/UpdateSetManager.js +391 -0
- package/dist/sn/updateset/UpdateSetManager.js.map +1 -0
- package/dist/sn/updateset/UpdateSetModels.d.ts +177 -0
- package/dist/sn/updateset/UpdateSetModels.js +5 -0
- package/dist/sn/updateset/UpdateSetModels.js.map +1 -0
- package/dist/sn/workflow/WorkflowManager.d.ts +81 -0
- package/dist/sn/workflow/WorkflowManager.js +388 -0
- package/dist/sn/workflow/WorkflowManager.js.map +1 -0
- package/dist/sn/workflow/WorkflowModels.d.ts +242 -0
- package/dist/sn/workflow/WorkflowModels.js +5 -0
- package/dist/sn/workflow/WorkflowModels.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { Logger } from "../../util/Logger.js";
|
|
2
|
+
import { ServiceNowRequest } from "../../comm/http/ServiceNowRequest.js";
|
|
3
|
+
import { TableAPIRequest } from "../../comm/http/TableAPIRequest.js";
|
|
4
|
+
/**
|
|
5
|
+
* UpdateSetManager provides operations for managing ServiceNow update sets.
|
|
6
|
+
* Supports setting/getting the current update set, listing, creating,
|
|
7
|
+
* moving records between update sets, cloning, and inspecting update sets.
|
|
8
|
+
*/
|
|
9
|
+
export class UpdateSetManager {
|
|
10
|
+
static UI_UPDATESET_PATH = '/api/now/ui/concoursepicker/updateset';
|
|
11
|
+
static UI_PREF_UPDATESET_PATH = '/api/now/ui/preferences/sys_update_set';
|
|
12
|
+
static UPDATE_SET_TABLE = 'sys_update_set';
|
|
13
|
+
static UPDATE_XML_TABLE = 'sys_update_xml';
|
|
14
|
+
_logger = new Logger("UpdateSetManager");
|
|
15
|
+
_req;
|
|
16
|
+
_tableAPI;
|
|
17
|
+
_instance;
|
|
18
|
+
constructor(instance) {
|
|
19
|
+
this._instance = instance;
|
|
20
|
+
this._req = new ServiceNowRequest(instance);
|
|
21
|
+
this._tableAPI = new TableAPIRequest(instance);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Set the current update set for the session.
|
|
25
|
+
* Uses PUT /api/now/ui/concoursepicker/updateset
|
|
26
|
+
*
|
|
27
|
+
* @param options The update set name and sysId to set as current
|
|
28
|
+
* @throws Error if name or sysId is empty or if the API call fails
|
|
29
|
+
*/
|
|
30
|
+
async setCurrentUpdateSet(options) {
|
|
31
|
+
if (!options.name || options.name.trim().length === 0) {
|
|
32
|
+
throw new Error('Update set name is required');
|
|
33
|
+
}
|
|
34
|
+
if (!options.sysId || options.sysId.trim().length === 0) {
|
|
35
|
+
throw new Error('Update set sysId is required');
|
|
36
|
+
}
|
|
37
|
+
this._logger.info(`Setting current update set to: ${options.name} (${options.sysId})`);
|
|
38
|
+
const request = {
|
|
39
|
+
method: 'PUT',
|
|
40
|
+
path: UpdateSetManager.UI_UPDATESET_PATH,
|
|
41
|
+
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
|
|
42
|
+
query: null,
|
|
43
|
+
body: null,
|
|
44
|
+
json: { name: options.name, sysId: options.sysId }
|
|
45
|
+
};
|
|
46
|
+
const resp = await this._req.put(request);
|
|
47
|
+
if (resp.status !== 200) {
|
|
48
|
+
throw new Error(`Failed to set current update set. Status: ${resp.status}`);
|
|
49
|
+
}
|
|
50
|
+
this._logger.info(`Successfully set current update set to: ${options.name}`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get the current update set from the session preferences.
|
|
54
|
+
* Uses GET /api/now/ui/preferences/sys_update_set
|
|
55
|
+
*
|
|
56
|
+
* @returns The current update set record or null if not set
|
|
57
|
+
*/
|
|
58
|
+
async getCurrentUpdateSet() {
|
|
59
|
+
this._logger.info('Getting current update set');
|
|
60
|
+
const request = {
|
|
61
|
+
method: 'GET',
|
|
62
|
+
path: UpdateSetManager.UI_PREF_UPDATESET_PATH,
|
|
63
|
+
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
|
|
64
|
+
query: null,
|
|
65
|
+
body: null
|
|
66
|
+
};
|
|
67
|
+
const resp = await this._req.get(request);
|
|
68
|
+
if (resp.status === 200 && resp.bodyObject?.result) {
|
|
69
|
+
this._logger.info(`Current update set: ${resp.bodyObject.result.name}`);
|
|
70
|
+
return resp.bodyObject.result;
|
|
71
|
+
}
|
|
72
|
+
throw new Error(`Failed to get current update set. Status: ${resp.status}`);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* List update sets from the sys_update_set table.
|
|
76
|
+
* Uses Table API GET on sys_update_set.
|
|
77
|
+
*
|
|
78
|
+
* @param options Optional query, limit, and fields options
|
|
79
|
+
* @returns Array of UpdateSetRecord
|
|
80
|
+
*/
|
|
81
|
+
async listUpdateSets(options = {}) {
|
|
82
|
+
const { encodedQuery, limit = 100, fields } = options;
|
|
83
|
+
this._logger.info(`Listing update sets with query: ${encodedQuery || 'none'}`);
|
|
84
|
+
const query = {
|
|
85
|
+
sysparm_limit: limit
|
|
86
|
+
};
|
|
87
|
+
if (encodedQuery) {
|
|
88
|
+
query.sysparm_query = encodedQuery;
|
|
89
|
+
}
|
|
90
|
+
if (fields) {
|
|
91
|
+
query.sysparm_fields = fields;
|
|
92
|
+
}
|
|
93
|
+
const response = await this._tableAPI.get(UpdateSetManager.UPDATE_SET_TABLE, query);
|
|
94
|
+
if (response.status === 200 && response.bodyObject?.result) {
|
|
95
|
+
this._logger.info(`Retrieved ${response.bodyObject.result.length} update sets`);
|
|
96
|
+
return response.bodyObject.result;
|
|
97
|
+
}
|
|
98
|
+
throw new Error(`Failed to list update sets. Status: ${response.status}`);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create a new update set.
|
|
102
|
+
* Uses Table API POST on sys_update_set.
|
|
103
|
+
*
|
|
104
|
+
* @param options The update set name and optional description, application, state
|
|
105
|
+
* @returns The created UpdateSetRecord
|
|
106
|
+
* @throws Error if name is empty or if the API call fails
|
|
107
|
+
*/
|
|
108
|
+
async createUpdateSet(options) {
|
|
109
|
+
if (!options.name || options.name.trim().length === 0) {
|
|
110
|
+
throw new Error('Update set name is required');
|
|
111
|
+
}
|
|
112
|
+
this._logger.info(`Creating update set: ${options.name}`);
|
|
113
|
+
const body = {
|
|
114
|
+
name: options.name,
|
|
115
|
+
state: options.state || 'in progress'
|
|
116
|
+
};
|
|
117
|
+
if (options.description) {
|
|
118
|
+
body.description = options.description;
|
|
119
|
+
}
|
|
120
|
+
if (options.application) {
|
|
121
|
+
body.application = options.application;
|
|
122
|
+
}
|
|
123
|
+
const response = await this._tableAPI.post(UpdateSetManager.UPDATE_SET_TABLE, {}, body);
|
|
124
|
+
if (response && (response.status === 200 || response.status === 201) && response.bodyObject?.result) {
|
|
125
|
+
this._logger.info(`Created update set: ${options.name} with sys_id: ${response.bodyObject.result.sys_id}`);
|
|
126
|
+
return response.bodyObject.result;
|
|
127
|
+
}
|
|
128
|
+
throw new Error(`Failed to create update set '${options.name}'. Status: ${response?.status ?? 'unknown'}`);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Move records to a target update set.
|
|
132
|
+
* Queries sys_update_xml records based on options and updates each to the target update set.
|
|
133
|
+
*
|
|
134
|
+
* @param targetUpdateSetId The sys_id of the target update set
|
|
135
|
+
* @param options Options for selecting which records to move
|
|
136
|
+
* @returns Result summary of the move operation
|
|
137
|
+
* @throws Error if targetUpdateSetId is empty or no selection criteria provided
|
|
138
|
+
*/
|
|
139
|
+
async moveRecordsToUpdateSet(targetUpdateSetId, options = {}) {
|
|
140
|
+
if (!targetUpdateSetId || targetUpdateSetId.trim().length === 0) {
|
|
141
|
+
throw new Error('Target update set ID is required');
|
|
142
|
+
}
|
|
143
|
+
if (!options.recordSysIds && !options.timeRange && !options.sourceUpdateSet) {
|
|
144
|
+
throw new Error('At least one selection criteria is required: recordSysIds, timeRange, or sourceUpdateSet');
|
|
145
|
+
}
|
|
146
|
+
this._logger.info(`Moving records to update set: ${targetUpdateSetId}`);
|
|
147
|
+
const result = {
|
|
148
|
+
moved: 0,
|
|
149
|
+
failed: 0,
|
|
150
|
+
records: [],
|
|
151
|
+
errors: []
|
|
152
|
+
};
|
|
153
|
+
let records = [];
|
|
154
|
+
if (options.recordSysIds && options.recordSysIds.length > 0) {
|
|
155
|
+
// Fetch specific records by sys_id
|
|
156
|
+
const sysIdQuery = `sys_idIN${options.recordSysIds.join(',')}`;
|
|
157
|
+
const queryParams = {
|
|
158
|
+
sysparm_query: sysIdQuery,
|
|
159
|
+
sysparm_limit: options.recordSysIds.length
|
|
160
|
+
};
|
|
161
|
+
const resp = await this._tableAPI.get(UpdateSetManager.UPDATE_XML_TABLE, queryParams);
|
|
162
|
+
if (resp.status === 200 && resp.bodyObject?.result) {
|
|
163
|
+
records = resp.bodyObject.result;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else if (options.sourceUpdateSet) {
|
|
167
|
+
// Fetch records from a source update set
|
|
168
|
+
let encodedQuery = `update_set=${options.sourceUpdateSet}`;
|
|
169
|
+
if (options.timeRange) {
|
|
170
|
+
encodedQuery += `^sys_created_onBETWEEN${options.timeRange.start}@${options.timeRange.end}`;
|
|
171
|
+
}
|
|
172
|
+
const queryParams = {
|
|
173
|
+
sysparm_query: encodedQuery,
|
|
174
|
+
sysparm_limit: 1000
|
|
175
|
+
};
|
|
176
|
+
const resp = await this._tableAPI.get(UpdateSetManager.UPDATE_XML_TABLE, queryParams);
|
|
177
|
+
if (resp.status === 200 && resp.bodyObject?.result) {
|
|
178
|
+
records = resp.bodyObject.result;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if (options.timeRange) {
|
|
182
|
+
const encodedQuery = `sys_created_onBETWEEN${options.timeRange.start}@${options.timeRange.end}`;
|
|
183
|
+
const queryParams = {
|
|
184
|
+
sysparm_query: encodedQuery,
|
|
185
|
+
sysparm_limit: 1000
|
|
186
|
+
};
|
|
187
|
+
const resp = await this._tableAPI.get(UpdateSetManager.UPDATE_XML_TABLE, queryParams);
|
|
188
|
+
if (resp.status === 200 && resp.bodyObject?.result) {
|
|
189
|
+
records = resp.bodyObject.result;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Move each record to the target update set
|
|
193
|
+
for (const record of records) {
|
|
194
|
+
try {
|
|
195
|
+
if (options.onProgress) {
|
|
196
|
+
options.onProgress(`Moving record ${record.sys_id} (${record.name || record.type || 'unknown'})`);
|
|
197
|
+
}
|
|
198
|
+
const putResp = await this._tableAPI.put(UpdateSetManager.UPDATE_XML_TABLE, record.sys_id, { update_set: targetUpdateSetId });
|
|
199
|
+
if (putResp && (putResp.status === 200 || putResp.status === 201)) {
|
|
200
|
+
result.moved++;
|
|
201
|
+
result.records.push({
|
|
202
|
+
sys_id: record.sys_id,
|
|
203
|
+
name: record.name,
|
|
204
|
+
type: record.type,
|
|
205
|
+
status: 'moved'
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
result.failed++;
|
|
210
|
+
result.records.push({
|
|
211
|
+
sys_id: record.sys_id,
|
|
212
|
+
name: record.name,
|
|
213
|
+
type: record.type,
|
|
214
|
+
status: 'failed'
|
|
215
|
+
});
|
|
216
|
+
result.errors.push({
|
|
217
|
+
sys_id: record.sys_id,
|
|
218
|
+
error: `Unexpected status: ${putResp?.status ?? 'unknown'}`
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
catch (err) {
|
|
223
|
+
result.failed++;
|
|
224
|
+
result.records.push({
|
|
225
|
+
sys_id: record.sys_id,
|
|
226
|
+
name: record.name,
|
|
227
|
+
type: record.type,
|
|
228
|
+
status: 'failed'
|
|
229
|
+
});
|
|
230
|
+
result.errors.push({
|
|
231
|
+
sys_id: record.sys_id,
|
|
232
|
+
error: err instanceof Error ? err.message : String(err)
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
this._logger.info(`Move complete: ${result.moved} moved, ${result.failed} failed`);
|
|
237
|
+
return result;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Clone an update set by creating a new update set and copying all sys_update_xml records.
|
|
241
|
+
*
|
|
242
|
+
* @param sourceUpdateSetId The sys_id of the source update set to clone
|
|
243
|
+
* @param newName The name for the new cloned update set
|
|
244
|
+
* @param onProgress Optional callback for progress updates
|
|
245
|
+
* @returns Result of the clone operation
|
|
246
|
+
* @throws Error if sourceUpdateSetId or newName is empty
|
|
247
|
+
*/
|
|
248
|
+
async cloneUpdateSet(sourceUpdateSetId, newName, onProgress) {
|
|
249
|
+
if (!sourceUpdateSetId || sourceUpdateSetId.trim().length === 0) {
|
|
250
|
+
throw new Error('Source update set ID is required');
|
|
251
|
+
}
|
|
252
|
+
if (!newName || newName.trim().length === 0) {
|
|
253
|
+
throw new Error('New update set name is required');
|
|
254
|
+
}
|
|
255
|
+
this._logger.info(`Cloning update set ${sourceUpdateSetId} as "${newName}"`);
|
|
256
|
+
if (onProgress) {
|
|
257
|
+
onProgress('Fetching source update set...');
|
|
258
|
+
}
|
|
259
|
+
// Get the source update set
|
|
260
|
+
const sourceQuery = {
|
|
261
|
+
sysparm_query: `sys_id=${sourceUpdateSetId}`,
|
|
262
|
+
sysparm_limit: 1
|
|
263
|
+
};
|
|
264
|
+
const sourceResp = await this._tableAPI.get(UpdateSetManager.UPDATE_SET_TABLE, sourceQuery);
|
|
265
|
+
if (!sourceResp || sourceResp.status !== 200 || !sourceResp.bodyObject?.result || sourceResp.bodyObject.result.length === 0) {
|
|
266
|
+
throw new Error(`Source update set '${sourceUpdateSetId}' not found`);
|
|
267
|
+
}
|
|
268
|
+
const sourceSet = sourceResp.bodyObject.result[0];
|
|
269
|
+
if (onProgress) {
|
|
270
|
+
onProgress(`Found source update set: ${sourceSet.name}`);
|
|
271
|
+
}
|
|
272
|
+
// Create the new update set
|
|
273
|
+
const newSetBody = {
|
|
274
|
+
name: newName,
|
|
275
|
+
state: 'in progress'
|
|
276
|
+
};
|
|
277
|
+
if (sourceSet.description) {
|
|
278
|
+
newSetBody.description = sourceSet.description;
|
|
279
|
+
}
|
|
280
|
+
if (sourceSet.application) {
|
|
281
|
+
newSetBody.application = sourceSet.application;
|
|
282
|
+
}
|
|
283
|
+
const createResp = await this._tableAPI.post(UpdateSetManager.UPDATE_SET_TABLE, {}, newSetBody);
|
|
284
|
+
if (!createResp || (createResp.status !== 200 && createResp.status !== 201) || !createResp.bodyObject?.result) {
|
|
285
|
+
throw new Error(`Failed to create new update set '${newName}'. Status: ${createResp?.status ?? 'unknown'}`);
|
|
286
|
+
}
|
|
287
|
+
const newSet = createResp.bodyObject.result;
|
|
288
|
+
if (onProgress) {
|
|
289
|
+
onProgress(`Created new update set: ${newSet.name} (${newSet.sys_id})`);
|
|
290
|
+
}
|
|
291
|
+
// Get all sys_update_xml records from the source update set
|
|
292
|
+
const xmlQuery = {
|
|
293
|
+
sysparm_query: `update_set=${sourceUpdateSetId}`,
|
|
294
|
+
sysparm_limit: 10000
|
|
295
|
+
};
|
|
296
|
+
const xmlResp = await this._tableAPI.get(UpdateSetManager.UPDATE_XML_TABLE, xmlQuery);
|
|
297
|
+
const sourceRecords = (xmlResp.status === 200 && xmlResp.bodyObject?.result) ? xmlResp.bodyObject.result : [];
|
|
298
|
+
let recordsCloned = 0;
|
|
299
|
+
if (onProgress) {
|
|
300
|
+
onProgress(`Found ${sourceRecords.length} records to clone`);
|
|
301
|
+
}
|
|
302
|
+
// Clone each record into the new update set
|
|
303
|
+
for (const record of sourceRecords) {
|
|
304
|
+
try {
|
|
305
|
+
const cloneBody = {
|
|
306
|
+
update_set: newSet.sys_id,
|
|
307
|
+
name: record.name,
|
|
308
|
+
type: record.type,
|
|
309
|
+
target_name: record.target_name,
|
|
310
|
+
payload: record.payload,
|
|
311
|
+
category: record.category
|
|
312
|
+
};
|
|
313
|
+
const cloneResp = await this._tableAPI.post(UpdateSetManager.UPDATE_XML_TABLE, {}, cloneBody);
|
|
314
|
+
if (cloneResp && (cloneResp.status === 200 || cloneResp.status === 201)) {
|
|
315
|
+
recordsCloned++;
|
|
316
|
+
if (onProgress) {
|
|
317
|
+
onProgress(`Cloned record ${recordsCloned}/${sourceRecords.length}: ${record.name || record.type || 'unknown'}`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
catch (err) {
|
|
322
|
+
this._logger.error(`Failed to clone record ${record.sys_id}: ${err instanceof Error ? err.message : String(err)}`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
this._logger.info(`Clone complete: ${recordsCloned}/${sourceRecords.length} records cloned`);
|
|
326
|
+
return {
|
|
327
|
+
newUpdateSetId: newSet.sys_id,
|
|
328
|
+
newUpdateSetName: newSet.name,
|
|
329
|
+
sourceUpdateSetId: sourceUpdateSetId,
|
|
330
|
+
sourceUpdateSetName: sourceSet.name,
|
|
331
|
+
recordsCloned: recordsCloned,
|
|
332
|
+
totalSourceRecords: sourceRecords.length
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Inspect an update set by querying its sys_update_xml records and grouping by type.
|
|
337
|
+
*
|
|
338
|
+
* @param updateSetSysId The sys_id of the update set to inspect
|
|
339
|
+
* @returns Inspection result with grouped components
|
|
340
|
+
* @throws Error if updateSetSysId is empty or the update set is not found
|
|
341
|
+
*/
|
|
342
|
+
async inspectUpdateSet(updateSetSysId) {
|
|
343
|
+
if (!updateSetSysId || updateSetSysId.trim().length === 0) {
|
|
344
|
+
throw new Error('Update set sys_id is required');
|
|
345
|
+
}
|
|
346
|
+
this._logger.info(`Inspecting update set: ${updateSetSysId}`);
|
|
347
|
+
// Get the update set record
|
|
348
|
+
const setQuery = {
|
|
349
|
+
sysparm_query: `sys_id=${updateSetSysId}`,
|
|
350
|
+
sysparm_limit: 1
|
|
351
|
+
};
|
|
352
|
+
const setResp = await this._tableAPI.get(UpdateSetManager.UPDATE_SET_TABLE, setQuery);
|
|
353
|
+
if (!setResp || setResp.status !== 200 || !setResp.bodyObject?.result || setResp.bodyObject.result.length === 0) {
|
|
354
|
+
throw new Error(`Update set '${updateSetSysId}' not found`);
|
|
355
|
+
}
|
|
356
|
+
const updateSet = setResp.bodyObject.result[0];
|
|
357
|
+
// Get all sys_update_xml records for this update set
|
|
358
|
+
const xmlQuery = {
|
|
359
|
+
sysparm_query: `update_set=${updateSetSysId}`,
|
|
360
|
+
sysparm_limit: 10000
|
|
361
|
+
};
|
|
362
|
+
const xmlResp = await this._tableAPI.get(UpdateSetManager.UPDATE_XML_TABLE, xmlQuery);
|
|
363
|
+
const records = (xmlResp.status === 200 && xmlResp.bodyObject?.result) ? xmlResp.bodyObject.result : [];
|
|
364
|
+
// Group records by type
|
|
365
|
+
const typeGroups = new Map();
|
|
366
|
+
for (const record of records) {
|
|
367
|
+
const type = record.type || 'unknown';
|
|
368
|
+
if (!typeGroups.has(type)) {
|
|
369
|
+
typeGroups.set(type, []);
|
|
370
|
+
}
|
|
371
|
+
typeGroups.get(type).push(record.target_name || record.name || record.sys_id);
|
|
372
|
+
}
|
|
373
|
+
const components = Array.from(typeGroups.entries()).map(([type, items]) => ({
|
|
374
|
+
type,
|
|
375
|
+
count: items.length,
|
|
376
|
+
items
|
|
377
|
+
}));
|
|
378
|
+
this._logger.info(`Inspection complete: ${records.length} records in ${components.length} component types`);
|
|
379
|
+
return {
|
|
380
|
+
updateSet: {
|
|
381
|
+
sys_id: updateSet.sys_id,
|
|
382
|
+
name: updateSet.name,
|
|
383
|
+
state: updateSet.state,
|
|
384
|
+
description: updateSet.description
|
|
385
|
+
},
|
|
386
|
+
totalRecords: records.length,
|
|
387
|
+
components
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
//# sourceMappingURL=UpdateSetManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdateSetManager.js","sourceRoot":"","sources":["../../../src/sn/updateset/UpdateSetManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAmBlE;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IACjB,MAAM,CAAU,iBAAiB,GAAG,uCAAuC,CAAC;IAC5E,MAAM,CAAU,sBAAsB,GAAG,wCAAwC,CAAC;IAClF,MAAM,CAAU,gBAAgB,GAAG,gBAAgB,CAAC;IACpD,MAAM,CAAU,gBAAgB,GAAG,gBAAgB,CAAC;IAEpD,OAAO,GAAW,IAAI,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACjD,IAAI,CAAoB;IACxB,SAAS,CAAkB;IAC3B,SAAS,CAAqB;IAEtC,YAAmB,QAA4B;QAC3C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,C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,MAAM;gBACxB,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,WAAW,EAAE,SAAS,CAAC,WAAW;aACrC;YACD,YAAY,EAAE,OAAO,CAAC,MAAM;YAC5B,UAAU;SACb,CAAC;IACN,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A record from the sys_update_set table.
|
|
3
|
+
*/
|
|
4
|
+
export interface UpdateSetRecord {
|
|
5
|
+
/** System ID */
|
|
6
|
+
sys_id: string;
|
|
7
|
+
/** Name of the update set */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Description of the update set */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** State of the update set (e.g., "in progress", "complete") */
|
|
12
|
+
state: string;
|
|
13
|
+
/** Application scope reference */
|
|
14
|
+
application?: string;
|
|
15
|
+
/** Created timestamp */
|
|
16
|
+
sys_created_on?: string;
|
|
17
|
+
/** Updated timestamp */
|
|
18
|
+
sys_updated_on?: string;
|
|
19
|
+
/** Created by user */
|
|
20
|
+
sys_created_by?: string;
|
|
21
|
+
/** Additional fields */
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A record from the sys_update_xml table.
|
|
26
|
+
*/
|
|
27
|
+
export interface UpdateXmlRecord {
|
|
28
|
+
/** System ID */
|
|
29
|
+
sys_id: string;
|
|
30
|
+
/** Name of the update XML record */
|
|
31
|
+
name?: string;
|
|
32
|
+
/** Type of the record (e.g., "sys_script_include") */
|
|
33
|
+
type?: string;
|
|
34
|
+
/** Target name of the record */
|
|
35
|
+
target_name?: string;
|
|
36
|
+
/** Reference to the parent update set */
|
|
37
|
+
update_set: string;
|
|
38
|
+
/** XML payload */
|
|
39
|
+
payload?: string;
|
|
40
|
+
/** Category of the update */
|
|
41
|
+
category?: string;
|
|
42
|
+
/** Created timestamp */
|
|
43
|
+
sys_created_on?: string;
|
|
44
|
+
/** Additional fields */
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Options for setting the current update set.
|
|
49
|
+
*/
|
|
50
|
+
export interface SetUpdateSetOptions {
|
|
51
|
+
/** Name of the update set */
|
|
52
|
+
name: string;
|
|
53
|
+
/** sys_id of the update set */
|
|
54
|
+
sysId: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Options for listing update sets.
|
|
58
|
+
*/
|
|
59
|
+
export interface ListUpdateSetsOptions {
|
|
60
|
+
/** Encoded query string for filtering */
|
|
61
|
+
encodedQuery?: string;
|
|
62
|
+
/** Maximum number of records to return */
|
|
63
|
+
limit?: number;
|
|
64
|
+
/** Comma-separated list of fields to return */
|
|
65
|
+
fields?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Options for creating a new update set.
|
|
69
|
+
*/
|
|
70
|
+
export interface CreateUpdateSetOptions {
|
|
71
|
+
/** Name of the update set */
|
|
72
|
+
name: string;
|
|
73
|
+
/** Description of the update set */
|
|
74
|
+
description?: string;
|
|
75
|
+
/** Application scope sys_id */
|
|
76
|
+
application?: string;
|
|
77
|
+
/** State of the update set (defaults to "in progress") */
|
|
78
|
+
state?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Options for moving records between update sets.
|
|
82
|
+
*/
|
|
83
|
+
export interface MoveRecordsOptions {
|
|
84
|
+
/** Specific record sys_ids to move */
|
|
85
|
+
recordSysIds?: string[];
|
|
86
|
+
/** Time range to select records */
|
|
87
|
+
timeRange?: {
|
|
88
|
+
start: string;
|
|
89
|
+
end: string;
|
|
90
|
+
};
|
|
91
|
+
/** Source update set sys_id to move records from */
|
|
92
|
+
sourceUpdateSet?: string;
|
|
93
|
+
/** Callback for progress updates */
|
|
94
|
+
onProgress?: (message: string) => void;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Result of moving records between update sets.
|
|
98
|
+
*/
|
|
99
|
+
export interface MoveRecordsResult {
|
|
100
|
+
/** Number of records successfully moved */
|
|
101
|
+
moved: number;
|
|
102
|
+
/** Number of records that failed to move */
|
|
103
|
+
failed: number;
|
|
104
|
+
/** Details of each record processed */
|
|
105
|
+
records: Array<{
|
|
106
|
+
sys_id: string;
|
|
107
|
+
name?: string;
|
|
108
|
+
type?: string;
|
|
109
|
+
status: string;
|
|
110
|
+
}>;
|
|
111
|
+
/** Details of errors encountered */
|
|
112
|
+
errors: Array<{
|
|
113
|
+
sys_id: string;
|
|
114
|
+
error: string;
|
|
115
|
+
}>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Result of cloning an update set.
|
|
119
|
+
*/
|
|
120
|
+
export interface CloneUpdateSetResult {
|
|
121
|
+
/** sys_id of the newly created update set */
|
|
122
|
+
newUpdateSetId: string;
|
|
123
|
+
/** Name of the newly created update set */
|
|
124
|
+
newUpdateSetName: string;
|
|
125
|
+
/** sys_id of the source update set */
|
|
126
|
+
sourceUpdateSetId: string;
|
|
127
|
+
/** Name of the source update set */
|
|
128
|
+
sourceUpdateSetName: string;
|
|
129
|
+
/** Number of records cloned */
|
|
130
|
+
recordsCloned: number;
|
|
131
|
+
/** Total number of records in the source update set */
|
|
132
|
+
totalSourceRecords: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Result of inspecting an update set.
|
|
136
|
+
*/
|
|
137
|
+
export interface InspectUpdateSetResult {
|
|
138
|
+
/** The update set record */
|
|
139
|
+
updateSet: {
|
|
140
|
+
sys_id: string;
|
|
141
|
+
name: string;
|
|
142
|
+
state: string;
|
|
143
|
+
description?: string;
|
|
144
|
+
};
|
|
145
|
+
/** Total number of records in the update set */
|
|
146
|
+
totalRecords: number;
|
|
147
|
+
/** Components grouped by type */
|
|
148
|
+
components: Array<{
|
|
149
|
+
type: string;
|
|
150
|
+
count: number;
|
|
151
|
+
items: string[];
|
|
152
|
+
}>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Response wrapper for multiple update set records.
|
|
156
|
+
*/
|
|
157
|
+
export interface UpdateSetResponse {
|
|
158
|
+
result: UpdateSetRecord[];
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Response wrapper for a single update set record.
|
|
162
|
+
*/
|
|
163
|
+
export interface UpdateSetSingleResponse {
|
|
164
|
+
result: UpdateSetRecord;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Response wrapper for multiple update XML records.
|
|
168
|
+
*/
|
|
169
|
+
export interface UpdateXmlResponse {
|
|
170
|
+
result: UpdateXmlRecord[];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Response wrapper for a single update XML record.
|
|
174
|
+
*/
|
|
175
|
+
export interface UpdateXmlSingleResponse {
|
|
176
|
+
result: UpdateXmlRecord;
|
|
177
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdateSetModels.js","sourceRoot":"","sources":["../../../src/sn/updateset/UpdateSetModels.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,0BAA0B;AAC1B,+DAA+D"}
|