@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.
- package/README.md +6 -0
- package/dist/comm/http/FormHtmlParser.d.ts +34 -0
- package/dist/comm/http/FormHtmlParser.js +227 -0
- package/dist/comm/http/FormHtmlParser.js.map +1 -0
- package/dist/comm/http/FormRecordModels.d.ts +120 -0
- package/dist/comm/http/FormRecordModels.js +6 -0
- package/dist/comm/http/FormRecordModels.js.map +1 -0
- package/dist/comm/http/FormRecordWriter.d.ts +99 -0
- package/dist/comm/http/FormRecordWriter.js +385 -0
- package/dist/comm/http/FormRecordWriter.js.map +1 -0
- package/dist/comm/http/HTTPRequest.d.ts +4 -0
- package/dist/comm/http/RequestHandler.d.ts +1 -0
- package/dist/comm/http/RequestHandler.js +34 -22
- package/dist/comm/http/RequestHandler.js.map +1 -1
- package/dist/comm/http/internal/FormTransportModels.d.ts +26 -0
- package/dist/comm/http/internal/FormTransportModels.js +2 -0
- package/dist/comm/http/internal/FormTransportModels.js.map +1 -0
- package/dist/exception/FormSubmitError.d.ts +13 -0
- package/dist/exception/FormSubmitError.js +19 -0
- package/dist/exception/FormSubmitError.js.map +1 -0
- package/dist/exception/WorkflowValidationError.d.ts +24 -0
- package/dist/exception/WorkflowValidationError.js +24 -0
- package/dist/exception/WorkflowValidationError.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/dist/sn/metadata/MetadataFormWriter.d.ts +13 -0
- package/dist/sn/metadata/MetadataFormWriter.js +264 -0
- package/dist/sn/metadata/MetadataFormWriter.js.map +1 -0
- package/dist/sn/metadata/MetadataModels.d.ts +44 -0
- package/dist/sn/metadata/MetadataModels.js +2 -0
- package/dist/sn/metadata/MetadataModels.js.map +1 -0
- package/dist/sn/metadata/MetadataScopeError.d.ts +5 -0
- package/dist/sn/metadata/MetadataScopeError.js +10 -0
- package/dist/sn/metadata/MetadataScopeError.js.map +1 -0
- package/dist/sn/metadata/MetadataVerificationError.d.ts +11 -0
- package/dist/sn/metadata/MetadataVerificationError.js +20 -0
- package/dist/sn/metadata/MetadataVerificationError.js.map +1 -0
- package/dist/sn/metadata/internal/MetadataPreferences.d.ts +12 -0
- package/dist/sn/metadata/internal/MetadataPreferences.js +27 -0
- package/dist/sn/metadata/internal/MetadataPreferences.js.map +1 -0
- package/dist/sn/metadata/internal/MetadataReader.d.ts +9 -0
- package/dist/sn/metadata/internal/MetadataReader.js +55 -0
- package/dist/sn/metadata/internal/MetadataReader.js.map +1 -0
- package/dist/sn/variables/VariableDefinitions.d.ts +23 -0
- package/dist/sn/variables/VariableDefinitions.js +106 -0
- package/dist/sn/variables/VariableDefinitions.js.map +1 -0
- package/dist/sn/variables/VariableModels.d.ts +49 -0
- package/dist/sn/variables/VariableModels.js +6 -0
- package/dist/sn/variables/VariableModels.js.map +1 -0
- package/dist/sn/workflow/WorkflowConversionModels.d.ts +209 -0
- package/dist/sn/workflow/WorkflowConversionModels.js +2 -0
- package/dist/sn/workflow/WorkflowConversionModels.js.map +1 -0
- package/dist/sn/workflow/WorkflowDiagramClient.d.ts +70 -0
- package/dist/sn/workflow/WorkflowDiagramClient.js +151 -0
- package/dist/sn/workflow/WorkflowDiagramClient.js.map +1 -0
- package/dist/sn/workflow/WorkflowFlowConversion.d.ts +19 -0
- package/dist/sn/workflow/WorkflowFlowConversion.js +1013 -0
- package/dist/sn/workflow/WorkflowFlowConversion.js.map +1 -0
- package/dist/sn/workflow/WorkflowFlowHints.d.ts +3 -0
- package/dist/sn/workflow/WorkflowFlowHints.js +36 -0
- package/dist/sn/workflow/WorkflowFlowHints.js.map +1 -0
- package/dist/sn/workflow/WorkflowFluentGenerator.d.ts +17 -0
- package/dist/sn/workflow/WorkflowFluentGenerator.js +348 -0
- package/dist/sn/workflow/WorkflowFluentGenerator.js.map +1 -0
- package/dist/sn/workflow/WorkflowGraphML.d.ts +39 -0
- package/dist/sn/workflow/WorkflowGraphML.js +162 -0
- package/dist/sn/workflow/WorkflowGraphML.js.map +1 -0
- package/dist/sn/workflow/WorkflowManager.d.ts +236 -6
- package/dist/sn/workflow/WorkflowManager.js +1443 -15
- package/dist/sn/workflow/WorkflowManager.js.map +1 -1
- package/dist/sn/workflow/WorkflowModels.d.ts +738 -0
- package/dist/sn/workflow/WorkflowStructure.d.ts +137 -0
- package/dist/sn/workflow/WorkflowStructure.js +368 -0
- package/dist/sn/workflow/WorkflowStructure.js.map +1 -0
- package/dist/sn/workflow/WorkflowViews.d.ts +104 -0
- package/dist/sn/workflow/WorkflowViews.js +408 -0
- package/dist/sn/workflow/WorkflowViews.js.map +1 -0
- package/package.json +2 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Models for workflow management operations in ServiceNow.
|
|
3
3
|
*/
|
|
4
|
+
import { FormValueInput } from '../../comm/http/FormRecordModels.js';
|
|
5
|
+
import { VariableDefinition } from '../variables/VariableModels.js';
|
|
4
6
|
/**
|
|
5
7
|
* Options for creating a workflow record.
|
|
6
8
|
*/
|
|
@@ -75,6 +77,12 @@ export interface CreateActivityOptions {
|
|
|
75
77
|
script?: string;
|
|
76
78
|
/** Activity variables (JSON string or comma-separated key=value pairs) */
|
|
77
79
|
vars?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Variable values keyed by element name. When set, the activity is created through
|
|
82
|
+
* the wf_activity form, which is what writes variables; `activityDefinitionSysId` is
|
|
83
|
+
* then required and `script`/`vars` are not used.
|
|
84
|
+
*/
|
|
85
|
+
variables?: Record<string, FormValueInput>;
|
|
78
86
|
}
|
|
79
87
|
/**
|
|
80
88
|
* Result of creating a workflow activity.
|
|
@@ -162,6 +170,8 @@ export interface ActivitySpec {
|
|
|
162
170
|
height?: number;
|
|
163
171
|
/** Activity variables */
|
|
164
172
|
vars?: string;
|
|
173
|
+
/** Variable values keyed by element name (see CreateActivityOptions.variables) */
|
|
174
|
+
variables?: Record<string, FormValueInput>;
|
|
165
175
|
}
|
|
166
176
|
/**
|
|
167
177
|
* Specification for a transition between activities in a complete workflow.
|
|
@@ -240,3 +250,731 @@ export interface WorkflowRecordResponse {
|
|
|
240
250
|
export interface WorkflowRecordListResponse {
|
|
241
251
|
result: WorkflowRecord[];
|
|
242
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* An activity on a workflow diagram, as the editor's diagram processor reports it.
|
|
255
|
+
*/
|
|
256
|
+
export interface WorkflowGraphNode {
|
|
257
|
+
/** wf_activity sys_id */
|
|
258
|
+
id: string;
|
|
259
|
+
/** The activity's own name */
|
|
260
|
+
name: string;
|
|
261
|
+
/** The activity type's name (e.g. "Timer") */
|
|
262
|
+
typeName: string;
|
|
263
|
+
/** Activity definition sys_id */
|
|
264
|
+
activityDefinition: string;
|
|
265
|
+
x?: number;
|
|
266
|
+
y?: number;
|
|
267
|
+
width?: number;
|
|
268
|
+
height?: number;
|
|
269
|
+
/** wf_stage sys_id */
|
|
270
|
+
stage?: string;
|
|
271
|
+
/** Parent activity sys_id, for activities nested in a container activity */
|
|
272
|
+
parent?: string;
|
|
273
|
+
/** Whether this activity contains child activities */
|
|
274
|
+
isParent: boolean;
|
|
275
|
+
/** False for Begin and End, which the editor will not delete */
|
|
276
|
+
deletable: boolean;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* An exit (wf_condition) on a diagram activity.
|
|
280
|
+
*/
|
|
281
|
+
export interface WorkflowGraphPort {
|
|
282
|
+
/** wf_condition sys_id */
|
|
283
|
+
id: string;
|
|
284
|
+
/** wf_activity sys_id the exit belongs to */
|
|
285
|
+
node: string;
|
|
286
|
+
name: string;
|
|
287
|
+
order: number;
|
|
288
|
+
error: boolean;
|
|
289
|
+
event: boolean;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* A transition (wf_transition) on a diagram.
|
|
293
|
+
*/
|
|
294
|
+
export interface WorkflowGraphEdge {
|
|
295
|
+
/** wf_transition sys_id */
|
|
296
|
+
id: string;
|
|
297
|
+
/** wf_activity sys_id the transition leaves */
|
|
298
|
+
source: string;
|
|
299
|
+
/** wf_condition sys_id the transition leaves from */
|
|
300
|
+
sourcePort: string;
|
|
301
|
+
/** wf_activity sys_id the transition enters */
|
|
302
|
+
target: string;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* A workflow version as the Workflow Editor's diagram processor sees it, including what
|
|
306
|
+
* the current user may do with it.
|
|
307
|
+
*/
|
|
308
|
+
export interface WorkflowGraph {
|
|
309
|
+
/** wf_workflow_version sys_id */
|
|
310
|
+
id: string;
|
|
311
|
+
/** wf_workflow sys_id */
|
|
312
|
+
workflowSysId: string;
|
|
313
|
+
name: string;
|
|
314
|
+
table: string;
|
|
315
|
+
published: boolean;
|
|
316
|
+
active: boolean;
|
|
317
|
+
/** True unless the version is a draft the current user can edit */
|
|
318
|
+
readOnly: boolean;
|
|
319
|
+
canCheckout: boolean;
|
|
320
|
+
canForceCheckout: boolean;
|
|
321
|
+
canPublish: boolean;
|
|
322
|
+
canDelete: boolean;
|
|
323
|
+
/** e.g. "Published", "Checked out by me" */
|
|
324
|
+
statusDisplay: string;
|
|
325
|
+
/** Activity sys_ids along the workflow's paths, as computed at publish */
|
|
326
|
+
fullSequences: string[];
|
|
327
|
+
/** Every graph property the processor returned, verbatim */
|
|
328
|
+
properties: Record<string, string>;
|
|
329
|
+
/** Activity type names keyed by activity definition sys_id (the editor's palette) */
|
|
330
|
+
activityTypes: Record<string, string>;
|
|
331
|
+
nodes: WorkflowGraphNode[];
|
|
332
|
+
ports: WorkflowGraphPort[];
|
|
333
|
+
edges: WorkflowGraphEdge[];
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* A workflow (wf_workflow) with the state of its versions.
|
|
337
|
+
*/
|
|
338
|
+
export interface WorkflowSummary {
|
|
339
|
+
/** wf_workflow sys_id */
|
|
340
|
+
sysId: string;
|
|
341
|
+
name: string;
|
|
342
|
+
table: string;
|
|
343
|
+
description: string;
|
|
344
|
+
/** sys_id of the published version, if any */
|
|
345
|
+
publishedVersionSysId?: string;
|
|
346
|
+
/** The draft version, if someone has the workflow checked out */
|
|
347
|
+
checkedOutVersion?: {
|
|
348
|
+
sysId: string;
|
|
349
|
+
checkedOutBy: string;
|
|
350
|
+
checkedOutByName?: string;
|
|
351
|
+
checkedOutOn: string;
|
|
352
|
+
/** Whether the current user holds the draft */
|
|
353
|
+
byCurrentUser: boolean;
|
|
354
|
+
};
|
|
355
|
+
/** Whether the published (or only) version is active */
|
|
356
|
+
active: boolean;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* A workflow version (wf_workflow_version).
|
|
360
|
+
*/
|
|
361
|
+
export interface WorkflowVersionSummary {
|
|
362
|
+
sysId: string;
|
|
363
|
+
workflowSysId: string;
|
|
364
|
+
name: string;
|
|
365
|
+
table: string;
|
|
366
|
+
published: boolean;
|
|
367
|
+
active: boolean;
|
|
368
|
+
/** When the version was checked out; empty unless it is a draft */
|
|
369
|
+
checkedOut: string;
|
|
370
|
+
/** sys_user sys_id of the user holding the draft; empty unless it is a draft */
|
|
371
|
+
checkedOutBy: string;
|
|
372
|
+
createdOn: string;
|
|
373
|
+
updatedOn: string;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Options for finding workflows.
|
|
377
|
+
*/
|
|
378
|
+
export interface FindWorkflowsOptions {
|
|
379
|
+
/** Name contains this text */
|
|
380
|
+
name?: string;
|
|
381
|
+
/** Workflow table (e.g. "sc_req_item") */
|
|
382
|
+
table?: string;
|
|
383
|
+
/** Additional encoded query on wf_workflow */
|
|
384
|
+
query?: string;
|
|
385
|
+
/** Maximum number of workflows to return. Defaults to 50. */
|
|
386
|
+
limit?: number;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* An activity exit (wf_condition).
|
|
390
|
+
*/
|
|
391
|
+
export interface WorkflowConditionInfo {
|
|
392
|
+
sysId: string;
|
|
393
|
+
activitySysId: string;
|
|
394
|
+
name: string;
|
|
395
|
+
/** JavaScript condition, e.g. `activity.result == 'approved'` */
|
|
396
|
+
condition: string;
|
|
397
|
+
order: number;
|
|
398
|
+
elseFlag: boolean;
|
|
399
|
+
error: boolean;
|
|
400
|
+
event: boolean;
|
|
401
|
+
eventName: string;
|
|
402
|
+
shortDescription: string;
|
|
403
|
+
skipDuringGenerate: boolean;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* A transition (wf_transition).
|
|
407
|
+
*/
|
|
408
|
+
export interface WorkflowTransitionInfo {
|
|
409
|
+
sysId: string;
|
|
410
|
+
/** wf_activity sys_id */
|
|
411
|
+
from: string;
|
|
412
|
+
/** wf_activity sys_id */
|
|
413
|
+
to: string;
|
|
414
|
+
/** wf_condition sys_id the transition leaves from */
|
|
415
|
+
condition: string;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* A workflow stage (wf_stage).
|
|
419
|
+
*/
|
|
420
|
+
export interface WorkflowStageInfo {
|
|
421
|
+
sysId: string;
|
|
422
|
+
name: string;
|
|
423
|
+
value: string;
|
|
424
|
+
order: number;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* An activity (wf_activity) with its configuration.
|
|
428
|
+
*/
|
|
429
|
+
export interface WorkflowActivityInfo {
|
|
430
|
+
sysId: string;
|
|
431
|
+
name: string;
|
|
432
|
+
/** Activity definition sys_id */
|
|
433
|
+
definitionSysId: string;
|
|
434
|
+
/** Activity type name (e.g. "Timer") */
|
|
435
|
+
definitionName: string;
|
|
436
|
+
x?: number;
|
|
437
|
+
y?: number;
|
|
438
|
+
width?: number;
|
|
439
|
+
height?: number;
|
|
440
|
+
/** wf_stage sys_id */
|
|
441
|
+
stage?: string;
|
|
442
|
+
/** Parent activity sys_id, for activities nested in a container activity */
|
|
443
|
+
parent?: string;
|
|
444
|
+
/** Activity Designer input mapping (JSON text); empty for core activities */
|
|
445
|
+
input: string;
|
|
446
|
+
/** Variable values keyed by element name (present when variables were requested) */
|
|
447
|
+
variables?: Record<string, string>;
|
|
448
|
+
/** The activity's exits, in order */
|
|
449
|
+
conditions: WorkflowConditionInfo[];
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Everything that makes up one workflow version.
|
|
453
|
+
*/
|
|
454
|
+
export interface WorkflowDefinition {
|
|
455
|
+
workflowSysId: string;
|
|
456
|
+
versionSysId: string;
|
|
457
|
+
name: string;
|
|
458
|
+
table: string;
|
|
459
|
+
description: string;
|
|
460
|
+
/** Trigger condition (encoded query) */
|
|
461
|
+
condition: string;
|
|
462
|
+
/** e.g. "run_match", or empty for none */
|
|
463
|
+
conditionType: string;
|
|
464
|
+
published: boolean;
|
|
465
|
+
active: boolean;
|
|
466
|
+
checkedOut: string;
|
|
467
|
+
checkedOutBy: string;
|
|
468
|
+
/** Begin activity sys_id */
|
|
469
|
+
start: string;
|
|
470
|
+
/** Activity sys_ids along the workflow's paths, as computed at publish */
|
|
471
|
+
fullSequences: string[];
|
|
472
|
+
/** What the current user may do with this version (present when status was requested) */
|
|
473
|
+
status?: {
|
|
474
|
+
readOnly: boolean;
|
|
475
|
+
canCheckout: boolean;
|
|
476
|
+
canForceCheckout: boolean;
|
|
477
|
+
canPublish: boolean;
|
|
478
|
+
statusDisplay: string;
|
|
479
|
+
};
|
|
480
|
+
activities: WorkflowActivityInfo[];
|
|
481
|
+
transitions: WorkflowTransitionInfo[];
|
|
482
|
+
stages: WorkflowStageInfo[];
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Options for reading a workflow definition.
|
|
486
|
+
*/
|
|
487
|
+
export interface GetWorkflowDefinitionOptions {
|
|
488
|
+
/** Include activity variable values. Defaults to true. */
|
|
489
|
+
includeVariables?: boolean;
|
|
490
|
+
/** Include the current user's permissions from the diagram processor. Defaults to true. */
|
|
491
|
+
includeStatus?: boolean;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* An activity type (wf_activity_definition, or an Activity Designer wf_element_activity).
|
|
495
|
+
*/
|
|
496
|
+
export interface ActivityDefinitionSummary {
|
|
497
|
+
sysId: string;
|
|
498
|
+
name: string;
|
|
499
|
+
category: string;
|
|
500
|
+
/** `wf_activity_definition` for core activities, `wf_element_activity` for Activity Designer ones */
|
|
501
|
+
sysClassName: string;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Options for listing activity types.
|
|
505
|
+
*/
|
|
506
|
+
export interface ListActivityDefinitionsOptions {
|
|
507
|
+
/** Name contains this text */
|
|
508
|
+
name?: string;
|
|
509
|
+
/** Category (e.g. "Approvals", "Timers") */
|
|
510
|
+
category?: string;
|
|
511
|
+
/** Include Activity Designer / Orchestration activities. Defaults to true. */
|
|
512
|
+
includeDesigner?: boolean;
|
|
513
|
+
/** Maximum number to return. Defaults to 500. */
|
|
514
|
+
limit?: number;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* A default exit an activity type gives every new activity (wf_condition_default).
|
|
518
|
+
*/
|
|
519
|
+
export interface DefaultConditionInfo {
|
|
520
|
+
name: string;
|
|
521
|
+
condition: string;
|
|
522
|
+
order: number;
|
|
523
|
+
elseFlag: boolean;
|
|
524
|
+
error: boolean;
|
|
525
|
+
skipDuringGenerate: boolean;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* An activity type with the variables its activities carry and the exits they start with.
|
|
529
|
+
*/
|
|
530
|
+
export interface ActivityDefinitionDetail extends ActivityDefinitionSummary {
|
|
531
|
+
/**
|
|
532
|
+
* The type's own documentation, as written on the instance: what it does and the
|
|
533
|
+
* results (exits) it produces. Often the best single explanation of the type.
|
|
534
|
+
*/
|
|
535
|
+
description: string;
|
|
536
|
+
/** Definition attributes, e.g. `generate=approval,approval=true`, `begin=true` */
|
|
537
|
+
attributes: string;
|
|
538
|
+
/** Variables (core activities); empty for Activity Designer activities, which use `input` */
|
|
539
|
+
variables: VariableDefinition[];
|
|
540
|
+
/** Exits a new activity of this type starts with. Empty means a single "Always" exit. */
|
|
541
|
+
defaultConditions: DefaultConditionInfo[];
|
|
542
|
+
/** Activity Designer inputs, set through the activity's `input` JSON keyed by `name` */
|
|
543
|
+
inputs?: ActivityDesignerField[];
|
|
544
|
+
/** Activity Designer outputs (`activityOutput.<name>`), which its exits test */
|
|
545
|
+
outputs?: ActivityDesignerField[];
|
|
546
|
+
/**
|
|
547
|
+
* The implementation, when requested: a core type's handler script (how each
|
|
548
|
+
* variable is read and which `activity.result` values it sets), or an Activity
|
|
549
|
+
* Designer type's output processing script.
|
|
550
|
+
*/
|
|
551
|
+
script?: string;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* An Activity Designer input or output.
|
|
555
|
+
*/
|
|
556
|
+
export interface ActivityDesignerField {
|
|
557
|
+
name: string;
|
|
558
|
+
/** e.g. STRING, BOOLEAN, INTEGER, DATA_OBJECT */
|
|
559
|
+
type: string;
|
|
560
|
+
mandatory: boolean;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Options for describing an activity type.
|
|
564
|
+
*/
|
|
565
|
+
export interface GetActivityDefinitionOptions {
|
|
566
|
+
/** Include the implementation script. Defaults to false (scripts run to several KB). */
|
|
567
|
+
includeScript?: boolean;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* How published workflows on the instance configure an activity type: for each variable
|
|
571
|
+
* (or Activity Designer input), how often it is set and its most common values.
|
|
572
|
+
*/
|
|
573
|
+
export interface ActivityUsage {
|
|
574
|
+
definitionSysId: string;
|
|
575
|
+
definitionName: string;
|
|
576
|
+
/** Activities of this type in published workflow versions */
|
|
577
|
+
publishedActivities: number;
|
|
578
|
+
/** Activities sampled to build the examples */
|
|
579
|
+
sampled: number;
|
|
580
|
+
/** Per variable or input, in definition order */
|
|
581
|
+
fields: Array<{
|
|
582
|
+
name: string;
|
|
583
|
+
/** Sampled activities with a non-empty value */
|
|
584
|
+
setCount: number;
|
|
585
|
+
/** Most common values (trimmed to `maxValueLength`); `isDefault` marks the type's untouched default */
|
|
586
|
+
examples: Array<{
|
|
587
|
+
value: string;
|
|
588
|
+
count: number;
|
|
589
|
+
isDefault: boolean;
|
|
590
|
+
}>;
|
|
591
|
+
}>;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Options for reading how an activity type is used.
|
|
595
|
+
*/
|
|
596
|
+
export interface GetActivityUsageOptions {
|
|
597
|
+
/** Activities to sample. Defaults to 100. */
|
|
598
|
+
sampleSize?: number;
|
|
599
|
+
/** Examples per field. Defaults to 5. */
|
|
600
|
+
examplesPerField?: number;
|
|
601
|
+
/** Longest example value kept, in characters. Defaults to 300. */
|
|
602
|
+
maxValueLength?: number;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Options for creating a workflow the way the Workflow Editor does.
|
|
606
|
+
*/
|
|
607
|
+
export interface NewWorkflowOptions {
|
|
608
|
+
/** Workflow name; must be unique */
|
|
609
|
+
name: string;
|
|
610
|
+
/** Table the workflow runs on (e.g. "incident", "sc_req_item") */
|
|
611
|
+
table: string;
|
|
612
|
+
description?: string;
|
|
613
|
+
/** Trigger condition (encoded query) */
|
|
614
|
+
condition?: string;
|
|
615
|
+
/** Trigger condition type, e.g. "run_match". Defaults to the instance default. */
|
|
616
|
+
conditionType?: string;
|
|
617
|
+
/** Additional wf_workflow_version fields to set, keyed by column name */
|
|
618
|
+
fields?: Record<string, string | number | boolean>;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Result of creating a workflow. The new version is a draft checked out to the current user.
|
|
622
|
+
*/
|
|
623
|
+
export interface NewWorkflowResult {
|
|
624
|
+
workflowSysId: string;
|
|
625
|
+
versionSysId: string;
|
|
626
|
+
beginActivitySysId: string;
|
|
627
|
+
endActivitySysId: string;
|
|
628
|
+
/** The Begin activity's "Always" exit */
|
|
629
|
+
beginConditionSysId: string;
|
|
630
|
+
/** The Begin → End transition */
|
|
631
|
+
transitionSysId: string;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Options for checking out a workflow.
|
|
635
|
+
*/
|
|
636
|
+
export interface CheckoutOptions {
|
|
637
|
+
/** Take the checkout from another user (the editor's "Force Checkout") */
|
|
638
|
+
force?: boolean;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Result of a checkout.
|
|
642
|
+
*/
|
|
643
|
+
export interface CheckoutResult {
|
|
644
|
+
workflowSysId: string;
|
|
645
|
+
/** The draft version to edit */
|
|
646
|
+
versionSysId: string;
|
|
647
|
+
/** True when the current user already had this draft checked out */
|
|
648
|
+
alreadyCheckedOut: boolean;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Options for publishing.
|
|
652
|
+
*/
|
|
653
|
+
export interface PublishOptions {
|
|
654
|
+
/**
|
|
655
|
+
* Publish even when validation reports warnings (the editor's "Publish this workflow
|
|
656
|
+
* with warnings?" prompt). Critical findings always block. Defaults to false.
|
|
657
|
+
*/
|
|
658
|
+
allowWarnings?: boolean;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Result of publishing.
|
|
662
|
+
*/
|
|
663
|
+
export interface PublishResult {
|
|
664
|
+
versionSysId: string;
|
|
665
|
+
/** Validation findings at Warn level that were accepted */
|
|
666
|
+
warnings: WorkflowValidationItem[];
|
|
667
|
+
/** Activity sys_ids along the workflow's paths, as computed at publish */
|
|
668
|
+
fullSequences: string[];
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* One validation check result.
|
|
672
|
+
*/
|
|
673
|
+
export interface WorkflowValidationItem {
|
|
674
|
+
/** Check name, e.g. "ValidateTransitionOut" */
|
|
675
|
+
type: string;
|
|
676
|
+
/** "Info", "Warn" or "Critical" */
|
|
677
|
+
level: string;
|
|
678
|
+
message: string;
|
|
679
|
+
details: string;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* The Workflow Editor's validation report for a version.
|
|
683
|
+
*/
|
|
684
|
+
export interface WorkflowValidationReport {
|
|
685
|
+
versionSysId: string;
|
|
686
|
+
/** e.g. "Validate Summary - Workflow version contains Warnings - Total checks performed:16 (Info:14, Warn:2, Critical:0)" */
|
|
687
|
+
summary: string;
|
|
688
|
+
/** True when no check reported Warn or Critical */
|
|
689
|
+
valid: boolean;
|
|
690
|
+
items: WorkflowValidationItem[];
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Where a new activity connects.
|
|
694
|
+
*/
|
|
695
|
+
export interface ActivityConnection {
|
|
696
|
+
/** Activity sys_id */
|
|
697
|
+
activity: string;
|
|
698
|
+
/** Exit name or wf_condition sys_id. Required when the activity has more than one exit. */
|
|
699
|
+
condition?: string;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Options for adding an activity to a checked-out workflow version.
|
|
703
|
+
*/
|
|
704
|
+
export interface AddActivityOptions {
|
|
705
|
+
/** Activity type: definition sys_id or exact name (e.g. "Timer", "Approval - User") */
|
|
706
|
+
definition: string;
|
|
707
|
+
/** The activity's name */
|
|
708
|
+
name: string;
|
|
709
|
+
/** Canvas position. Defaults to the middle of `insertOn`, or to the right of `connectFrom`. */
|
|
710
|
+
x?: number;
|
|
711
|
+
y?: number;
|
|
712
|
+
/** Stage: wf_stage sys_id, name or value */
|
|
713
|
+
stage?: string;
|
|
714
|
+
/** Variable values keyed by element name; see getActivityDefinition() for what a type accepts */
|
|
715
|
+
variables?: Record<string, FormValueInput>;
|
|
716
|
+
/** Activity Designer input mapping (object or JSON text) */
|
|
717
|
+
input?: string | Record<string, unknown>;
|
|
718
|
+
/**
|
|
719
|
+
* Drop the activity onto this transition, as the editor does when you drop onto a
|
|
720
|
+
* line: the transition is re-pointed at the new activity, and a new transition runs
|
|
721
|
+
* from the new activity to the original target.
|
|
722
|
+
*/
|
|
723
|
+
insertOn?: string;
|
|
724
|
+
/** Add a transition into the new activity from this activity and exit */
|
|
725
|
+
connectFrom?: ActivityConnection;
|
|
726
|
+
/** Add a transition from the new activity to this activity */
|
|
727
|
+
connectTo?: string;
|
|
728
|
+
/**
|
|
729
|
+
* Which of the new activity's exits feeds `insertOn` / `connectTo` (name or sys_id).
|
|
730
|
+
* Defaults to its first exit, as the editor does.
|
|
731
|
+
*/
|
|
732
|
+
exitCondition?: string;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Result of adding an activity.
|
|
736
|
+
*/
|
|
737
|
+
export interface AddActivityResult {
|
|
738
|
+
activitySysId: string;
|
|
739
|
+
name: string;
|
|
740
|
+
/** The exits the activity was created with */
|
|
741
|
+
conditions: WorkflowConditionInfo[];
|
|
742
|
+
/** Transitions created or re-pointed to wire the activity in */
|
|
743
|
+
transitionSysIds: string[];
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Options for updating an activity. Omitted values are left unchanged.
|
|
747
|
+
*/
|
|
748
|
+
export interface UpdateActivityOptions {
|
|
749
|
+
name?: string;
|
|
750
|
+
variables?: Record<string, FormValueInput>;
|
|
751
|
+
input?: string | Record<string, unknown>;
|
|
752
|
+
/** Stage: wf_stage sys_id, name or value; empty string clears it */
|
|
753
|
+
stage?: string;
|
|
754
|
+
x?: number;
|
|
755
|
+
y?: number;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Options for removing an activity.
|
|
759
|
+
*/
|
|
760
|
+
export interface RemoveActivityOptions {
|
|
761
|
+
/**
|
|
762
|
+
* When the activity has exactly one incoming and one outgoing transition, join them
|
|
763
|
+
* so the flow stays connected. Otherwise every transition touching it is removed.
|
|
764
|
+
*/
|
|
765
|
+
reconnect?: boolean;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Options for adding a transition.
|
|
769
|
+
*/
|
|
770
|
+
export interface AddTransitionOptions {
|
|
771
|
+
/** Source activity sys_id */
|
|
772
|
+
from: string;
|
|
773
|
+
/** Target activity sys_id */
|
|
774
|
+
to: string;
|
|
775
|
+
/** Exit on `from`: name or wf_condition sys_id. Required when `from` has more than one exit. */
|
|
776
|
+
condition?: string;
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Options for adding an exit to an activity.
|
|
780
|
+
*/
|
|
781
|
+
export interface AddConditionOptions {
|
|
782
|
+
/** Activity sys_id */
|
|
783
|
+
activity: string;
|
|
784
|
+
name: string;
|
|
785
|
+
/** JavaScript condition, e.g. `activity.result == 'skipped'` */
|
|
786
|
+
condition: string;
|
|
787
|
+
order?: number;
|
|
788
|
+
elseFlag?: boolean;
|
|
789
|
+
error?: boolean;
|
|
790
|
+
shortDescription?: string;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Options for updating an exit. Omitted values are left unchanged.
|
|
794
|
+
*/
|
|
795
|
+
export interface UpdateConditionOptions {
|
|
796
|
+
name?: string;
|
|
797
|
+
condition?: string;
|
|
798
|
+
order?: number;
|
|
799
|
+
elseFlag?: boolean;
|
|
800
|
+
error?: boolean;
|
|
801
|
+
shortDescription?: string;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* A new canvas position for an activity.
|
|
805
|
+
*/
|
|
806
|
+
export interface ActivityPosition {
|
|
807
|
+
sysId: string;
|
|
808
|
+
x: number;
|
|
809
|
+
y: number;
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Workflow properties to change on a draft. Omitted values are left unchanged.
|
|
813
|
+
*/
|
|
814
|
+
export interface UpdateWorkflowPropertiesOptions {
|
|
815
|
+
name?: string;
|
|
816
|
+
description?: string;
|
|
817
|
+
/** Trigger condition (encoded query) */
|
|
818
|
+
condition?: string;
|
|
819
|
+
conditionType?: string;
|
|
820
|
+
/** Additional wf_workflow_version fields to set, keyed by column name */
|
|
821
|
+
fields?: Record<string, string | number | boolean>;
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Options for exporting a workflow.
|
|
825
|
+
*/
|
|
826
|
+
export interface ExportWorkflowOptions {
|
|
827
|
+
/**
|
|
828
|
+
* Which version to export when given a workflow (not a version sys_id): `current`
|
|
829
|
+
* (your draft if you have one, else the published version — the default),
|
|
830
|
+
* `published`, or `draft` (your draft).
|
|
831
|
+
*/
|
|
832
|
+
version?: 'current' | 'published' | 'draft';
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* A variable value on an exported activity.
|
|
836
|
+
*/
|
|
837
|
+
export interface WorkflowExportVariable {
|
|
838
|
+
element: string;
|
|
839
|
+
label: string;
|
|
840
|
+
/** Internal type of the variable (e.g. `script`, `glide_list`, `conditions`) */
|
|
841
|
+
type: string;
|
|
842
|
+
/** Stored value */
|
|
843
|
+
value: string;
|
|
844
|
+
/** True when the value is the activity type's untouched default */
|
|
845
|
+
isDefault: boolean;
|
|
846
|
+
/** Choice label for choice values, or display names for referenced records */
|
|
847
|
+
display?: string;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* An activity type used by an exported workflow, described from the instance.
|
|
851
|
+
*/
|
|
852
|
+
export interface WorkflowExportActivityType {
|
|
853
|
+
sysId: string;
|
|
854
|
+
name: string;
|
|
855
|
+
category: string;
|
|
856
|
+
sysClassName: string;
|
|
857
|
+
attributes: string;
|
|
858
|
+
description: string;
|
|
859
|
+
/**
|
|
860
|
+
* Whether activities of this type can pause the workflow (approvals, timers, waits,
|
|
861
|
+
* tasks, joins, subflows). Read from the type's handler script and the handlers it
|
|
862
|
+
* extends; some only wait conditionally (tasks honour their `wait_for_completion`
|
|
863
|
+
* variable). Undefined for Activity Designer types, which run through their own engine.
|
|
864
|
+
*/
|
|
865
|
+
waits?: boolean;
|
|
866
|
+
/** Activity Designer inputs and outputs */
|
|
867
|
+
inputs?: ActivityDesignerField[];
|
|
868
|
+
outputs?: ActivityDesignerField[];
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* An exit of an exported activity.
|
|
872
|
+
*/
|
|
873
|
+
export interface WorkflowExportExit {
|
|
874
|
+
sysId: string;
|
|
875
|
+
name: string;
|
|
876
|
+
condition: string;
|
|
877
|
+
order: number;
|
|
878
|
+
elseFlag: boolean;
|
|
879
|
+
error: boolean;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* An activity in an exported workflow.
|
|
883
|
+
*/
|
|
884
|
+
export interface WorkflowExportActivity {
|
|
885
|
+
sysId: string;
|
|
886
|
+
name: string;
|
|
887
|
+
/** Activity type sys_id (key of `activityTypes`) */
|
|
888
|
+
typeSysId: string;
|
|
889
|
+
/** Activity type name */
|
|
890
|
+
type: string;
|
|
891
|
+
x?: number;
|
|
892
|
+
y?: number;
|
|
893
|
+
/** Stage sys_id (see `stages`) */
|
|
894
|
+
stage?: string;
|
|
895
|
+
/** Parent activity sys_id, for activities nested in a container */
|
|
896
|
+
parent?: string;
|
|
897
|
+
/** Non-empty variable values (core types) */
|
|
898
|
+
variables: WorkflowExportVariable[];
|
|
899
|
+
/** Activity Designer input mapping */
|
|
900
|
+
input?: Record<string, unknown>;
|
|
901
|
+
/** For subflow activities: the workflow they run */
|
|
902
|
+
subflow?: {
|
|
903
|
+
workflowSysId: string;
|
|
904
|
+
name: string;
|
|
905
|
+
};
|
|
906
|
+
exits: WorkflowExportExit[];
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* A complete, self-contained definition of one workflow version: everything needed to
|
|
910
|
+
* understand, redraw or port it without going back to the instance.
|
|
911
|
+
*/
|
|
912
|
+
export interface WorkflowExport {
|
|
913
|
+
/** Format identifier, bumped on incompatible changes */
|
|
914
|
+
format: 'now-sdk-ext/legacy-workflow@1';
|
|
915
|
+
exportedAt: string;
|
|
916
|
+
workflow: {
|
|
917
|
+
sysId: string;
|
|
918
|
+
name: string;
|
|
919
|
+
table: string;
|
|
920
|
+
description: string;
|
|
921
|
+
scope: string;
|
|
922
|
+
};
|
|
923
|
+
version: {
|
|
924
|
+
sysId: string;
|
|
925
|
+
name: string;
|
|
926
|
+
published: boolean;
|
|
927
|
+
active: boolean;
|
|
928
|
+
checkedOut: string;
|
|
929
|
+
checkedOutBy: string;
|
|
930
|
+
/** Trigger condition (encoded query) and how it is applied */
|
|
931
|
+
condition: string;
|
|
932
|
+
conditionType: string;
|
|
933
|
+
order: number;
|
|
934
|
+
runMultiple: boolean;
|
|
935
|
+
afterBusinessRules: boolean;
|
|
936
|
+
stageField: string;
|
|
937
|
+
/** Script run when the workflow is cancelled */
|
|
938
|
+
onCancel: string;
|
|
939
|
+
/** Begin activity sys_id */
|
|
940
|
+
start: string;
|
|
941
|
+
fullSequences: string[];
|
|
942
|
+
};
|
|
943
|
+
/** Workflow input variables (for subflows and scripted starts) */
|
|
944
|
+
inputs: Array<{
|
|
945
|
+
name: string;
|
|
946
|
+
label: string;
|
|
947
|
+
type: string;
|
|
948
|
+
mandatory: boolean;
|
|
949
|
+
defaultValue: string;
|
|
950
|
+
}>;
|
|
951
|
+
stages: WorkflowStageInfo[];
|
|
952
|
+
/** Activity types used, keyed by sys_id */
|
|
953
|
+
activityTypes: Record<string, WorkflowExportActivityType>;
|
|
954
|
+
activities: WorkflowExportActivity[];
|
|
955
|
+
/** Transitions: from activity, via one of its exits, to activity */
|
|
956
|
+
transitions: Array<{
|
|
957
|
+
sysId: string;
|
|
958
|
+
from: string;
|
|
959
|
+
exit: string;
|
|
960
|
+
to: string;
|
|
961
|
+
}>;
|
|
962
|
+
/** Display names for sys_ids found in variable values */
|
|
963
|
+
references: Record<string, {
|
|
964
|
+
table: string;
|
|
965
|
+
display: string;
|
|
966
|
+
}>;
|
|
967
|
+
/** What starts or calls this workflow */
|
|
968
|
+
usedBy: {
|
|
969
|
+
catalogItems: Array<{
|
|
970
|
+
sysId: string;
|
|
971
|
+
name: string;
|
|
972
|
+
active: boolean;
|
|
973
|
+
}>;
|
|
974
|
+
parentWorkflows: Array<{
|
|
975
|
+
workflowSysId: string;
|
|
976
|
+
name: string;
|
|
977
|
+
versionSysId: string;
|
|
978
|
+
}>;
|
|
979
|
+
};
|
|
980
|
+
}
|