@sonisoft/now-sdk-ext-core 3.0.1 → 3.3.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.
@@ -0,0 +1,352 @@
1
+ import { Logger } from "../../util/Logger.js";
2
+ import { ServiceNowRequest } from "../../comm/http/ServiceNowRequest.js";
3
+ import { TableAPIRequest } from "../../comm/http/TableAPIRequest.js";
4
+ import { AggregateQuery } from "../aggregate/AggregateQuery.js";
5
+ /**
6
+ * Mapping of numeric variable type codes to friendly names.
7
+ * Sourced from a ServiceNow instance with sysparm_display_value: 'all'.
8
+ */
9
+ export const VARIABLE_TYPE_MAP = {
10
+ '1': 'Yes/No',
11
+ '2': 'Multi Line Text',
12
+ '3': 'Multiple Choice',
13
+ '4': 'Numeric Scale',
14
+ '5': 'Select Box',
15
+ '6': 'Single Line Text',
16
+ '7': 'CheckBox',
17
+ '8': 'Reference',
18
+ '9': 'Date',
19
+ '10': 'Date/Time',
20
+ '11': 'Label',
21
+ '14': 'Custom',
22
+ '16': 'Wide Single Line Text',
23
+ '17': 'Custom with Label',
24
+ '18': 'Lookup Select Box',
25
+ '19': 'Container Start',
26
+ '20': 'Container End',
27
+ '21': 'List Collector',
28
+ '23': 'HTML',
29
+ '24': 'Container Split',
30
+ '26': 'Email',
31
+ '28': 'IP Address',
32
+ '29': 'Duration',
33
+ '31': 'Requested For',
34
+ '32': 'Rich Text Label',
35
+ '33': 'Attachment',
36
+ '40': 'Table Name'
37
+ };
38
+ /**
39
+ * Get a human-readable variable type name from a numeric type code.
40
+ *
41
+ * @param typeCode The numeric type code (as a string)
42
+ * @returns The friendly type name, or "Unknown ({typeCode})" if not mapped
43
+ */
44
+ export function getVariableTypeName(typeCode) {
45
+ if (!typeCode)
46
+ return 'Unknown';
47
+ return VARIABLE_TYPE_MAP[typeCode] || `Unknown (${typeCode})`;
48
+ }
49
+ /**
50
+ * Provides operations for managing ServiceNow Service Catalog items,
51
+ * categories, variables, and request submissions via the Table API,
52
+ * Stats API, and Service Catalog REST API.
53
+ */
54
+ export class CatalogManager {
55
+ static CATALOG_ITEM_TABLE = 'sc_cat_item';
56
+ static CATEGORY_TABLE = 'sc_category';
57
+ static VARIABLE_TABLE = 'item_option_new';
58
+ static VARIABLE_SET_ITEM_TABLE = 'io_set_item';
59
+ static REQUEST_ITEM_TABLE = 'sc_req_item';
60
+ static ORDER_NOW_API = '/api/sn_sc/servicecatalog/items/{sys_id}/order_now';
61
+ /** Fields to return for catalog item list operations */
62
+ static ITEM_LIST_FIELDS = 'sys_id,name,short_description,description,category,price,active,order,sys_scope,sc_catalogs,type';
63
+ /** Fields to return for category list operations */
64
+ static CATEGORY_LIST_FIELDS = 'sys_id,title,description,parent,sc_catalog,active,order,icon,header_icon';
65
+ /** Fields to return for variable list operations */
66
+ static VARIABLE_LIST_FIELDS = 'sys_id,name,question_text,type,mandatory,default_value,help_text,order,reference,reference_qual,choice_table,choice_field,cat_item,variable_set';
67
+ _logger = new Logger("CatalogManager");
68
+ _req;
69
+ _tableAPI;
70
+ _aggregateQuery;
71
+ _instance;
72
+ _headers = {
73
+ "Content-Type": "application/json",
74
+ "Accept": "application/json"
75
+ };
76
+ constructor(instance) {
77
+ this._instance = instance;
78
+ this._req = new ServiceNowRequest(instance);
79
+ this._tableAPI = new TableAPIRequest(instance);
80
+ this._aggregateQuery = new AggregateQuery(instance);
81
+ }
82
+ /**
83
+ * List catalog items with optional filtering and pagination.
84
+ *
85
+ * @param options Filtering and pagination options
86
+ * @returns Array of catalog item records
87
+ * @throws Error if the API call fails
88
+ */
89
+ async listCatalogItems(options = {}) {
90
+ const { query, textSearch, categorySysId, catalogSysId, active, limit = 20, offset = 0 } = options;
91
+ this._logger.info('Listing catalog items');
92
+ const queryParts = [];
93
+ if (active !== undefined)
94
+ queryParts.push(`active=${active}`);
95
+ if (categorySysId)
96
+ queryParts.push(`category=${categorySysId}`);
97
+ if (catalogSysId)
98
+ queryParts.push(`sc_catalogs=${catalogSysId}`);
99
+ if (textSearch)
100
+ queryParts.push(`nameLIKE${textSearch}^ORshort_descriptionLIKE${textSearch}`);
101
+ if (query)
102
+ queryParts.push(query);
103
+ const params = {
104
+ sysparm_limit: limit,
105
+ sysparm_offset: offset,
106
+ sysparm_fields: CatalogManager.ITEM_LIST_FIELDS
107
+ };
108
+ if (queryParts.length > 0) {
109
+ params.sysparm_query = queryParts.join('^');
110
+ }
111
+ const response = await this._tableAPI.get(CatalogManager.CATALOG_ITEM_TABLE, params);
112
+ if (response && response.status === 200 && response.bodyObject?.result) {
113
+ this._logger.info(`Retrieved ${response.bodyObject.result.length} catalog items`);
114
+ return response.bodyObject.result;
115
+ }
116
+ throw new Error(`Failed to list catalog items. Status: ${response?.status ?? 'unknown'}`);
117
+ }
118
+ /**
119
+ * Get details of a specific catalog item, optionally including its variables.
120
+ *
121
+ * @param sysId The sys_id of the catalog item
122
+ * @param includeVariables Whether to include variables (default true)
123
+ * @returns Catalog item detail with item record and variables
124
+ * @throws Error if the sys_id is empty, the item is not found, or the API call fails
125
+ */
126
+ async getCatalogItem(sysId, includeVariables = true) {
127
+ if (!sysId || sysId.trim().length === 0) {
128
+ throw new Error('Catalog item sys_id is required');
129
+ }
130
+ this._logger.info(`Getting catalog item: ${sysId}`);
131
+ const response = await this._tableAPI.get(CatalogManager.CATALOG_ITEM_TABLE, { sysparm_query: `sys_id=${sysId}`, sysparm_limit: 1 });
132
+ if (!response || response.status !== 200 || !response.bodyObject?.result ||
133
+ response.bodyObject.result.length === 0) {
134
+ throw new Error(`Catalog item '${sysId}' not found. Status: ${response?.status ?? 'unknown'}`);
135
+ }
136
+ const item = response.bodyObject.result[0];
137
+ let variables = [];
138
+ if (includeVariables) {
139
+ variables = await this._fetchAllVariables(sysId);
140
+ }
141
+ this._logger.info(`Catalog item '${item.name}': ${variables.length} variables`);
142
+ return { item, variables };
143
+ }
144
+ /**
145
+ * List catalog categories with optional filtering and pagination.
146
+ *
147
+ * @param options Filtering and pagination options
148
+ * @returns Array of catalog category records
149
+ * @throws Error if the API call fails
150
+ */
151
+ async listCatalogCategories(options = {}) {
152
+ const { parentSysId, catalogSysId, active, title, query, limit = 20, offset = 0 } = options;
153
+ this._logger.info('Listing catalog categories');
154
+ const queryParts = [];
155
+ if (parentSysId)
156
+ queryParts.push(`parent=${parentSysId}`);
157
+ if (catalogSysId)
158
+ queryParts.push(`sc_catalog=${catalogSysId}`);
159
+ if (active !== undefined)
160
+ queryParts.push(`active=${active}`);
161
+ if (title)
162
+ queryParts.push(`title=${title}`);
163
+ if (query)
164
+ queryParts.push(query);
165
+ const params = {
166
+ sysparm_limit: limit,
167
+ sysparm_offset: offset,
168
+ sysparm_fields: CatalogManager.CATEGORY_LIST_FIELDS
169
+ };
170
+ if (queryParts.length > 0) {
171
+ params.sysparm_query = queryParts.join('^');
172
+ }
173
+ const response = await this._tableAPI.get(CatalogManager.CATEGORY_TABLE, params);
174
+ if (response && response.status === 200 && response.bodyObject?.result) {
175
+ this._logger.info(`Retrieved ${response.bodyObject.result.length} catalog categories`);
176
+ return response.bodyObject.result;
177
+ }
178
+ throw new Error(`Failed to list catalog categories. Status: ${response?.status ?? 'unknown'}`);
179
+ }
180
+ /**
181
+ * Get details of a specific catalog category including its item count.
182
+ *
183
+ * @param sysId The sys_id of the catalog category
184
+ * @returns Category detail with category record and item count
185
+ * @throws Error if the sys_id is empty, the category is not found, or the API call fails
186
+ */
187
+ async getCatalogCategory(sysId) {
188
+ if (!sysId || sysId.trim().length === 0) {
189
+ throw new Error('Catalog category sys_id is required');
190
+ }
191
+ this._logger.info(`Getting catalog category: ${sysId}`);
192
+ const response = await this._tableAPI.get(CatalogManager.CATEGORY_TABLE, {
193
+ sysparm_query: `sys_id=${sysId}`,
194
+ sysparm_limit: 1,
195
+ sysparm_fields: CatalogManager.CATEGORY_LIST_FIELDS
196
+ });
197
+ if (!response || response.status !== 200 || !response.bodyObject?.result ||
198
+ response.bodyObject.result.length === 0) {
199
+ throw new Error(`Catalog category '${sysId}' not found. Status: ${response?.status ?? 'unknown'}`);
200
+ }
201
+ const category = response.bodyObject.result[0];
202
+ const itemCount = await this._aggregateQuery.count({
203
+ table: CatalogManager.CATALOG_ITEM_TABLE,
204
+ query: `category=${sysId}`
205
+ });
206
+ this._logger.info(`Category '${category.title}': ${itemCount} items`);
207
+ return { category, itemCount };
208
+ }
209
+ /**
210
+ * List variables for a catalog item, including variables from variable sets.
211
+ *
212
+ * @param options Options including the catalog item sys_id
213
+ * @returns Array of catalog variable records sorted by order
214
+ * @throws Error if the catalog item sys_id is empty or the API call fails
215
+ */
216
+ async listCatalogItemVariables(options) {
217
+ if (!options.catalogItemSysId || options.catalogItemSysId.trim().length === 0) {
218
+ throw new Error('Catalog item sys_id is required');
219
+ }
220
+ this._logger.info(`Listing variables for catalog item: ${options.catalogItemSysId}`);
221
+ const includeVariableSets = options.includeVariableSets !== false;
222
+ const variables = includeVariableSets
223
+ ? await this._fetchAllVariables(options.catalogItemSysId)
224
+ : await this._fetchDirectVariables(options.catalogItemSysId);
225
+ this._logger.info(`Retrieved ${variables.length} variables for item ${options.catalogItemSysId}`);
226
+ return variables;
227
+ }
228
+ /**
229
+ * Submit a catalog request using the Service Catalog order_now API.
230
+ * After ordering, fetches the RITM record for the complete result.
231
+ *
232
+ * @param options Request submission options
233
+ * @returns Request result with REQ and RITM numbers/sys_ids
234
+ * @throws Error if the catalog item sys_id is empty or the API call fails
235
+ */
236
+ async submitCatalogRequest(options) {
237
+ if (!options.catalogItemSysId || options.catalogItemSysId.trim().length === 0) {
238
+ throw new Error('Catalog item sys_id is required');
239
+ }
240
+ this._logger.info(`Submitting catalog request for item: ${options.catalogItemSysId}`);
241
+ const orderBody = {
242
+ sysparm_quantity: options.quantity || 1,
243
+ variables: options.variables || {}
244
+ };
245
+ const orderUrl = CatalogManager.ORDER_NOW_API.replace('{sys_id}', options.catalogItemSysId);
246
+ const request = {
247
+ path: orderUrl,
248
+ method: 'post',
249
+ headers: this._headers,
250
+ query: null,
251
+ body: null,
252
+ json: orderBody
253
+ };
254
+ const orderResponse = await this._req.executeRequest(request);
255
+ if (!orderResponse || orderResponse.status !== 200 || !orderResponse.bodyObject?.result) {
256
+ throw new Error(`Failed to submit catalog request. Status: ${orderResponse?.status ?? 'unknown'}`);
257
+ }
258
+ const orderResult = orderResponse.bodyObject.result;
259
+ const result = {
260
+ requestNumber: orderResult.request_number || orderResult.number,
261
+ requestSysId: orderResult.request_id || orderResult.sys_id
262
+ };
263
+ // Fetch the RITM record
264
+ try {
265
+ const ritmResponse = await this._tableAPI.get(CatalogManager.REQUEST_ITEM_TABLE, {
266
+ sysparm_query: `request=${result.requestSysId}`,
267
+ sysparm_fields: 'sys_id,number',
268
+ sysparm_limit: 1
269
+ });
270
+ if (ritmResponse && ritmResponse.status === 200 &&
271
+ ritmResponse.bodyObject?.result && ritmResponse.bodyObject.result.length > 0) {
272
+ const ritm = ritmResponse.bodyObject.result[0];
273
+ result.requestItemNumber = ritm.number;
274
+ result.requestItemSysId = ritm.sys_id;
275
+ this._logger.info(`Catalog request submitted: ${result.requestNumber} / ${result.requestItemNumber}`);
276
+ }
277
+ else {
278
+ this._logger.info(`Catalog request submitted: ${result.requestNumber} (RITM not yet available)`);
279
+ }
280
+ }
281
+ catch (err) {
282
+ // RITM fetch is best-effort; log but don't fail the overall request
283
+ this._logger.info(`Catalog request submitted: ${result.requestNumber} (RITM fetch failed)`);
284
+ }
285
+ return result;
286
+ }
287
+ /**
288
+ * Fetch all variables for a catalog item: direct variables + variable set variables.
289
+ * Merges, deduplicates by sys_id, enriches with friendly_type, and sorts by order.
290
+ * @private
291
+ */
292
+ async _fetchAllVariables(catalogItemSysId) {
293
+ // Fetch direct variables and variable set IDs in parallel
294
+ const [directVars, setItemResponse] = await Promise.all([
295
+ this._fetchDirectVariables(catalogItemSysId),
296
+ this._tableAPI.get(CatalogManager.VARIABLE_SET_ITEM_TABLE, {
297
+ sysparm_query: `sc_cat_item=${catalogItemSysId}`,
298
+ sysparm_fields: 'sys_id,sc_cat_item,variable_set'
299
+ })
300
+ ]);
301
+ let setVars = [];
302
+ if (setItemResponse && setItemResponse.status === 200 &&
303
+ setItemResponse.bodyObject?.result && setItemResponse.bodyObject.result.length > 0) {
304
+ const setIds = setItemResponse.bodyObject.result.map(r => r.variable_set).filter(Boolean);
305
+ if (setIds.length > 0) {
306
+ const setQuery = `variable_setIN${setIds.join(',')}`;
307
+ const setVarsResponse = await this._tableAPI.get(CatalogManager.VARIABLE_TABLE, {
308
+ sysparm_query: setQuery,
309
+ sysparm_fields: CatalogManager.VARIABLE_LIST_FIELDS
310
+ });
311
+ if (setVarsResponse && setVarsResponse.status === 200 && setVarsResponse.bodyObject?.result) {
312
+ setVars = setVarsResponse.bodyObject.result;
313
+ }
314
+ }
315
+ }
316
+ // Merge, deduplicate by sys_id, enrich, and sort
317
+ const allVars = [...directVars, ...setVars];
318
+ const seen = new Set();
319
+ const deduped = [];
320
+ for (const v of allVars) {
321
+ if (!seen.has(v.sys_id)) {
322
+ seen.add(v.sys_id);
323
+ v.friendly_type = getVariableTypeName(v.type);
324
+ deduped.push(v);
325
+ }
326
+ }
327
+ deduped.sort((a, b) => {
328
+ const orderA = parseInt(a.order || '0', 10);
329
+ const orderB = parseInt(b.order || '0', 10);
330
+ return orderA - orderB;
331
+ });
332
+ return deduped;
333
+ }
334
+ /**
335
+ * Fetch variables directly assigned to a catalog item (cat_item field).
336
+ * @private
337
+ */
338
+ async _fetchDirectVariables(catalogItemSysId) {
339
+ const response = await this._tableAPI.get(CatalogManager.VARIABLE_TABLE, {
340
+ sysparm_query: `cat_item=${catalogItemSysId}^ORDERBYorder`,
341
+ sysparm_fields: CatalogManager.VARIABLE_LIST_FIELDS
342
+ });
343
+ if (response && response.status === 200 && response.bodyObject?.result) {
344
+ return response.bodyObject.result.map(v => ({
345
+ ...v,
346
+ friendly_type: getVariableTypeName(v.type)
347
+ }));
348
+ }
349
+ return [];
350
+ }
351
+ }
352
+ //# sourceMappingURL=CatalogManager.js.map
@@ -0,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AC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAClB,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC;YAC5C,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC;YAC5C,OAAO,MAAM,GAAG,MAAM,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,qBAAqB,CAAC,gBAAwB;QACxD,MAAM,QAAQ,GAA2C,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAC7E,cAAc,CAAC,cAAc,EAC7B;YACI,aAAa,EAAE,YAAY,gBAAgB,eAAe;YAC1D,cAAc,EAAE,cAAc,CAAC,oBAAoB;SACtD,CACJ,CAAC;QAEF,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;YACrE,OAAO,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACxC,GAAG,CAAC;gBACJ,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC;aAC7C,CAAC,CAAC,CAAC;QACR,CAAC;QAED,OAAO,EAAE,CAAC;IACd,CAAC"}
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Models for Service Catalog management operations against ServiceNow tables:
3
+ * sc_cat_item, sc_category, and item_option_new.
4
+ */
5
+ /**
6
+ * A catalog item record from the sc_cat_item table.
7
+ */
8
+ export interface CatalogItemRecord {
9
+ sys_id: string;
10
+ name: string;
11
+ short_description?: string;
12
+ description?: string;
13
+ category?: string;
14
+ price?: string;
15
+ active?: string;
16
+ order?: string;
17
+ sys_scope?: string;
18
+ sc_catalogs?: string;
19
+ type?: string;
20
+ [key: string]: unknown;
21
+ }
22
+ /**
23
+ * A catalog category record from the sc_category table.
24
+ */
25
+ export interface CatalogCategoryRecord {
26
+ sys_id: string;
27
+ title: string;
28
+ description?: string;
29
+ parent?: string;
30
+ sc_catalog?: string;
31
+ active?: string;
32
+ order?: string;
33
+ icon?: string;
34
+ header_icon?: string;
35
+ [key: string]: unknown;
36
+ }
37
+ /**
38
+ * A catalog variable record from the item_option_new table.
39
+ * Includes an enriched friendly_type field mapped from the numeric type code.
40
+ */
41
+ export interface CatalogVariableRecord {
42
+ sys_id: string;
43
+ name: string;
44
+ question_text?: string;
45
+ type?: string;
46
+ mandatory?: string;
47
+ default_value?: string;
48
+ help_text?: string;
49
+ order?: string;
50
+ reference?: string;
51
+ reference_qual?: string;
52
+ choice_table?: string;
53
+ choice_field?: string;
54
+ cat_item?: string;
55
+ variable_set?: string;
56
+ /** Human-readable variable type name mapped from the numeric type code */
57
+ friendly_type?: string;
58
+ [key: string]: unknown;
59
+ }
60
+ /**
61
+ * A record from the io_set_item table linking variable sets to catalog items.
62
+ */
63
+ export interface VariableSetItemRecord {
64
+ sys_id: string;
65
+ sc_cat_item: string;
66
+ variable_set: string;
67
+ [key: string]: unknown;
68
+ }
69
+ /**
70
+ * Options for listing catalog items.
71
+ */
72
+ export interface ListCatalogItemsOptions {
73
+ /** Encoded query string for filtering */
74
+ query?: string;
75
+ /** Text search term (searches name and short_description) */
76
+ textSearch?: string;
77
+ /** Filter by category sys_id */
78
+ categorySysId?: string;
79
+ /** Filter by catalog sys_id */
80
+ catalogSysId?: string;
81
+ /** Filter by active status */
82
+ active?: boolean;
83
+ /** Maximum number of records to return (default 20) */
84
+ limit?: number;
85
+ /** Offset for pagination (default 0) */
86
+ offset?: number;
87
+ }
88
+ /**
89
+ * Options for listing catalog categories.
90
+ */
91
+ export interface ListCatalogCategoriesOptions {
92
+ /** Filter by parent category sys_id */
93
+ parentSysId?: string;
94
+ /** Filter by catalog sys_id */
95
+ catalogSysId?: string;
96
+ /** Filter by active status */
97
+ active?: boolean;
98
+ /** Filter by title (exact match) */
99
+ title?: string;
100
+ /** Encoded query string for additional filtering */
101
+ query?: string;
102
+ /** Maximum number of records (default 20) */
103
+ limit?: number;
104
+ /** Offset for pagination (default 0) */
105
+ offset?: number;
106
+ }
107
+ /**
108
+ * Options for listing catalog item variables.
109
+ */
110
+ export interface ListCatalogVariablesOptions {
111
+ /** The catalog item sys_id (required) */
112
+ catalogItemSysId: string;
113
+ /** Include variables from variable sets (default true) */
114
+ includeVariableSets?: boolean;
115
+ }
116
+ /**
117
+ * Options for submitting a catalog request via order_now.
118
+ */
119
+ export interface SubmitCatalogRequestOptions {
120
+ /** The catalog item sys_id (required) */
121
+ catalogItemSysId: string;
122
+ /** Quantity to order (default 1) */
123
+ quantity?: number;
124
+ /** Variable name-value pairs */
125
+ variables?: Record<string, string>;
126
+ }
127
+ /**
128
+ * Enriched catalog item detail including its variables.
129
+ */
130
+ export interface CatalogItemDetail {
131
+ item: CatalogItemRecord;
132
+ variables: CatalogVariableRecord[];
133
+ }
134
+ /**
135
+ * Enriched catalog category detail including item count.
136
+ */
137
+ export interface CatalogCategoryDetail {
138
+ category: CatalogCategoryRecord;
139
+ itemCount: number;
140
+ }
141
+ /**
142
+ * Result from submitting a catalog request, including both REQ and RITM.
143
+ */
144
+ export interface CatalogRequestResult {
145
+ requestNumber: string;
146
+ requestSysId: string;
147
+ requestItemNumber?: string;
148
+ requestItemSysId?: string;
149
+ }
150
+ export interface CatalogItemResponse {
151
+ result: CatalogItemRecord[];
152
+ }
153
+ export interface CatalogCategoryResponse {
154
+ result: CatalogCategoryRecord[];
155
+ }
156
+ export interface CatalogVariableResponse {
157
+ result: CatalogVariableRecord[];
158
+ }
159
+ export interface VariableSetItemResponse {
160
+ result: VariableSetItemRecord[];
161
+ }
162
+ export interface CatalogOrderResponse {
163
+ result: {
164
+ sys_id: string;
165
+ number: string;
166
+ request_number: string;
167
+ request_id: string;
168
+ table: string;
169
+ };
170
+ }
171
+ export interface RequestItemResponse {
172
+ result: Array<{
173
+ sys_id: string;
174
+ number: string;
175
+ [key: string]: unknown;
176
+ }>;
177
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Models for Service Catalog management operations against ServiceNow tables:
3
+ * sc_cat_item, sc_category, and item_option_new.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=CatalogModels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatalogModels.js","sourceRoot":"","sources":["../../../src/sn/catalog/CatalogModels.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,93 @@
1
+ import { ServiceNowInstance } from "../ServiceNowInstance.js";
2
+ import { KnowledgeBaseRecord, KnowledgeBaseDetail, KnowledgeCategoryRecord, KnowledgeArticleRecord, KnowledgeArticleSummary, ListKnowledgeBasesOptions, ListCategoriesOptions, CreateCategoryOptions, ListArticlesOptions, CreateArticleOptions, UpdateArticleOptions } from './KnowledgeModels.js';
3
+ /**
4
+ * Provides operations for managing ServiceNow Knowledge Base articles,
5
+ * knowledge bases, and categories via the Table API and Stats API.
6
+ */
7
+ export declare class KnowledgeManager {
8
+ private static readonly KB_BASE_TABLE;
9
+ private static readonly KB_CATEGORY_TABLE;
10
+ private static readonly KB_KNOWLEDGE_TABLE;
11
+ /** Fields to return in list operations (excludes large body fields) */
12
+ private static readonly ARTICLE_LIST_FIELDS;
13
+ private _logger;
14
+ private _req;
15
+ private _tableAPI;
16
+ private _aggregateQuery;
17
+ private _instance;
18
+ constructor(instance: ServiceNowInstance);
19
+ /**
20
+ * List knowledge bases with optional filtering and pagination.
21
+ *
22
+ * @param options Filtering and pagination options
23
+ * @returns Array of knowledge base records
24
+ * @throws Error if the API call fails
25
+ */
26
+ listKnowledgeBases(options?: ListKnowledgeBasesOptions): Promise<KnowledgeBaseRecord[]>;
27
+ /**
28
+ * Get details of a specific knowledge base including article and category counts.
29
+ *
30
+ * @param sysId The sys_id of the knowledge base
31
+ * @returns Knowledge base detail with article and category counts
32
+ * @throws Error if the sys_id is empty, the KB is not found, or the API call fails
33
+ */
34
+ getKnowledgeBase(sysId: string): Promise<KnowledgeBaseDetail>;
35
+ /**
36
+ * List categories within a knowledge base with optional filtering.
37
+ *
38
+ * @param options Filtering and pagination options
39
+ * @returns Array of category records
40
+ * @throws Error if the API call fails
41
+ */
42
+ listCategories(options?: ListCategoriesOptions): Promise<KnowledgeCategoryRecord[]>;
43
+ /**
44
+ * Create a new knowledge base category.
45
+ *
46
+ * @param options Category creation options
47
+ * @returns The created category record
48
+ * @throws Error if required fields are missing or the API call fails
49
+ */
50
+ createCategory(options: CreateCategoryOptions): Promise<KnowledgeCategoryRecord>;
51
+ /**
52
+ * List knowledge articles with filtering by KB, category, workflow state, and text search.
53
+ * Returns article summaries (without large body fields) for efficiency.
54
+ *
55
+ * @param options Filtering and pagination options
56
+ * @returns Array of article summaries
57
+ * @throws Error if the API call fails
58
+ */
59
+ listArticles(options?: ListArticlesOptions): Promise<KnowledgeArticleSummary[]>;
60
+ /**
61
+ * Get full article content including body text.
62
+ *
63
+ * @param sysId The sys_id of the article
64
+ * @returns The full article record
65
+ * @throws Error if the sys_id is empty, the article is not found, or the API call fails
66
+ */
67
+ getArticle(sysId: string): Promise<KnowledgeArticleRecord>;
68
+ /**
69
+ * Create a new knowledge article.
70
+ *
71
+ * @param options Article creation options
72
+ * @returns The created article record
73
+ * @throws Error if required fields are missing or the API call fails
74
+ */
75
+ createArticle(options: CreateArticleOptions): Promise<KnowledgeArticleRecord>;
76
+ /**
77
+ * Update an existing knowledge article.
78
+ *
79
+ * @param sysId The sys_id of the article to update
80
+ * @param options Fields to update
81
+ * @returns The updated article record
82
+ * @throws Error if the sys_id is empty, no fields are provided, or the API call fails
83
+ */
84
+ updateArticle(sysId: string, options: UpdateArticleOptions): Promise<KnowledgeArticleRecord>;
85
+ /**
86
+ * Publish a draft article by setting its workflow_state to "published".
87
+ *
88
+ * @param sysId The sys_id of the article to publish
89
+ * @returns The updated article record
90
+ * @throws Error if the sys_id is empty or the API call fails
91
+ */
92
+ publishArticle(sysId: string): Promise<KnowledgeArticleRecord>;
93
+ }