@sonisoft/now-sdk-ext-core 6.6.3 → 6.8.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 (79) hide show
  1. package/README.md +6 -0
  2. package/dist/comm/http/FormHtmlParser.d.ts +34 -0
  3. package/dist/comm/http/FormHtmlParser.js +227 -0
  4. package/dist/comm/http/FormHtmlParser.js.map +1 -0
  5. package/dist/comm/http/FormRecordModels.d.ts +120 -0
  6. package/dist/comm/http/FormRecordModels.js +6 -0
  7. package/dist/comm/http/FormRecordModels.js.map +1 -0
  8. package/dist/comm/http/FormRecordWriter.d.ts +99 -0
  9. package/dist/comm/http/FormRecordWriter.js +385 -0
  10. package/dist/comm/http/FormRecordWriter.js.map +1 -0
  11. package/dist/comm/http/HTTPRequest.d.ts +4 -0
  12. package/dist/comm/http/RequestHandler.d.ts +1 -0
  13. package/dist/comm/http/RequestHandler.js +34 -22
  14. package/dist/comm/http/RequestHandler.js.map +1 -1
  15. package/dist/comm/http/internal/FormTransportModels.d.ts +26 -0
  16. package/dist/comm/http/internal/FormTransportModels.js +2 -0
  17. package/dist/comm/http/internal/FormTransportModels.js.map +1 -0
  18. package/dist/exception/FormSubmitError.d.ts +13 -0
  19. package/dist/exception/FormSubmitError.js +19 -0
  20. package/dist/exception/FormSubmitError.js.map +1 -0
  21. package/dist/exception/WorkflowValidationError.d.ts +24 -0
  22. package/dist/exception/WorkflowValidationError.js +24 -0
  23. package/dist/exception/WorkflowValidationError.js.map +1 -0
  24. package/dist/index.d.ts +19 -0
  25. package/dist/index.js +19 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/sn/metadata/MetadataFormWriter.d.ts +13 -0
  28. package/dist/sn/metadata/MetadataFormWriter.js +264 -0
  29. package/dist/sn/metadata/MetadataFormWriter.js.map +1 -0
  30. package/dist/sn/metadata/MetadataModels.d.ts +44 -0
  31. package/dist/sn/metadata/MetadataModels.js +2 -0
  32. package/dist/sn/metadata/MetadataModels.js.map +1 -0
  33. package/dist/sn/metadata/MetadataScopeError.d.ts +5 -0
  34. package/dist/sn/metadata/MetadataScopeError.js +10 -0
  35. package/dist/sn/metadata/MetadataScopeError.js.map +1 -0
  36. package/dist/sn/metadata/MetadataVerificationError.d.ts +11 -0
  37. package/dist/sn/metadata/MetadataVerificationError.js +20 -0
  38. package/dist/sn/metadata/MetadataVerificationError.js.map +1 -0
  39. package/dist/sn/metadata/internal/MetadataPreferences.d.ts +12 -0
  40. package/dist/sn/metadata/internal/MetadataPreferences.js +27 -0
  41. package/dist/sn/metadata/internal/MetadataPreferences.js.map +1 -0
  42. package/dist/sn/metadata/internal/MetadataReader.d.ts +9 -0
  43. package/dist/sn/metadata/internal/MetadataReader.js +55 -0
  44. package/dist/sn/metadata/internal/MetadataReader.js.map +1 -0
  45. package/dist/sn/variables/VariableDefinitions.d.ts +23 -0
  46. package/dist/sn/variables/VariableDefinitions.js +106 -0
  47. package/dist/sn/variables/VariableDefinitions.js.map +1 -0
  48. package/dist/sn/variables/VariableModels.d.ts +49 -0
  49. package/dist/sn/variables/VariableModels.js +6 -0
  50. package/dist/sn/variables/VariableModels.js.map +1 -0
  51. package/dist/sn/workflow/WorkflowConversionModels.d.ts +209 -0
  52. package/dist/sn/workflow/WorkflowConversionModels.js +2 -0
  53. package/dist/sn/workflow/WorkflowConversionModels.js.map +1 -0
  54. package/dist/sn/workflow/WorkflowDiagramClient.d.ts +70 -0
  55. package/dist/sn/workflow/WorkflowDiagramClient.js +151 -0
  56. package/dist/sn/workflow/WorkflowDiagramClient.js.map +1 -0
  57. package/dist/sn/workflow/WorkflowFlowConversion.d.ts +19 -0
  58. package/dist/sn/workflow/WorkflowFlowConversion.js +1013 -0
  59. package/dist/sn/workflow/WorkflowFlowConversion.js.map +1 -0
  60. package/dist/sn/workflow/WorkflowFlowHints.d.ts +3 -0
  61. package/dist/sn/workflow/WorkflowFlowHints.js +36 -0
  62. package/dist/sn/workflow/WorkflowFlowHints.js.map +1 -0
  63. package/dist/sn/workflow/WorkflowFluentGenerator.d.ts +17 -0
  64. package/dist/sn/workflow/WorkflowFluentGenerator.js +348 -0
  65. package/dist/sn/workflow/WorkflowFluentGenerator.js.map +1 -0
  66. package/dist/sn/workflow/WorkflowGraphML.d.ts +39 -0
  67. package/dist/sn/workflow/WorkflowGraphML.js +162 -0
  68. package/dist/sn/workflow/WorkflowGraphML.js.map +1 -0
  69. package/dist/sn/workflow/WorkflowManager.d.ts +236 -6
  70. package/dist/sn/workflow/WorkflowManager.js +1443 -15
  71. package/dist/sn/workflow/WorkflowManager.js.map +1 -1
  72. package/dist/sn/workflow/WorkflowModels.d.ts +738 -0
  73. package/dist/sn/workflow/WorkflowStructure.d.ts +137 -0
  74. package/dist/sn/workflow/WorkflowStructure.js +368 -0
  75. package/dist/sn/workflow/WorkflowStructure.js.map +1 -0
  76. package/dist/sn/workflow/WorkflowViews.d.ts +104 -0
  77. package/dist/sn/workflow/WorkflowViews.js +408 -0
  78. package/dist/sn/workflow/WorkflowViews.js.map +1 -0
  79. package/package.json +2 -1
