@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,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,69 @@
1
+ import { ServiceNowInstance } from "../ServiceNowInstance.js";
2
+ import { BackgroundScriptExecutionResult } from "../BackgroundScriptExecutor.js";
3
+ import { ExecuteFlowOptions, ExecuteFlowByNameOptions, ExecuteSubflowOptions, ExecuteActionOptions, FlowExecutionResult, FlowScriptResultEnvelope, FlowContextStatusResult, FlowOutputsResult, FlowErrorResult, FlowCancelResult, FlowSendMessageResult } from './FlowModels.js';
4
+ /**
5
+ * Provides operations for executing ServiceNow Flow Designer flows,
6
+ * subflows, and actions remotely via BackgroundScriptExecutor.
7
+ *
8
+ * Uses the sn_fd.FlowAPI.getRunner() (ScriptableFlowRunner) API
9
+ * on the server side to execute and capture results.
10
+ */
11
+ export declare class FlowManager {
12
+ private _logger;
13
+ private _bgExecutor;
14
+ private _instance;
15
+ private _defaultScope;
16
+ /**
17
+ * @param instance ServiceNow instance connection
18
+ * @param scope Default scope for script execution (default: "global")
19
+ */
20
+ constructor(instance: ServiceNowInstance, scope?: string);
21
+ /** Execute any flow object (flow, subflow, or action). */
22
+ execute(options: ExecuteFlowOptions): Promise<FlowExecutionResult>;
23
+ /** Execute a flow by scoped name. */
24
+ executeFlow(options: ExecuteFlowByNameOptions): Promise<FlowExecutionResult>;
25
+ /** Execute a subflow by scoped name. */
26
+ executeSubflow(options: ExecuteSubflowOptions): Promise<FlowExecutionResult>;
27
+ /** Execute an action by scoped name. */
28
+ executeAction(options: ExecuteActionOptions): Promise<FlowExecutionResult>;
29
+ /** Query the status of a flow context by its sys_id. */
30
+ getFlowContextStatus(contextId: string): Promise<FlowContextStatusResult>;
31
+ /** Retrieve outputs from a completed flow/subflow/action by context ID. */
32
+ getFlowOutputs(contextId: string): Promise<FlowOutputsResult>;
33
+ /** Retrieve error messages from a flow/subflow/action by context ID. */
34
+ getFlowError(contextId: string): Promise<FlowErrorResult>;
35
+ /** Cancel a running or paused flow/subflow/action. */
36
+ cancelFlow(contextId: string, reason?: string): Promise<FlowCancelResult>;
37
+ /** Send a message to a paused flow to resume it (for Wait for Message actions). */
38
+ sendFlowMessage(contextId: string, message: string, payload?: string): Promise<FlowSendMessageResult>;
39
+ /** Build the ServiceNow server-side script string. */
40
+ _buildFlowScript(options: ExecuteFlowOptions): string;
41
+ /** Serialize inputs for embedding in the generated script. */
42
+ _serializeInputs(inputs: Record<string, unknown>): string;
43
+ /**
44
+ * Decode HTML entities and strip HTML tags from a string.
45
+ * ServiceNow's background script output encodes quotes as &quot;
46
+ * and appends <BR/> tags that must be removed before JSON parsing.
47
+ */
48
+ _decodeHtmlEntities(str: string): string;
49
+ /** Try to parse a line containing the result marker into a FlowScriptResultEnvelope. */
50
+ private _tryParseEnvelopeFromLine;
51
+ /** Extract the JSON envelope from script output lines. */
52
+ _extractResultEnvelope(bgResult: BackgroundScriptExecutionResult): FlowScriptResultEnvelope | null;
53
+ /** Parse BackgroundScriptExecutionResult into FlowExecutionResult. */
54
+ _parseFlowResult(bgResult: BackgroundScriptExecutionResult, options: ExecuteFlowOptions): FlowExecutionResult;
55
+ /** Validate that a context ID is non-empty. */
56
+ private _validateContextId;
57
+ /** Escape a string for embedding in a generated SN script single-quoted string. */
58
+ private _escapeForScript;
59
+ /** Build script to query sys_flow_context status. */
60
+ _buildContextStatusScript(contextId: string): string;
61
+ /** Build script to retrieve flow outputs via FlowAPI.getOutputs(). */
62
+ _buildGetOutputsScript(contextId: string): string;
63
+ /** Build script to retrieve flow error via FlowAPI.getErrorMessage(). */
64
+ _buildGetErrorScript(contextId: string): string;
65
+ /** Build script to cancel a flow via FlowAPI.cancel(). */
66
+ _buildCancelScript(contextId: string, reason: string): string;
67
+ /** Build script to send a message to a paused flow via FlowAPI.sendMessage(). */
68
+ _buildSendMessageScript(contextId: string, message: string, payload: string): string;
69
+ }