@sonisoft/now-sdk-ext-core 3.0.2 → 3.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.
Files changed (33) hide show
  1. package/dist/index.d.ts +9 -0
  2. package/dist/index.js +9 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/sn/BackgroundScriptExecutor.js +2 -4
  5. package/dist/sn/BackgroundScriptExecutor.js.map +1 -1
  6. package/dist/sn/catalog/CatalogManager.d.ts +101 -0
  7. package/dist/sn/catalog/CatalogManager.js +352 -0
  8. package/dist/sn/catalog/CatalogManager.js.map +1 -0
  9. package/dist/sn/catalog/CatalogModels.d.ts +177 -0
  10. package/dist/sn/catalog/CatalogModels.js +6 -0
  11. package/dist/sn/catalog/CatalogModels.js.map +1 -0
  12. package/dist/sn/flow/FlowManager.d.ts +69 -0
  13. package/dist/sn/flow/FlowManager.js +571 -0
  14. package/dist/sn/flow/FlowManager.js.map +1 -0
  15. package/dist/sn/flow/FlowModels.d.ts +146 -0
  16. package/dist/sn/flow/FlowModels.js +7 -0
  17. package/dist/sn/flow/FlowModels.js.map +1 -0
  18. package/dist/sn/knowledge/KnowledgeManager.d.ts +93 -0
  19. package/dist/sn/knowledge/KnowledgeManager.js +316 -0
  20. package/dist/sn/knowledge/KnowledgeManager.js.map +1 -0
  21. package/dist/sn/knowledge/KnowledgeModels.d.ts +234 -0
  22. package/dist/sn/knowledge/KnowledgeModels.js +6 -0
  23. package/dist/sn/knowledge/KnowledgeModels.js.map +1 -0
  24. package/dist/sn/xml/XMLRecordManager.d.ts +35 -0
  25. package/dist/sn/xml/XMLRecordManager.js +157 -0
  26. package/dist/sn/xml/XMLRecordManager.js.map +1 -0
  27. package/dist/sn/xml/XMLRecordModels.d.ts +42 -0
  28. package/dist/sn/xml/XMLRecordModels.js +2 -0
  29. package/dist/sn/xml/XMLRecordModels.js.map +1 -0
  30. package/dist/util/CSRFTokenHelper.d.ts +16 -0
  31. package/dist/util/CSRFTokenHelper.js +23 -0
  32. package/dist/util/CSRFTokenHelper.js.map +1 -0
  33. package/package.json +1 -1
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Models for Flow Designer execution operations.
3
+ * Supports executing flows, subflows, and actions via BackgroundScriptExecutor
4
+ * using the sn_fd.FlowAPI.getRunner() (ScriptableFlowRunner) API.
5
+ */
6
+ /** Type of Flow Designer object to execute. */
7
+ export type FlowObjectType = 'flow' | 'subflow' | 'action';
8
+ /** Execution mode: synchronous (foreground) or asynchronous (background). */
9
+ export type FlowExecutionMode = 'foreground' | 'background';
10
+ /** Options for executing a Flow Designer object (flow, subflow, or action). */
11
+ export interface ExecuteFlowOptions {
12
+ /** Scoped name of the flow/subflow/action, e.g. "global.my_flow" */
13
+ scopedName: string;
14
+ /** Type of object to execute */
15
+ type: FlowObjectType;
16
+ /** Input name-value pairs to pass to the flow/subflow/action */
17
+ inputs?: Record<string, unknown>;
18
+ /**
19
+ * Execution mode: 'foreground' (sync) or 'background' (async).
20
+ * Default: 'foreground'
21
+ */
22
+ mode?: FlowExecutionMode;
23
+ /** Timeout in milliseconds (optional, SN default is 30s) */
24
+ timeout?: number;
25
+ /**
26
+ * Quick mode: skip execution detail records for better performance.
27
+ * Default: false
28
+ */
29
+ quick?: boolean;
30
+ /**
31
+ * Scope context for BackgroundScriptExecutor.
32
+ * Can be a scope name ("global", "x_myapp_custom") or a 32-character sys_id.
33
+ * Default: uses the FlowManager's default scope.
34
+ */
35
+ scope?: string;
36
+ }
37
+ /** Convenience options for executing a flow (type is implied). */
38
+ export interface ExecuteFlowByNameOptions extends Omit<ExecuteFlowOptions, 'type'> {
39
+ }
40
+ /** Convenience options for executing a subflow (type is implied). */
41
+ export interface ExecuteSubflowOptions extends Omit<ExecuteFlowOptions, 'type'> {
42
+ }
43
+ /** Convenience options for executing an action (type is implied). */
44
+ export interface ExecuteActionOptions extends Omit<ExecuteFlowOptions, 'type'> {
45
+ }
46
+ /** Structured result from executing a flow/subflow/action. */
47
+ export interface FlowExecutionResult {
48
+ /** Whether the execution completed without error */
49
+ success: boolean;
50
+ /** The scoped name of the executed flow object, e.g. "global.my_flow" */
51
+ flowObjectName: string;
52
+ /** Type of flow object that was executed */
53
+ flowObjectType: FlowObjectType;
54
+ /** sys_id of the execution context record (if not quick mode) */
55
+ contextId?: string;
56
+ /** Execution date/time as a string from the SN server */
57
+ executionDate?: string;
58
+ /** Domain sys_id (for domain-separated instances) */
59
+ domainId?: string;
60
+ /** Output name-value pairs returned by the flow/subflow/action */
61
+ outputs?: Record<string, unknown>;
62
+ /** Raw debug() output from ScriptableFlowRunnerResult */
63
+ debugOutput?: string;
64
+ /** Error message if execution failed */
65
+ errorMessage?: string;
66
+ /** The raw BackgroundScriptExecutionResult for advanced inspection */
67
+ rawScriptResult?: unknown;
68
+ }
69
+ /**
70
+ * JSON envelope structure used for communication between
71
+ * the generated SN server-side script and the FlowManager parser.
72
+ * @internal
73
+ */
74
+ export interface FlowScriptResultEnvelope {
75
+ __flowResult: true;
76
+ success: boolean;
77
+ flowObjectName: string;
78
+ flowObjectType: string;
79
+ contextId: string | null;
80
+ executionDate: string | null;
81
+ domainId: string | null;
82
+ outputs: Record<string, unknown> | null;
83
+ debugOutput: string;
84
+ errorMessage: string | null;
85
+ }
86
+ /** Known states of a flow context record in sys_flow_context. */
87
+ export type FlowContextState = 'QUEUED' | 'IN_PROGRESS' | 'WAITING' | 'COMPLETE' | 'CANCELLED' | 'ERROR' | string;
88
+ /** Result from querying a flow context's status. */
89
+ export interface FlowContextStatusResult {
90
+ success: boolean;
91
+ contextId: string;
92
+ found: boolean;
93
+ state?: FlowContextState;
94
+ name?: string;
95
+ started?: string;
96
+ ended?: string;
97
+ errorMessage?: string;
98
+ rawScriptResult?: unknown;
99
+ }
100
+ /** Result from retrieving outputs of a completed flow context. */
101
+ export interface FlowOutputsResult {
102
+ success: boolean;
103
+ contextId: string;
104
+ outputs?: Record<string, unknown>;
105
+ errorMessage?: string;
106
+ rawScriptResult?: unknown;
107
+ }
108
+ /** Result from retrieving error messages of a flow context. */
109
+ export interface FlowErrorResult {
110
+ success: boolean;
111
+ contextId: string;
112
+ flowErrorMessage?: string;
113
+ errorMessage?: string;
114
+ rawScriptResult?: unknown;
115
+ }
116
+ /** Result from cancelling a flow context. */
117
+ export interface FlowCancelResult {
118
+ success: boolean;
119
+ contextId: string;
120
+ errorMessage?: string;
121
+ rawScriptResult?: unknown;
122
+ }
123
+ /** Result from sending a message to a paused flow. */
124
+ export interface FlowSendMessageResult {
125
+ success: boolean;
126
+ contextId: string;
127
+ errorMessage?: string;
128
+ rawScriptResult?: unknown;
129
+ }
130
+ /**
131
+ * JSON envelope for lifecycle operations (status, outputs, errors, cancel, message).
132
+ * @internal
133
+ */
134
+ export interface FlowLifecycleEnvelope {
135
+ __flowResult: true;
136
+ success: boolean;
137
+ contextId: string;
138
+ errorMessage: string | null;
139
+ found?: boolean;
140
+ state?: string | null;
141
+ name?: string | null;
142
+ started?: string | null;
143
+ ended?: string | null;
144
+ outputs?: Record<string, unknown> | null;
145
+ flowErrorMessage?: string | null;
146
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Models for Flow Designer execution operations.
3
+ * Supports executing flows, subflows, and actions via BackgroundScriptExecutor
4
+ * using the sn_fd.FlowAPI.getRunner() (ScriptableFlowRunner) API.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=FlowModels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowModels.js","sourceRoot":"","sources":["../../../src/sn/flow/FlowModels.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -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
+ }
@@ -0,0 +1,316 @@
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
+ * Provides operations for managing ServiceNow Knowledge Base articles,
7
+ * knowledge bases, and categories via the Table API and Stats API.
8
+ */
9
+ export class KnowledgeManager {
10
+ static KB_BASE_TABLE = 'kb_knowledge_base';
11
+ static KB_CATEGORY_TABLE = 'kb_category';
12
+ static KB_KNOWLEDGE_TABLE = 'kb_knowledge';
13
+ /** Fields to return in list operations (excludes large body fields) */
14
+ static ARTICLE_LIST_FIELDS = 'sys_id,number,short_description,kb_knowledge_base,kb_category,workflow_state,' +
15
+ 'author,article_type,published,active,sys_view_count,sys_created_on,sys_updated_on';
16
+ _logger = new Logger("KnowledgeManager");
17
+ _req;
18
+ _tableAPI;
19
+ _aggregateQuery;
20
+ _instance;
21
+ constructor(instance) {
22
+ this._instance = instance;
23
+ this._req = new ServiceNowRequest(instance);
24
+ this._tableAPI = new TableAPIRequest(instance);
25
+ this._aggregateQuery = new AggregateQuery(instance);
26
+ }
27
+ /**
28
+ * List knowledge bases with optional filtering and pagination.
29
+ *
30
+ * @param options Filtering and pagination options
31
+ * @returns Array of knowledge base records
32
+ * @throws Error if the API call fails
33
+ */
34
+ async listKnowledgeBases(options = {}) {
35
+ const { query, active, limit = 20, offset = 0 } = options;
36
+ this._logger.info('Listing knowledge bases');
37
+ const queryParts = [];
38
+ if (active !== undefined)
39
+ queryParts.push(`active=${active}`);
40
+ if (query)
41
+ queryParts.push(query);
42
+ const params = {
43
+ sysparm_limit: limit,
44
+ sysparm_offset: offset
45
+ };
46
+ if (queryParts.length > 0) {
47
+ params.sysparm_query = queryParts.join('^');
48
+ }
49
+ const response = await this._tableAPI.get(KnowledgeManager.KB_BASE_TABLE, params);
50
+ if (response && response.status === 200 && response.bodyObject?.result) {
51
+ this._logger.info(`Retrieved ${response.bodyObject.result.length} knowledge bases`);
52
+ return response.bodyObject.result;
53
+ }
54
+ throw new Error(`Failed to list knowledge bases. Status: ${response?.status ?? 'unknown'}`);
55
+ }
56
+ /**
57
+ * Get details of a specific knowledge base including article and category counts.
58
+ *
59
+ * @param sysId The sys_id of the knowledge base
60
+ * @returns Knowledge base detail with article and category counts
61
+ * @throws Error if the sys_id is empty, the KB is not found, or the API call fails
62
+ */
63
+ async getKnowledgeBase(sysId) {
64
+ if (!sysId || sysId.trim().length === 0) {
65
+ throw new Error('Knowledge base sys_id is required');
66
+ }
67
+ this._logger.info(`Getting knowledge base: ${sysId}`);
68
+ const query = {
69
+ sysparm_query: `sys_id=${sysId}`,
70
+ sysparm_limit: 1
71
+ };
72
+ const response = await this._tableAPI.get(KnowledgeManager.KB_BASE_TABLE, query);
73
+ if (!response || response.status !== 200 || !response.bodyObject?.result ||
74
+ response.bodyObject.result.length === 0) {
75
+ throw new Error(`Knowledge base '${sysId}' not found. Status: ${response?.status ?? 'unknown'}`);
76
+ }
77
+ const knowledgeBase = response.bodyObject.result[0];
78
+ // Get article and category counts in parallel
79
+ const [articleCount, categoryCount] = await Promise.all([
80
+ this._aggregateQuery.count({
81
+ table: KnowledgeManager.KB_KNOWLEDGE_TABLE,
82
+ query: `kb_knowledge_base=${sysId}`
83
+ }),
84
+ this._aggregateQuery.count({
85
+ table: KnowledgeManager.KB_CATEGORY_TABLE,
86
+ query: `value=${sysId}`
87
+ })
88
+ ]);
89
+ this._logger.info(`Knowledge base '${knowledgeBase.title}': ${articleCount} articles, ${categoryCount} categories`);
90
+ return { knowledgeBase, articleCount, categoryCount };
91
+ }
92
+ /**
93
+ * List categories within a knowledge base with optional filtering.
94
+ *
95
+ * @param options Filtering and pagination options
96
+ * @returns Array of category records
97
+ * @throws Error if the API call fails
98
+ */
99
+ async listCategories(options = {}) {
100
+ const { knowledgeBaseSysId, parentCategory, query, active, limit = 20, offset = 0 } = options;
101
+ this._logger.info('Listing categories');
102
+ const queryParts = [];
103
+ if (knowledgeBaseSysId)
104
+ queryParts.push(`value=${knowledgeBaseSysId}`);
105
+ if (parentCategory)
106
+ queryParts.push(`parent_id=${parentCategory}`);
107
+ if (active !== undefined)
108
+ queryParts.push(`active=${active}`);
109
+ if (query)
110
+ queryParts.push(query);
111
+ const params = {
112
+ sysparm_limit: limit,
113
+ sysparm_offset: offset
114
+ };
115
+ if (queryParts.length > 0) {
116
+ params.sysparm_query = queryParts.join('^');
117
+ }
118
+ const response = await this._tableAPI.get(KnowledgeManager.KB_CATEGORY_TABLE, params);
119
+ if (response && response.status === 200 && response.bodyObject?.result) {
120
+ this._logger.info(`Retrieved ${response.bodyObject.result.length} categories`);
121
+ return response.bodyObject.result;
122
+ }
123
+ throw new Error(`Failed to list categories. Status: ${response?.status ?? 'unknown'}`);
124
+ }
125
+ /**
126
+ * Create a new knowledge base category.
127
+ *
128
+ * @param options Category creation options
129
+ * @returns The created category record
130
+ * @throws Error if required fields are missing or the API call fails
131
+ */
132
+ async createCategory(options) {
133
+ if (!options.label || options.label.trim().length === 0) {
134
+ throw new Error('Category label is required');
135
+ }
136
+ if (!options.knowledgeBaseSysId || options.knowledgeBaseSysId.trim().length === 0) {
137
+ throw new Error('Knowledge base sys_id is required');
138
+ }
139
+ this._logger.info(`Creating category: ${options.label}`);
140
+ const body = {
141
+ label: options.label,
142
+ value: options.knowledgeBaseSysId
143
+ };
144
+ if (options.parentCategory) {
145
+ body.parent_id = options.parentCategory;
146
+ }
147
+ if (options.active !== undefined) {
148
+ body.active = String(options.active);
149
+ }
150
+ const response = await this._tableAPI.post(KnowledgeManager.KB_CATEGORY_TABLE, {}, body);
151
+ if (response && (response.status === 200 || response.status === 201) && response.bodyObject?.result) {
152
+ this._logger.info(`Created category: ${options.label} (${response.bodyObject.result.sys_id})`);
153
+ return response.bodyObject.result;
154
+ }
155
+ throw new Error(`Failed to create category '${options.label}'. Status: ${response?.status ?? 'unknown'}`);
156
+ }
157
+ /**
158
+ * List knowledge articles with filtering by KB, category, workflow state, and text search.
159
+ * Returns article summaries (without large body fields) for efficiency.
160
+ *
161
+ * @param options Filtering and pagination options
162
+ * @returns Array of article summaries
163
+ * @throws Error if the API call fails
164
+ */
165
+ async listArticles(options = {}) {
166
+ const { knowledgeBaseSysId, categorySysId, workflowState, textSearch, query, limit = 20, offset = 0 } = options;
167
+ this._logger.info('Listing articles');
168
+ const queryParts = [];
169
+ if (knowledgeBaseSysId)
170
+ queryParts.push(`kb_knowledge_base=${knowledgeBaseSysId}`);
171
+ if (categorySysId)
172
+ queryParts.push(`kb_category=${categorySysId}`);
173
+ if (workflowState)
174
+ queryParts.push(`workflow_state=${workflowState}`);
175
+ if (textSearch)
176
+ queryParts.push(`short_descriptionLIKE${textSearch}`);
177
+ if (query)
178
+ queryParts.push(query);
179
+ const params = {
180
+ sysparm_limit: limit,
181
+ sysparm_offset: offset,
182
+ sysparm_fields: KnowledgeManager.ARTICLE_LIST_FIELDS
183
+ };
184
+ if (queryParts.length > 0) {
185
+ params.sysparm_query = queryParts.join('^');
186
+ }
187
+ const response = await this._tableAPI.get(KnowledgeManager.KB_KNOWLEDGE_TABLE, params);
188
+ if (response && response.status === 200 && response.bodyObject?.result) {
189
+ this._logger.info(`Retrieved ${response.bodyObject.result.length} articles`);
190
+ return response.bodyObject.result;
191
+ }
192
+ throw new Error(`Failed to list articles. Status: ${response?.status ?? 'unknown'}`);
193
+ }
194
+ /**
195
+ * Get full article content including body text.
196
+ *
197
+ * @param sysId The sys_id of the article
198
+ * @returns The full article record
199
+ * @throws Error if the sys_id is empty, the article is not found, or the API call fails
200
+ */
201
+ async getArticle(sysId) {
202
+ if (!sysId || sysId.trim().length === 0) {
203
+ throw new Error('Article sys_id is required');
204
+ }
205
+ this._logger.info(`Getting article: ${sysId}`);
206
+ const query = {
207
+ sysparm_query: `sys_id=${sysId}`,
208
+ sysparm_limit: 1
209
+ };
210
+ const response = await this._tableAPI.get(KnowledgeManager.KB_KNOWLEDGE_TABLE, query);
211
+ if (response && response.status === 200 && response.bodyObject?.result) {
212
+ if (response.bodyObject.result.length > 0) {
213
+ this._logger.info(`Found article: ${response.bodyObject.result[0].short_description}`);
214
+ return response.bodyObject.result[0];
215
+ }
216
+ throw new Error(`Article '${sysId}' not found`);
217
+ }
218
+ throw new Error(`Failed to get article '${sysId}'. Status: ${response?.status ?? 'unknown'}`);
219
+ }
220
+ /**
221
+ * Create a new knowledge article.
222
+ *
223
+ * @param options Article creation options
224
+ * @returns The created article record
225
+ * @throws Error if required fields are missing or the API call fails
226
+ */
227
+ async createArticle(options) {
228
+ if (!options.shortDescription || options.shortDescription.trim().length === 0) {
229
+ throw new Error('Article short description is required');
230
+ }
231
+ if (!options.knowledgeBaseSysId || options.knowledgeBaseSysId.trim().length === 0) {
232
+ throw new Error('Knowledge base sys_id is required');
233
+ }
234
+ this._logger.info(`Creating article: ${options.shortDescription}`);
235
+ const body = {
236
+ short_description: options.shortDescription,
237
+ kb_knowledge_base: options.knowledgeBaseSysId,
238
+ workflow_state: options.workflowState || 'draft'
239
+ };
240
+ if (options.text)
241
+ body.text = options.text;
242
+ if (options.wiki)
243
+ body.wiki = options.wiki;
244
+ if (options.categorySysId)
245
+ body.kb_category = options.categorySysId;
246
+ if (options.articleType)
247
+ body.article_type = options.articleType;
248
+ if (options.additionalFields) {
249
+ Object.assign(body, options.additionalFields);
250
+ }
251
+ const response = await this._tableAPI.post(KnowledgeManager.KB_KNOWLEDGE_TABLE, {}, body);
252
+ if (response && (response.status === 200 || response.status === 201) && response.bodyObject?.result) {
253
+ this._logger.info(`Created article: ${options.shortDescription} (${response.bodyObject.result.sys_id})`);
254
+ return response.bodyObject.result;
255
+ }
256
+ throw new Error(`Failed to create article. Status: ${response?.status ?? 'unknown'}`);
257
+ }
258
+ /**
259
+ * Update an existing knowledge article.
260
+ *
261
+ * @param sysId The sys_id of the article to update
262
+ * @param options Fields to update
263
+ * @returns The updated article record
264
+ * @throws Error if the sys_id is empty, no fields are provided, or the API call fails
265
+ */
266
+ async updateArticle(sysId, options) {
267
+ if (!sysId || sysId.trim().length === 0) {
268
+ throw new Error('Article sys_id is required');
269
+ }
270
+ this._logger.info(`Updating article: ${sysId}`);
271
+ const body = {};
272
+ if (options.shortDescription !== undefined)
273
+ body.short_description = options.shortDescription;
274
+ if (options.text !== undefined)
275
+ body.text = options.text;
276
+ if (options.wiki !== undefined)
277
+ body.wiki = options.wiki;
278
+ if (options.knowledgeBaseSysId !== undefined)
279
+ body.kb_knowledge_base = options.knowledgeBaseSysId;
280
+ if (options.categorySysId !== undefined)
281
+ body.kb_category = options.categorySysId;
282
+ if (options.workflowState !== undefined)
283
+ body.workflow_state = options.workflowState;
284
+ if (options.articleType !== undefined)
285
+ body.article_type = options.articleType;
286
+ if (options.active !== undefined)
287
+ body.active = String(options.active);
288
+ if (options.additionalFields) {
289
+ Object.assign(body, options.additionalFields);
290
+ }
291
+ if (Object.keys(body).length === 0) {
292
+ throw new Error('At least one field must be provided for update');
293
+ }
294
+ const response = await this._tableAPI.put(KnowledgeManager.KB_KNOWLEDGE_TABLE, sysId, body);
295
+ if (response && response.status === 200 && response.bodyObject?.result) {
296
+ this._logger.info(`Updated article: ${sysId}`);
297
+ return response.bodyObject.result;
298
+ }
299
+ throw new Error(`Failed to update article '${sysId}'. Status: ${response?.status ?? 'unknown'}`);
300
+ }
301
+ /**
302
+ * Publish a draft article by setting its workflow_state to "published".
303
+ *
304
+ * @param sysId The sys_id of the article to publish
305
+ * @returns The updated article record
306
+ * @throws Error if the sys_id is empty or the API call fails
307
+ */
308
+ async publishArticle(sysId) {
309
+ if (!sysId || sysId.trim().length === 0) {
310
+ throw new Error('Article sys_id is required');
311
+ }
312
+ this._logger.info(`Publishing article: ${sysId}`);
313
+ return this.updateArticle(sysId, { workflowState: 'published' });
314
+ }
315
+ }
316
+ //# sourceMappingURL=KnowledgeManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnowledgeManager.js","sourceRoot":"","sources":["../../../src/sn/knowledge/KnowledgeManager.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;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAsB7D;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACjB,MAAM,CAAU,aAAa,GAAG,mBAAmB,CAAC;IACpD,MAAM,CAAU,iBAAiB,GAAG,aAAa,CAAC;IAClD,MAAM,CAAU,kBAAkB,GAAG,cAAc,CAAC;IAE5D,uEAAuE;IAC/D,MAAM,CAAU,mBAAmB,GACvC,+EAA+E;QAC/E,mFAAmF,CAAC;IAEhF,OAAO,GAAW,IAAI,MA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