@@ -0,0 +1,162 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
3
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
4
+ import { XMLParser } from "fast-xml-parser";
5
+ /**
6
+ * GraphML as spoken by the Workflow Editor's diagram processor
7
+ * (`com.glideapp.workflow.ui.WorkflowDiagramProcessor`).
8
+ *
9
+ * - `<graph id>` is the wf_workflow_version sys_id; its `<data>` children are version
10
+ * properties and permissions (`can_checkout`, `published`, …) plus one
11
+ * `activity_<definition sys_id>` entry per activity type in the palette.
12
+ * - `<node>` is a wf_activity. Careful: its `name` is the activity TYPE ("Timer") and
13
+ * its `description` is the activity's own name.
14
+ * - `<port>` is a wf_condition (an exit) on a node.
15
+ * - `<edge>` is a wf_transition; `source_port` is the condition it leaves from.
16
+ */
17
+ const parser = new XMLParser({
18
+ ignoreAttributes: false,
19
+ attributeNamePrefix: "",
20
+ textNodeName: "#text",
21
+ parseTagValue: false,
22
+ parseAttributeValue: false,
23
+ trimValues: false,
24
+ isArray: (name) => ["graph", "node", "port", "edge", "data"].includes(name),
25
+ });
26
+ /**
27
+ * Parse a diagram processor response (`<xml …><graphml>…</graphml></xml>`).
28
+ *
29
+ * @returns The graph when the response carries one, and any reported messages
30
+ */
31
+ export function parseDiagramResponse(xml) {
32
+ const doc = parser.parse(xml);
33
+ const root = doc?.xml ?? {};
34
+ const messages = {};
35
+ const text = (key) => {
36
+ const value = root[key];
37
+ if (value === undefined)
38
+ return undefined;
39
+ const raw = typeof value === "object" ? (value["#text"] ?? "") : String(value);
40
+ return String(raw).trim();
41
+ };
42
+ if (text("validation_critical") !== undefined)
43
+ messages.validationCritical = text("validation_critical");
44
+ if (text("validation_warning") !== undefined)
45
+ messages.validationWarning = text("validation_warning");
46
+ if (text("duplicate_name") !== undefined)
47
+ messages.duplicateName = text("duplicate_name");
48
+ if (text("different_domain") !== undefined)
49
+ messages.differentDomain = text("different_domain");
50
+ const graphEl = root.graphml?.graph?.[0];
51
+ return { graph: graphEl ? toGraph(graphEl) : undefined, messages, root };
52
+ }
53
+ function dataMap(el) {
54
+ const out = {};
55
+ for (const d of (el.data ?? [])) {
56
+ if (d?.key === undefined)
57
+ continue;
58
+ out[String(d.key)] = d["#text"] === undefined ? "" : String(d["#text"]);
59
+ }
60
+ return out;
61
+ }
62
+ function num(value) {
63
+ if (value === undefined || value === "")
64
+ return undefined;
65
+ const n = Number(value);
66
+ return Number.isFinite(n) ? n : undefined;
67
+ }
68
+ function toGraph(el) {
69
+ const all = dataMap(el);
70
+ const properties = {};
71
+ const activityTypes = {};
72
+ for (const [key, value] of Object.entries(all)) {
73
+ if (/^activity_[0-9a-f]{32}$/i.test(key))
74
+ activityTypes[key.slice("activity_".length)] = value;
75
+ else
76
+ properties[key] = value;
77
+ }
78
+ const nodes = (el.node ?? []).map(n => {
79
+ const d = dataMap(n);
80
+ const node = {
81
+ id: String(n.id),
82
+ name: d.description ?? "",
83
+ typeName: d.name ?? "",
84
+ activityDefinition: d.activity_definition ?? "",
85
+ x: num(d.x),
86
+ y: num(d.y),
87
+ width: num(d.width),
88
+ height: num(d.height),
89
+ stage: d.stage || undefined,
90
+ parent: d.parent || undefined,
91
+ isParent: d.is_parent === "true",
92
+ deletable: d.deleteable !== "false",
93
+ };
94
+ return node;
95
+ });
96
+ const ports = (el.port ?? []).map(p => {
97
+ const d = dataMap(p);
98
+ return {
99
+ id: String(p.id),
100
+ node: String(p.node),
101
+ name: d.name ?? "",
102
+ order: num(d.order) ?? 0,
103
+ error: d.error === "true",
104
+ event: d.event === "true",
105
+ };
106
+ });
107
+ const edges = (el.edge ?? []).map(e => ({
108
+ id: String(e.id),
109
+ source: String(e.source),
110
+ sourcePort: String(e.source_port ?? ""),
111
+ target: String(e.target),
112
+ }));
113
+ const bool = (key) => properties[key] === "true";
114
+ return {
115
+ id: String(el.id ?? ""),
116
+ workflowSysId: properties.workflow ?? "",
117
+ name: properties.name ?? "",
118
+ table: properties.table ?? "",
119
+ published: bool("published"),
120
+ active: bool("active"),
121
+ readOnly: bool("read_only"),
122
+ canCheckout: bool("can_checkout"),
123
+ canForceCheckout: bool("can_force_checkout"),
124
+ canPublish: bool("can_publish"),
125
+ canDelete: bool("can_delete"),
126
+ statusDisplay: properties.status_display ?? "",
127
+ fullSequences: properties.full_sequences ? properties.full_sequences.split(",").filter(Boolean) : [],
128
+ properties,
129
+ activityTypes,
130
+ nodes,
131
+ ports,
132
+ edges,
133
+ };
134
+ }
135
+ /**
136
+ * Serialize minimal GraphML for a processor write: the graph id plus the elements being
137
+ * changed. The processor needs nothing else — the editor's copy of every graph property
138
+ * and palette entry is ignored.
139
+ */
140
+ export function serializeGraph(versionSysId, content) {
141
+ const parts = [];
142
+ for (const node of content.nodes ?? []) {
143
+ const data = [];
144
+ if (node.x !== undefined)
145
+ data.push(`<data key="x">${Math.round(node.x)}</data>`);
146
+ if (node.y !== undefined)
147
+ data.push(`<data key="y">${Math.round(node.y)}</data>`);
148
+ parts.push(`<node id="${attr(node.id)}">${data.join("")}</node>`);
149
+ }
150
+ for (const edge of content.edges ?? []) {
151
+ parts.push(`<edge id="${attr(edge.id)}" source="${attr(edge.source)}" source_port="${attr(edge.sourcePort)}" target="${attr(edge.target)}"/>`);
152
+ }
153
+ return `<graphml><graph id="${attr(versionSysId)}">${parts.join("")}</graph></graphml>`;
154
+ }
155
+ function attr(value) {
156
+ return String(value)
157
+ .replace(/&/g, "&amp;")
158
+ .replace(/</g, "&lt;")
159
+ .replace(/>/g, "&gt;")
160
+ .replace(/"/g, "&quot;");
161
+ }
162
+ //# sourceMappingURL=WorkflowGraphML.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkflowGraphML.js","sourceRoot":"","sources":["../../../src/sn/workflow/WorkflowGraphML.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,4DAA4D;AAC5D,+DAA+D;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IACzB,gBAAgB,EAAE,KAAK;IACvB,mBAAmB,EAAE,EAAE;IACvB,YAAY,EAAE,OAAO;IACrB,aAAa,EAAE,KAAK;IACpB,mBAAmB,EAAE,KAAK;IAC1B,UAAU,EAAE,KAAK;IACjB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;CAC9E,CAAC,CAAC;AAcH;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;IACzC,MAAM,IAAI,GAAY,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IACrC,MAAM,QA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SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACjC,CAAC"}
@@ -1,10 +1,21 @@
1
1
  import { ServiceNowInstance } from "../ServiceNowInstance.js";
2
- import { CreateWorkflowOptions, CreateWorkflowResult, CreateWorkflowVersionOptions, CreateWorkflowVersionResult, CreateActivityOptions, CreateActivityResult, CreateTransitionOptions, CreateTransitionResult, CreateConditionOptions, CreateConditionResult, PublishWorkflowOptions, CompleteWorkflowSpec, CompleteWorkflowResult } from './WorkflowModels.js';
2
+ import { FluentGeneratorOptions } from "./WorkflowFluentGenerator.js";
3
+ import { WorkflowFlowConversion } from "./WorkflowConversionModels.js";
4
+ import { CreateWorkflowOptions, CreateWorkflowResult, CreateWorkflowVersionOptions, CreateWorkflowVersionResult, CreateActivityOptions, CreateActivityResult, CreateTransitionOptions, CreateTransitionResult, CreateConditionOptions, CreateConditionResult, PublishWorkflowOptions, CompleteWorkflowSpec, CompleteWorkflowResult, ActivityDefinitionDetail, ActivityDefinitionSummary, ActivityPosition, ActivityUsage, AddActivityOptions, AddActivityResult, AddConditionOptions, AddTransitionOptions, CheckoutOptions, CheckoutResult, ExportWorkflowOptions, FindWorkflowsOptions, GetActivityDefinitionOptions, GetActivityUsageOptions, GetWorkflowDefinitionOptions, ListActivityDefinitionsOptions, NewWorkflowOptions, NewWorkflowResult, PublishOptions, PublishResult, RemoveActivityOptions, UpdateActivityOptions, UpdateConditionOptions, UpdateWorkflowPropertiesOptions, WorkflowDefinition, WorkflowExport, WorkflowGraph, WorkflowSummary, WorkflowValidationReport, WorkflowVersionSummary } from './WorkflowModels.js';
3
5
  /**
4
- * Manages ServiceNow workflow lifecycle operations including creating workflows,
5
- * versions, activities, transitions, conditions, and publishing.
6
- * Also provides a high-level orchestration method to create a complete workflow
7
- * from a single specification.
6
+ * Manages legacy ServiceNow workflows (the Workflow Editor's wf_* records).
7
+ *
8
+ * Two families of methods live here:
9
+ *
10
+ * - **Editor-parity methods** (`newWorkflow`, `checkout`, `addActivity`, `publish`, …)
11
+ * drive the same server endpoints the Workflow Editor uses — its diagram processor for
12
+ * structure and lifecycle, and the classic `wf_activity` form for activity
13
+ * configuration — so checkout's deep copy, publish's validation and version swap, and
14
+ * activity variables (`sys_variable_value`) all behave exactly as they do in the UI.
15
+ * Editing methods require a draft checked out to the current user.
16
+ * - **Record methods** (`createWorkflow`, `createActivity`, …, `createCompleteWorkflow`)
17
+ * insert wf_* records directly through the Table API. They predate the editor-parity
18
+ * methods and are kept for compatibility.
8
19
  */
9
20
  export declare class WorkflowManager {
10
21
  private static readonly WF_WORKFLOW;
@@ -12,10 +23,16 @@ export declare class WorkflowManager {
12
23
  private static readonly WF_ACTIVITY;
13
24
  private static readonly WF_TRANSITION;
14
25
  private static readonly WF_CONDITION;
26
+ /** The form view the Workflow Editor uses for activity dialogs. */
27
+ private static readonly ACTIVITY_VIEW;
15
28
  private _logger;
16
29
  private _req;
17
30
  private _tableAPI;
18
31
  private _instance;
32
+ private _diagram;
33
+ private _forms;
34
+ private _variables;
35
+ private _currentUser?;
19
36
  constructor(instance: ServiceNowInstance);
20
37
  /**
21
38
  * Create a new workflow record.
@@ -58,7 +75,11 @@ export declare class WorkflowManager {
58
75
  */
59
76
  createCondition(options: CreateConditionOptions): Promise<CreateConditionResult>;
60
77
  /**
61
- * Publish a workflow version by setting published=true and the start activity.
78
+ * Set a workflow version's start activity and publish it.
79
+ *
80
+ * Publishes through the Workflow Editor's publish (without its validation prompt, as
81
+ * this method never validated), so the version swap, path computation and update-set
82
+ * capture match a publish from the editor. Use {@link publish} for validation.
62
83
  *
63
84
  * @param options Publish options including version sys_id and start activity sys_id
64
85
  * @throws Error if the API call fails
@@ -78,4 +99,213 @@ export declare class WorkflowManager {
78
99
  * @throws Error if any step fails
79
100
  */
80
101
  createCompleteWorkflow(spec: CompleteWorkflowSpec, onProgress?: (message: string) => void): Promise<CompleteWorkflowResult>;
102
+ /**
103
+ * Find workflows, with the state of their published and checked-out versions.
104
+ */
105
+ findWorkflows(options?: FindWorkflowsOptions): Promise<WorkflowSummary[]>;
106
+ /**
107
+ * Resolve a workflow by name, wf_workflow sys_id, or the sys_id of any of its versions.
108
+ *
109
+ * @throws InvalidParameterException when nothing or more than one workflow matches
110
+ */
111
+ resolveWorkflow(nameOrSysId: string): Promise<WorkflowSummary>;
112
+ /**
113
+ * List a workflow's versions, newest first.
114
+ */
115
+ getWorkflowVersions(workflowSysId: string): Promise<WorkflowVersionSummary[]>;
116
+ /**
117
+ * Read everything that makes up a workflow version: activities with their variables
118
+ * and exits, transitions and stages.
119
+ */
120
+ getWorkflowDefinition(versionSysId: string, options?: GetWorkflowDefinitionOptions): Promise<WorkflowDefinition>;
121
+ /**
122
+ * Read a version's diagram as the Workflow Editor sees it.
123
+ */
124
+ getWorkflowGraph(versionSysId: string): Promise<WorkflowGraph>;
125
+ /**
126
+ * List activity types — core activities and, unless excluded, Activity Designer ones.
127
+ */
128
+ listActivityDefinitions(options?: ListActivityDefinitionsOptions): Promise<ActivityDefinitionSummary[]>;
129
+ /**
130
+ * Describe an activity type as the instance defines it: its own description, the
131
+ * variables its activities carry (types, defaults, choices, hints) or — for Activity
132
+ * Designer types — its inputs and outputs, and the exits a new activity starts with.
133
+ * With `includeScript`, also its implementation, which shows how each variable is used
134
+ * and which results drive the exits.
135
+ *
136
+ * @param nameOrSysId Definition sys_id or exact name (e.g. "Timer")
137
+ */
138
+ getActivityDefinition(nameOrSysId: string, options?: GetActivityDefinitionOptions): Promise<ActivityDefinitionDetail>;
139
+ /**
140
+ * Learn how an activity type is configured on this instance: samples activities of the
141
+ * type in published workflows and reports, per variable (or Activity Designer input),
142
+ * how often it is set and its most common values. Use it to follow the instance's own
143
+ * conventions — which fields approvals reference, how task values are templated, … .
144
+ *
145
+ * @param nameOrSysId Definition sys_id or exact name
146
+ */
147
+ getActivityUsage(nameOrSysId: string, options?: GetActivityUsageOptions): Promise<ActivityUsage>;
148
+ /**
149
+ * Export one workflow version as a complete, self-contained definition: the workflow
150
+ * and version properties, inputs, stages, every activity with its type, labelled
151
+ * variables (defaults marked) and exits, the transitions, the activity types it uses
152
+ * (described from the instance, including whether they pause the workflow), display
153
+ * names for referenced records, the subflows it calls, and what uses it.
154
+ *
155
+ * @param workflow Workflow name or sys_id, or a version sys_id (exported as is)
156
+ */
157
+ exportWorkflow(workflow: string, options?: ExportWorkflowOptions): Promise<WorkflowExport>;
158
+ /**
159
+ * Plan the move of a workflow version to Flow Designer and write a Fluent (now-sdk)
160
+ * skeleton for it. Read-only: it exports the version and works from the export (see
161
+ * {@link planFlowConversion} and {@link generateFluentFlow} to work from a saved export).
162
+ *
163
+ * @param workflow Workflow name or sys_id, or a version sys_id
164
+ */
165
+ convertToFlow(workflow: string, options?: ExportWorkflowOptions & FluentGeneratorOptions): Promise<WorkflowFlowConversion>;
166
+ /**
167
+ * Run the Workflow Editor's validation ("Validate Workflow") without publishing.
168
+ */
169
+ validateWorkflow(versionSysId: string): Promise<WorkflowValidationReport>;
170
+ /**
171
+ * Create a workflow the way the Workflow Editor's "New Workflow" does: a version with
172
+ * Begin and End activities joined by a transition, checked out to the current user.
173
+ *
174
+ * @throws InvalidParameterException when a workflow with this name already exists
175
+ */
176
+ newWorkflow(options: NewWorkflowOptions): Promise<NewWorkflowResult>;
177
+ /**
178
+ * Check a workflow out for editing. Like the editor, this creates a draft version —
179
+ * a full copy of the published one — checked out to the current user. If the
180
+ * current user already has a draft, that draft is returned.
181
+ *
182
+ * @param workflow Workflow name, wf_workflow sys_id or a version sys_id
183
+ * @throws Error when another user has it checked out (unless `force`)
184
+ */
185
+ checkout(workflow: string, options?: CheckoutOptions): Promise<CheckoutResult>;
186
+ /**
187
+ * The draft version of a workflow that the current user has checked out.
188
+ *
189
+ * @param workflow Workflow name, wf_workflow sys_id or a version sys_id
190
+ * @throws Error when the workflow is not checked out, or is checked out by someone else
191
+ */
192
+ getDraftVersion(workflow: string): Promise<string>;
193
+ /**
194
+ * Publish a checked-out draft, as the editor's Publish does: validate, publish, and
195
+ * retire the previously published version. The instance records the whole workflow
196
+ * in the current update set.
197
+ *
198
+ * @throws WorkflowValidationError when validation finds critical problems, or
199
+ * warnings without `allowWarnings`
200
+ */
201
+ publish(versionSysId: string, options?: PublishOptions): Promise<PublishResult>;
202
+ /**
203
+ * Throw away a checked-out draft, keeping the published version.
204
+ *
205
+ * @throws Error when the draft is the workflow's only version (use deleteWorkflow)
206
+ */
207
+ discardCheckout(versionSysId: string): Promise<void>;
208
+ /**
209
+ * Delete a workflow and every version of it.
210
+ *
211
+ * @param workflow Workflow name, wf_workflow sys_id or a version sys_id
212
+ */
213
+ deleteWorkflow(workflow: string): Promise<void>;
214
+ /**
215
+ * Activate or deactivate a workflow (the editor's Set Active / Set Inactive).
216
+ *
217
+ * @param versionSysId The published version
218
+ */
219
+ setWorkflowActive(versionSysId: string, active: boolean): Promise<void>;
220
+ /**
221
+ * Change a draft's workflow properties.
222
+ */
223
+ updateWorkflowProperties(versionSysId: string, options: UpdateWorkflowPropertiesOptions): Promise<void>;
224
+ /**
225
+ * Add an activity to a checked-out draft, configured with variables, and optionally
226
+ * wire it in. The activity is created through the editor's activity form, so its
227
+ * variables are written and its default exits are created exactly as in the UI.
228
+ */
229
+ addActivity(versionSysId: string, options: AddActivityOptions): Promise<AddActivityResult>;
230
+ /**
231
+ * Change an activity on a checked-out draft. Variables you do not pass keep their values.
232
+ */
233
+ updateActivity(activitySysId: string, options: UpdateActivityOptions): Promise<void>;
234
+ /**
235
+ * Remove an activity (with its exits and variables) from a checked-out draft.
236
+ */
237
+ removeActivity(activitySysId: string, options?: RemoveActivityOptions): Promise<void>;
238
+ /**
239
+ * Reposition activities on checked-out drafts.
240
+ */
241
+ moveActivities(positions: ActivityPosition[]): Promise<void>;
242
+ /**
243
+ * Add a transition on a checked-out draft.
244
+ *
245
+ * @returns The new transition's sys_id
246
+ */
247
+ addTransition(options: AddTransitionOptions): Promise<string>;
248
+ /**
249
+ * Point an existing transition at a different activity on a checked-out draft.
250
+ */
251
+ retargetTransition(transitionSysId: string, toActivitySysId: string): Promise<void>;
252
+ /**
253
+ * Remove a transition from a checked-out draft.
254
+ */
255
+ removeTransition(transitionSysId: string): Promise<void>;
256
+ /**
257
+ * Add an exit to an activity on a checked-out draft.
258
+ *
259
+ * @returns The new condition's sys_id
260
+ */
261
+ addCondition(options: AddConditionOptions): Promise<string>;
262
+ /**
263
+ * Change an exit on a checked-out draft.
264
+ */
265
+ updateCondition(conditionSysId: string, options: UpdateConditionOptions): Promise<void>;
266
+ /**
267
+ * Remove an exit, and the transitions leaving from it, from a checked-out draft.
268
+ */
269
+ removeCondition(conditionSysId: string): Promise<void>;
270
+ private createActivityThroughForm;
271
+ private summarize;
272
+ private readVersion;
273
+ /**
274
+ * Editing is only allowed on an unpublished draft checked out to the current user —
275
+ * the same rule the editor enforces (and the wf_condition ACLs require a checkout).
276
+ */
277
+ private requireDraft;
278
+ private readActivity;
279
+ private readTransition;
280
+ private readCondition;
281
+ private readConditions;
282
+ private readVariableValues;
283
+ private resolveActivityDefinition;
284
+ private resolveStage;
285
+ /**
286
+ * Pick an exit by name or sys_id. With no reference, a single exit is unambiguous;
287
+ * for several, `firstWhenAmbiguous` takes the first in order (what the editor does
288
+ * when you drop onto a line), otherwise the caller must choose.
289
+ */
290
+ private pickExit;
291
+ private defaultPosition;
292
+ /**
293
+ * The version to read for a workflow reference: a version sys_id as is; otherwise the
294
+ * current user's draft and/or the published version, as asked.
295
+ */
296
+ private resolveVersionToRead;
297
+ /**
298
+ * Whether a core activity type can pause the workflow, read from its handler script:
299
+ * it sets `activity.state` / `executing.state` to `'waiting'`, itself or in a handler it
300
+ * extends. Some only wait conditionally (tasks honour `wait_for_completion`).
301
+ */
302
+ private typeWaits;
303
+ /** Display names for sys_ids, grouped by table. Unknown tables or records are skipped. */
304
+ private displayNames;
305
+ private findingsOrEmpty;
306
+ private currentUserSysId;
307
+ private read;
308
+ private count;
309
+ private request;
310
+ private requireSysId;
81
311
  }