@servicenow/sdk-build-plugins 4.5.0 → 4.6.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 (144) hide show
  1. package/dist/column-plugin.js +3 -7
  2. package/dist/column-plugin.js.map +1 -1
  3. package/dist/flow/flow-logic/flow-logic-diagnostics.js +5 -5
  4. package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -1
  5. package/dist/flow/plugins/flow-action-definition-plugin.js +1229 -54
  6. package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -1
  7. package/dist/flow/plugins/flow-data-pill-plugin.js +5 -2
  8. package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -1
  9. package/dist/flow/plugins/flow-definition-plugin.js +16 -42
  10. package/dist/flow/plugins/flow-definition-plugin.js.map +1 -1
  11. package/dist/flow/plugins/flow-diagnostics-plugin.d.ts +2 -2
  12. package/dist/flow/plugins/flow-diagnostics-plugin.js +2 -2
  13. package/dist/flow/plugins/flow-instance-plugin.js +68 -22
  14. package/dist/flow/plugins/flow-instance-plugin.js.map +1 -1
  15. package/dist/flow/plugins/step-definition-plugin.js +2 -1
  16. package/dist/flow/plugins/step-definition-plugin.js.map +1 -1
  17. package/dist/flow/plugins/step-instance-plugin.d.ts +9 -1
  18. package/dist/flow/plugins/step-instance-plugin.js +649 -136
  19. package/dist/flow/plugins/step-instance-plugin.js.map +1 -1
  20. package/dist/flow/plugins/wfa-datapill-plugin.js +20 -5
  21. package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -1
  22. package/dist/flow/post-install.js +1 -0
  23. package/dist/flow/post-install.js.map +1 -1
  24. package/dist/flow/utils/complex-object-resolver.js +4 -1
  25. package/dist/flow/utils/complex-object-resolver.js.map +1 -1
  26. package/dist/flow/utils/complex-objects.js +1 -1
  27. package/dist/flow/utils/complex-objects.js.map +1 -1
  28. package/dist/flow/utils/flow-constants.d.ts +66 -2
  29. package/dist/flow/utils/flow-constants.js +402 -6
  30. package/dist/flow/utils/flow-constants.js.map +1 -1
  31. package/dist/flow/utils/flow-io-to-record.d.ts +1 -1
  32. package/dist/flow/utils/flow-io-to-record.js +37 -16
  33. package/dist/flow/utils/flow-io-to-record.js.map +1 -1
  34. package/dist/flow/utils/flow-shapes.js +4 -0
  35. package/dist/flow/utils/flow-shapes.js.map +1 -1
  36. package/dist/flow/utils/label-cache-parser.d.ts +9 -2
  37. package/dist/flow/utils/label-cache-parser.js +32 -4
  38. package/dist/flow/utils/label-cache-parser.js.map +1 -1
  39. package/dist/flow/utils/pill-shape-helpers.d.ts +15 -0
  40. package/dist/flow/utils/pill-shape-helpers.js +35 -0
  41. package/dist/flow/utils/pill-shape-helpers.js.map +1 -0
  42. package/dist/flow/utils/pill-string-parser.js +1 -0
  43. package/dist/flow/utils/pill-string-parser.js.map +1 -1
  44. package/dist/flow/utils/schema-to-flow-object.d.ts +6 -1
  45. package/dist/flow/utils/schema-to-flow-object.js +131 -15
  46. package/dist/flow/utils/schema-to-flow-object.js.map +1 -1
  47. package/dist/flow/utils/utils.d.ts +1 -0
  48. package/dist/flow/utils/utils.js +6 -1
  49. package/dist/flow/utils/utils.js.map +1 -1
  50. package/dist/form-plugin.js +7 -9
  51. package/dist/form-plugin.js.map +1 -1
  52. package/dist/inbound-email-action-plugin.d.ts +10 -0
  53. package/dist/inbound-email-action-plugin.js +128 -0
  54. package/dist/inbound-email-action-plugin.js.map +1 -0
  55. package/dist/index.d.ts +4 -0
  56. package/dist/index.js +4 -0
  57. package/dist/index.js.map +1 -1
  58. package/dist/instance-scan-plugin.js +0 -5
  59. package/dist/instance-scan-plugin.js.map +1 -1
  60. package/dist/property-plugin.js +1 -1
  61. package/dist/property-plugin.js.map +1 -1
  62. package/dist/record-plugin.d.ts +7 -0
  63. package/dist/record-plugin.js +10 -2
  64. package/dist/record-plugin.js.map +1 -1
  65. package/dist/rest-api-plugin.js +8 -1
  66. package/dist/rest-api-plugin.js.map +1 -1
  67. package/dist/schedule-script/scheduled-script-plugin.js +8 -3
  68. package/dist/schedule-script/scheduled-script-plugin.js.map +1 -1
  69. package/dist/service-catalog/service-catalog-base.d.ts +18 -18
  70. package/dist/service-catalog/service-catalog-base.js +22 -22
  71. package/dist/service-catalog/service-catalog-base.js.map +1 -1
  72. package/dist/service-portal/header-footer-plugin.d.ts +2 -0
  73. package/dist/service-portal/header-footer-plugin.js +50 -0
  74. package/dist/service-portal/header-footer-plugin.js.map +1 -0
  75. package/dist/service-portal/menu-plugin.js +3 -22
  76. package/dist/service-portal/menu-plugin.js.map +1 -1
  77. package/dist/service-portal/page-plugin.js +3 -24
  78. package/dist/service-portal/page-plugin.js.map +1 -1
  79. package/dist/service-portal/page-route-map-plugin.d.ts +2 -0
  80. package/dist/service-portal/page-route-map-plugin.js +114 -0
  81. package/dist/service-portal/page-route-map-plugin.js.map +1 -0
  82. package/dist/service-portal/portal-plugin.js +21 -8
  83. package/dist/service-portal/portal-plugin.js.map +1 -1
  84. package/dist/service-portal/utils.d.ts +40 -2
  85. package/dist/service-portal/utils.js +283 -2
  86. package/dist/service-portal/utils.js.map +1 -1
  87. package/dist/service-portal/widget-plugin.js +9 -218
  88. package/dist/service-portal/widget-plugin.js.map +1 -1
  89. package/dist/static-content-plugin.js +4 -0
  90. package/dist/static-content-plugin.js.map +1 -1
  91. package/dist/table-plugin.js +190 -26
  92. package/dist/table-plugin.js.map +1 -1
  93. package/dist/ui-action-plugin.js +1 -4
  94. package/dist/ui-action-plugin.js.map +1 -1
  95. package/dist/ui-page-plugin.js +68 -13
  96. package/dist/ui-page-plugin.js.map +1 -1
  97. package/dist/view-plugin.js +8 -3
  98. package/dist/view-plugin.js.map +1 -1
  99. package/dist/workspace-plugin.js +39 -36
  100. package/dist/workspace-plugin.js.map +1 -1
  101. package/package.json +5 -4
  102. package/src/column-plugin.ts +3 -8
  103. package/src/flow/flow-logic/flow-logic-diagnostics.ts +5 -6
  104. package/src/flow/plugins/flow-action-definition-plugin.ts +1581 -61
  105. package/src/flow/plugins/flow-data-pill-plugin.ts +5 -2
  106. package/src/flow/plugins/flow-definition-plugin.ts +12 -47
  107. package/src/flow/plugins/flow-diagnostics-plugin.ts +2 -2
  108. package/src/flow/plugins/flow-instance-plugin.ts +98 -22
  109. package/src/flow/plugins/step-definition-plugin.ts +2 -1
  110. package/src/flow/plugins/step-instance-plugin.ts +772 -156
  111. package/src/flow/plugins/wfa-datapill-plugin.ts +25 -5
  112. package/src/flow/post-install.ts +1 -0
  113. package/src/flow/utils/complex-object-resolver.ts +4 -1
  114. package/src/flow/utils/complex-objects.ts +1 -1
  115. package/src/flow/utils/flow-constants.ts +421 -5
  116. package/src/flow/utils/flow-io-to-record.ts +43 -17
  117. package/src/flow/utils/flow-shapes.ts +4 -0
  118. package/src/flow/utils/label-cache-parser.ts +33 -4
  119. package/src/flow/utils/pill-shape-helpers.ts +42 -0
  120. package/src/flow/utils/pill-string-parser.ts +1 -0
  121. package/src/flow/utils/schema-to-flow-object.ts +183 -15
  122. package/src/flow/utils/utils.ts +12 -1
  123. package/src/form-plugin.ts +1 -3
  124. package/src/inbound-email-action-plugin.ts +145 -0
  125. package/src/index.ts +4 -0
  126. package/src/instance-scan-plugin.ts +0 -5
  127. package/src/property-plugin.ts +4 -1
  128. package/src/record-plugin.ts +14 -4
  129. package/src/rest-api-plugin.ts +7 -1
  130. package/src/schedule-script/scheduled-script-plugin.ts +14 -3
  131. package/src/service-catalog/service-catalog-base.ts +22 -22
  132. package/src/service-portal/header-footer-plugin.ts +57 -0
  133. package/src/service-portal/menu-plugin.ts +1 -23
  134. package/src/service-portal/page-plugin.ts +3 -28
  135. package/src/service-portal/page-route-map-plugin.ts +124 -0
  136. package/src/service-portal/portal-plugin.ts +33 -10
  137. package/src/service-portal/utils.ts +404 -3
  138. package/src/service-portal/widget-plugin.ts +14 -290
  139. package/src/static-content-plugin.ts +3 -0
  140. package/src/table-plugin.ts +226 -36
  141. package/src/ui-action-plugin.ts +1 -8
  142. package/src/ui-page-plugin.ts +76 -13
  143. package/src/view-plugin.ts +10 -4
  144. package/src/workspace-plugin.ts +43 -43
@@ -130,10 +130,13 @@ export const WfaDataPillPlugin = Plugin.create({
130
130
  return { success: false }
131
131
  }
132
132
 
133
- // Validate wfa.dataPill is inside a Flow or Subflow call expression
134
- const ancestorFlowOrSubflow = findAncestorByCalleeName(node, 'Flow', 'Subflow')
135
- if (!ancestorFlowOrSubflow) {
136
- diagnostics.error(node, 'wfa.dataPill() cannot be used outside of a Flow or Subflow context.')
133
+ // Validate wfa.dataPill is inside a Flow or Subflow or action call expression
134
+ const isDataPillAncestorValid = findAncestorByCalleeName(node, 'Flow', 'Subflow', 'Action')
135
+ if (!isDataPillAncestorValid) {
136
+ diagnostics.error(
137
+ node,
138
+ 'wfa.dataPill() cannot be used outside of a Flow, Subflow, or Action context.'
139
+ )
137
140
  return { success: false }
138
141
  }
139
142
 
@@ -205,7 +208,24 @@ export const WfaDataPillPlugin = Plugin.create({
205
208
  return { success: true, value: shapeResult.value }
206
209
  }
207
210
  }
208
- diagnostics.error(expressionArg, 'wfa.dataPill: failed to resolve expression or type')
211
+ // Inside Action() bodies, step output datapills (e.g., create_record_step.record)
212
+ // reference local const variables that can't be resolved during the shape phase.
213
+ // These are handled by the ActionDefinitionPlugin's toRecord handler for Action() instead.
214
+ // Action input pills (params.inputs.xxx) DO resolve here — only step variable
215
+ // references fail, so an unresolved pill in an Action body is expected for step refs
216
+ // but could indicate a typo for other cases. Emit a hint (not error) to surface
217
+ // potential issues without blocking the build.
218
+ const actionAncestor = findAncestorByCalleeName(node, 'Action')
219
+ if (actionAncestor) {
220
+ diagnostics.hint(
221
+ expressionArg,
222
+ 'wfa.dataPill: expression could not be resolved at compile time. ' +
223
+ 'If this references a step output variable, it will be resolved during build. ' +
224
+ 'Otherwise, check for typos in the property path.'
225
+ )
226
+ } else {
227
+ diagnostics.error(expressionArg, 'wfa.dataPill: failed to resolve expression or type')
228
+ }
209
229
  return { success: false }
210
230
  },
211
231
  },
@@ -88,5 +88,6 @@ export const FlowActivationTask: PostInstallTask = {
88
88
  name: 'flow-activation',
89
89
  skipFlag: 'skipFlowActivation',
90
90
  skipFlagDescription: 'Skip activating (publishing) flows after install',
91
+ runFor: 'both',
91
92
  run: activateFlows,
92
93
  }
@@ -824,7 +824,10 @@ function buildChildrenArray(
824
824
  } else if (typeof fieldType === 'string') {
825
825
  // Primitive field with value
826
826
  if (shouldIncludeField(fieldValue)) {
827
- const value = isDataPill(fieldValue) ? stripDataPillType(fieldValue) : ''
827
+ // DEF0792627: Preserve the |type annotation so extractDataPillsFromChildren()
828
+ // uses the developer-specified type instead of injecting parameter.type.
829
+ // The annotation is stripped later by STRIP_DATATYPE_FROM_PILL_REGEX after extraction.
830
+ const value = isDataPill(fieldValue) ? String(fieldValue) : ''
828
831
  const parameter = createChildParameter(
829
832
  key,
830
833
  fieldType.toLowerCase(),
@@ -86,7 +86,7 @@ const buildFieldFacet = ({
86
86
  const additionalProperties: globalThis.Record<string, unknown> = {}
87
87
 
88
88
  // Handle reference columns - extract reference table
89
- if (uiType === 'reference') {
89
+ if (uiType === 'reference' || uiType === 'records') {
90
90
  const referenceTable = config.get('referenceTable')?.ifString()?.getValue()
91
91
  if (referenceTable) {
92
92
  additionalProperties['reference'] = referenceTable
@@ -21,24 +21,64 @@ export const UNSUPPORTED_FLOW_DESCENDANTS = [
21
21
  ACTION_INSTANCE_TABLE,
22
22
  SUBFLOW_INSTANCE_TABLE,
23
23
  FLOW_LOGIC_INSTANCE_TABLE,
24
- SUBFLOW_INSTANCE_TABLE_V2,
25
24
  ]
26
25
 
27
26
  //Plugins callee names
28
27
  export const FLOW_API_NAME = 'Flow'
29
28
  export const SUBFLOW_API_NAME = 'Subflow'
30
- export const ACTION_DEFINITION_API_NAME = 'ActionDefinition'
29
+ export const ACTION_DEFINITION_API_NAME = 'Action'
31
30
  export const TRIGGER_DEFINITION_API_NAME = 'TriggerDefinition'
32
31
 
33
32
  export const TRIGGER_INSTANCE_API_NAME = 'wfa.trigger'
34
33
  export const ACTION_INSTANCE_API_NAME = 'wfa.action'
35
34
  export const SUBFLOW_INSTANCE_API_NAME = 'wfa.subflow'
36
- export const ACTION_STEP_INSTANCE_API_NAME = 'wfa.action_step'
35
+ export const ACTION_STEP_INSTANCE_API_NAME = 'wfa.actionStep'
37
36
  export const APPROVAL_RULES_API_NAME = 'wfa.approvalRules'
38
37
  export const APPROVAL_DUE_DATE_API_NAME = 'wfa.approvalDueDate'
39
38
 
39
+ export const FLOW_OBJECT_API_NAME = 'FlowObject'
40
+ export const FLOW_ARRAY_API_NAME = 'FlowArray'
41
+
40
42
  export const ELEMENT_MAPPING_PROVIDER = 'com.glide.flow_design.action.data.FlowDesignVariableMapper'
41
43
 
44
+ const UI_TYPE_LABEL: { [key: string]: string } = {
45
+ string: 'String',
46
+ integer: 'Integer',
47
+ boolean: 'True/False',
48
+ decimal: 'Decimal',
49
+ float: 'Float',
50
+ date: 'Date',
51
+ glide_date: 'Date',
52
+ glide_date_time: 'Date/Time',
53
+ datetime: 'Date/Time',
54
+ reference: 'Reference',
55
+ choice: 'Choice',
56
+ table_name: 'Table Name',
57
+ field_name: 'Field Name',
58
+ document_id: 'Document ID',
59
+ json: 'JSON',
60
+ script: 'Script',
61
+ url: 'URL',
62
+ html: 'HTML',
63
+ email: 'Email',
64
+ password2: 'Password',
65
+ glide_duration: 'Duration',
66
+ conditions: 'Conditions',
67
+ template_value: 'Template Value',
68
+ records: 'Records',
69
+ }
70
+
71
+ /** Returns the human-readable uiTypeLabel for a given internal_type (e.g. 'integer' → 'Integer') */
72
+ export function getUiTypeLabel(internalType: string): string {
73
+ return UI_TYPE_LABEL[internalType] ?? internalType.charAt(0).toUpperCase() + internalType.slice(1)
74
+ }
75
+
76
+ /** Builds the attributes string for sys_hub_step_ext_input/output records */
77
+ export function buildExtVarAttributes(internalType: string): string {
78
+ const uiTypeLabel = getUiTypeLabel(internalType)
79
+ return `element_mapping_provider=${ELEMENT_MAPPING_PROVIDER},uiType=${internalType},uiTypeLabel=${uiTypeLabel}`
80
+ }
81
+
42
82
  export const TRIGGER_TYPE_KEY_NAME = 'trigger_type'
43
83
  export const ACTION_TYPE_KEY_NAME = 'action_type'
44
84
 
@@ -67,8 +107,9 @@ export const CORE_ACTIONS_PREFIX = 'action.core'
67
107
  export const RUN_ON_EXTENDED = 'run_on_extended'
68
108
 
69
109
  export const APPROVAL_DUE_DATE_INPUT_FIELD_ACTIONS = [
70
- 'f8f2e9920b10030085c083eb37673abd',
71
- 'cd04ac7573011010791f94596bf6a716',
110
+ 'f8f2e9920b10030085c083eb37673abd', // askForApproval action definition sys_id (flow context)
111
+ 'cd04ac7573011010791f94596bf6a716', // originally added in DEF0789002 — sys_id identity unknown, needs investigation
112
+ 'a4eb47900b22320085c083eb37673acc', // askForApproval step definition sys_id (action definition context)
72
113
  ]
73
114
 
74
115
  export const CORE_ACTIONS_SYS_ID_NAME_MAP: { [sysId: string]: string } = {
@@ -107,12 +148,387 @@ export const CORE_ACTIONS_SYS_ID_NAME_MAP: { [sysId: string]: string } = {
107
148
  '605d0ab8931012105cd18166448918db': 'waitForMessage',
108
149
  }
109
150
 
151
+ /**
152
+ * Prefix for built-in action step references in generated Fluent code.
153
+ * Produces identifiers like `actionStep.createRecord`, `actionStep.log`, etc.
154
+ */
155
+ export const BUILT_IN_STEP_PREFIX = 'actionStep'
156
+
157
+ /**
158
+ * Maps built-in step definition sys_ids to their `actionStep.xxx` property name.
159
+ * Used during XML→Fluent transform to emit typed references instead of strings.
160
+ * Follows the same pattern as CORE_ACTIONS_SYS_ID_NAME_MAP for actions.
161
+ */
162
+ export const BUILT_IN_STEP_SYS_ID_NAME_MAP: { [sysId: string]: string } = {
163
+ a03fea9bc712220061f553c6f09763b1: 'log',
164
+ '9cbaa0f267003200553fafb49585ef69': 'createRecord',
165
+ '106afb6647032200b4fad7527c9a71e7': 'script',
166
+
167
+ '07973e960b233200cbd9e240e0ea604e': 'createTask',
168
+ '05a6e480a301311029c4d1f3e31e61f1': 'collectActivityContext',
169
+ '092bb996ff30311077a95dac793bf166': 'fireEvent',
170
+ '0d9746f0931012105cd181664489188c': 'waitForMessage',
171
+ '0e07df020f13101051218e8ebc767e57': 'getLatestResponseTextFromEmail',
172
+
173
+ '48526b2dc32a32002841b63b12d3ae72': 'lookUpRecords',
174
+ '4c5f36a37f0b32005f58108c3ffa9126': 'email',
175
+ '4c9234ca0b18030085c083eb37673aaa': 'waitForCondition',
176
+ '5d31f8f37f1322004d145212bdfa9145': 'notification',
177
+ '65a40b525b12101083f30f216581c787': 'createAppFromPayload',
178
+ '81e15fbd7fcb12108e688c90ac866541': 'waitForEmailReply',
179
+ '8c6b7466c71100105312134c95c2602a': 'deleteMultipleRecords',
180
+ '8f5c107a53a3230034c6ddeeff7b129d': 'createOrUpdateRecord',
181
+ a3dfc066c7dd00105312134c95c26014: 'updateMultipleRecords',
182
+ a4eb47900b22320085c083eb37673acc: 'askForApproval',
183
+ b51f683667003200553fafb49585ef3f: 'updateRecord',
184
+ b67821c1c723220061f553c6f09763c2: 'deleteRecord',
185
+ dc9c26043b23220057a4a2e334efc447: 'lookUpRecord',
186
+ e0b9272d53112110aba6ddeeff7b1224: 'createRecordForRemoteTable',
187
+ f760b5c2737c001086592f163cf6a758: 'sms',
188
+ }
189
+
190
+ /**
191
+ * A step variable entry: either a plain element name (string)
192
+ * or an object with element name + uiType for value coercion during transform.
193
+ */
194
+ export type StepVarEntry = string | { name: string; uiType: string }
195
+
196
+ /** Extract the element name from a StepVarEntry */
197
+ export function getVarEntryName(entry: StepVarEntry): string {
198
+ return typeof entry === 'string' ? entry : entry.name
199
+ }
200
+
201
+ /** Extract the uiType from a StepVarEntry (undefined for plain strings) */
202
+ export function getVarEntryType(entry: StepVarEntry): string | undefined {
203
+ return typeof entry === 'string' ? undefined : entry.uiType
204
+ }
205
+
206
+ /**
207
+ * Maps built-in step definition sys_ids to their metadata including
208
+ * input/output variable sys_id → element name mappings.
209
+ * Used during XML→Fluent transform to resolve OOB step definitions
210
+ * and their sys_variable_value records into proper element names.
211
+ */
212
+ export const BUILT_IN_STEP_DEFINITIONS: {
213
+ [sysId: string]: {
214
+ name: string
215
+ inputs: { [varSysId: string]: StepVarEntry }
216
+ outputs: { [varSysId: string]: StepVarEntry }
217
+ }
218
+ } = {
219
+ a03fea9bc712220061f553c6f09763b1: {
220
+ name: 'Log',
221
+ inputs: {
222
+ '4fc2fadbc712220061f553c6f0976388': 'log_message',
223
+ ab123adbc712220061f553c6f0976387: 'log_level',
224
+ },
225
+ outputs: {},
226
+ },
227
+ '9cbaa0f267003200553fafb49585ef69': {
228
+ name: 'Create Record',
229
+ inputs: {
230
+ '9e5f9d85536333003bf1d9109ec587c6': { name: 'skip_insert', uiType: 'boolean' },
231
+ e78d203667003200553fafb49585ef63: { name: 'create_record_field_values', uiType: 'template_value' },
232
+ f0fb68f267003200553fafb49585efa0: 'create_record_table_name',
233
+ },
234
+ outputs: {
235
+ '795c557267003200553fafb49585efb0': 'table_name',
236
+ '966cd57267003200553fafb49585efa0': 'record',
237
+ },
238
+ },
239
+ '106afb6647032200b4fad7527c9a71e7': {
240
+ name: 'Script',
241
+ inputs: {
242
+ '0d2db9e653310110d3a8ddeeff7b1208': 'mid_cluster',
243
+ '28e4e579b3101300176b051a16a8dc0f': 'host',
244
+ '2b2ba571b3101300176b051a16a8dc8f': 'connection_alias',
245
+ '2c226939b3101300176b051a16a8dc83': 'mid_selection_type',
246
+ '71aa7f6647032200b4fad7527c9a719b': 'script',
247
+ '74315b04b3201300176b051a16a8dc2b': 'required_run_time',
248
+ '7d36ed79b3101300176b051a16a8dceb': 'capabilities',
249
+ cbd1070373531010791f94596bf6a776: 'mid_selection',
250
+ f0d58b8373531010791f94596bf6a7be: 'mid_server',
251
+ f5e56d79b3101300176b051a16a8dce4: 'application',
252
+ },
253
+ outputs: {},
254
+ },
255
+ '07973e960b233200cbd9e240e0ea604e': {
256
+ name: 'Create Task',
257
+ inputs: {
258
+ '1aeb688553af33003bf1d9109ec58710': { name: 'skip_insert', uiType: 'boolean' },
259
+ '2a7872d60b233200cbd9e240e0ea601e': { name: 'create_record_field_values', uiType: 'template_value' },
260
+ '9b6832d60b233200cbd9e240e0ea601c': 'create_record_table_name',
261
+ a498b2d60b233200cbd9e240e0ea6004: { name: 'wait', uiType: 'boolean' },
262
+ },
263
+ outputs: {
264
+ '19efa6b653333200f5bf435723dc340e': 'table',
265
+ '9f0b036353233200f5bf435723dc3475': 'task',
266
+ },
267
+ },
268
+ '092bb996ff30311077a95dac793bf166': {
269
+ name: 'Fire Event',
270
+ inputs: {
271
+ '020ebd5aff30311077a95dac793bf1ea': 'table',
272
+ '077ef59aff30311077a95dac793bf1ba': 'parm1',
273
+ '17be7d9aff30311077a95dac793bf18f': 'parm2',
274
+ '599cf11aff30311077a95dac793bf1d2': 'event_name',
275
+ a3ad395aff30311077a95dac793bf12e: 'record',
276
+ },
277
+ outputs: {},
278
+ },
279
+ b51f683667003200553fafb49585ef3f: {
280
+ name: 'Update Record',
281
+ inputs: {
282
+ '3930d57267003200553fafb49585efc5': 'table_name',
283
+ aab0ddb267003200553fafb49585ef30: 'record',
284
+ fcbf6c3667003200553fafb49585ef2e: { name: 'update_record_field_values', uiType: 'template_value' },
285
+ },
286
+ outputs: {
287
+ '2fb3d57267003200553fafb49585ef43': 'table_name',
288
+ ffd3197267003200553fafb49585ef5a: 'record',
289
+ },
290
+ },
291
+ b67821c1c723220061f553c6f09763c2: {
292
+ name: 'Delete Record',
293
+ inputs: {
294
+ '995a2105c723220061f553c6f0976301': 'record',
295
+ ab19a9c1c723220061f553c6f0976383: 'table_name',
296
+ },
297
+ outputs: {},
298
+ },
299
+ dc9c26043b23220057a4a2e334efc447: {
300
+ name: 'Look Up Record',
301
+ inputs: {
302
+ '0cfca6043b23220057a4a2e334efc43b': { name: 'conditions', uiType: 'conditions' },
303
+ '3b9387923b23220057a4a2e334efc4e4': 'multiple_records_found',
304
+ a6da115587003300663ca1bb36cb0bc0: 'sort_column',
305
+ b019356673110010d70877186bf6a780: { name: 'dont_fail_flow_on_error', uiType: 'boolean' },
306
+ c62b915587003300663ca1bb36cb0bd2: 'sort_type',
307
+ f9cc66043b23220057a4a2e334efc42f: 'lookup_table_name',
308
+ },
309
+ outputs: {
310
+ '145a3da673110010d70877186bf6a7a5': 'error_message',
311
+ '14bd89c673310010d70877186bf6a7be': 'status',
312
+ a64d6a043b23220057a4a2e334efc4e8: 'table_name',
313
+ d3e627913b23220057a4a2e334efc45e: 'record',
314
+ },
315
+ },
316
+ '48526b2dc32a32002841b63b12d3ae72': {
317
+ name: 'Look Up Records',
318
+ inputs: {
319
+ '0677f8e053200300f5bf435723dc34e3': { name: 'limit', uiType: 'integer' },
320
+ '2df79dd187003300663ca1bb36cb0b33': 'sort_column',
321
+ '4d19bb21c36a32002841b63b12d3aeef': 'table_name',
322
+ '6a88151587003300663ca1bb36cb0b14': 'sort_type',
323
+ '95f8bb21c36a32002841b63b12d3ae0c': { name: 'conditions', uiType: 'conditions' },
324
+ },
325
+ outputs: {
326
+ '5db8f721c36a32002841b63b12d3aeb7': 'records',
327
+ c576f2a2c32232002841b63b12d3ae66: 'table_name',
328
+ f6700274c32b32002841b63b12d3ae37: { name: 'count', uiType: 'integer' },
329
+ },
330
+ },
331
+ a3dfc066c7dd00105312134c95c26014: {
332
+ name: 'Update Multiple Records',
333
+ inputs: {
334
+ '0f7194a6c7dd00105312134c95c26028': { name: 'set_autosysfields', uiType: 'boolean' },
335
+ '168d8069c7ee00105312134c95c260a7': 'sort_column',
336
+ '66401866c7dd00105312134c95c2607e': { name: 'conditions', uiType: 'conditions' },
337
+ '71ad0469c7ee00105312134c95c26027': 'sort_type',
338
+ '8a6154a6c7dd00105312134c95c26019': { name: 'set_workflow', uiType: 'boolean' },
339
+ a5505866c7dd00105312134c95c26065: { name: 'field_values', uiType: 'template_value' },
340
+ c530d466c7dd00105312134c95c26066: 'table_name',
341
+ e2214bd6c72a40105312134c95c2600c: { name: 'dont_fail_flow_on_error', uiType: 'boolean' },
342
+ },
343
+ outputs: {
344
+ '10209466c7dd00105312134c95c26031': 'error_message',
345
+ '4f814fd6c72a40105312134c95c26001': 'status',
346
+ a4101466c7dd00105312134c95c260a8: { name: 'count', uiType: 'integer' },
347
+ },
348
+ },
349
+ '8c6b7466c71100105312134c95c2602a': {
350
+ name: 'Delete Multiple Records',
351
+ inputs: {
352
+ '156c34a6c71100105312134c95c26068': { name: 'set_workflow', uiType: 'boolean' },
353
+ '693c70a6c71100105312134c95c26011': 'table_name',
354
+ '76207652c72a40105312134c95c26083': { name: 'dont_fail_flow_on_error', uiType: 'boolean' },
355
+ '79fb8029c7ee00105312134c95c26042': 'sort_column',
356
+ a34cb0a6c71100105312134c95c260a3: { name: 'conditions', uiType: 'conditions' },
357
+ a85c8429c7ee00105312134c95c26033: 'sort_type',
358
+ },
359
+ outputs: {
360
+ '60fbbc66c71100105312134c95c26033': 'error_message',
361
+ ce41be52c72a40105312134c95c2606b: 'status',
362
+ e7db3c66c71100105312134c95c26031: { name: 'count', uiType: 'integer' },
363
+ },
364
+ },
365
+ '4c5f36a37f0b32005f58108c3ffa9126': {
366
+ name: 'Email',
367
+ inputs: {
368
+ '0fba76757303230082999cfd7bf6a7f2': { name: 'watermark_email', uiType: 'boolean' },
369
+ '33c003277f0b32005f58108c3ffa91e8': 'cc',
370
+ '40cf3ae37f0b32005f58108c3ffa91f3': 'to',
371
+ '4d0183277f0b32005f58108c3ffa9197': 'subject',
372
+ '8ef44f277f0b32005f58108c3ffa91f7': 'body',
373
+ '9971a338a70323008299b39f08790195': 'record',
374
+ e1312338a70323008299b39f087901f5: 'table_name',
375
+ e8f043277f0b32005f58108c3ffa91d1: 'bcc',
376
+ },
377
+ outputs: {
378
+ f4a503677f0b32005f58108c3ffa91cf: 'email',
379
+ },
380
+ },
381
+ '5d31f8f37f1322004d145212bdfa9145': {
382
+ name: 'Notification',
383
+ inputs: {
384
+ '4d1cbc717f0332004d145212bdfa91b8': 'record',
385
+ b8a793697f2a32005f58108c3ffa910b: 'table_name',
386
+ cc7fb8b17f0332004d145212bdfa91da: 'notification',
387
+ },
388
+ outputs: {},
389
+ },
390
+ a4eb47900b22320085c083eb37673acc: {
391
+ name: 'Ask for Approval',
392
+ inputs: {
393
+ '30a496c67f3012108e688c90ac8665a0': 'approval_reason',
394
+ '745c0f900b22320085c083eb37673a79': { name: 'approval_conditions', uiType: 'approval_rules' },
395
+ '982c8b900b22320085c083eb37673a7c': 'record',
396
+ a44ccb900b22320085c083eb37673ab4: 'table',
397
+ d3dac4860b333200c438ee6537673a5a: { name: 'due_date', uiType: 'schedule_date_time' },
398
+ db521c5567323200c4098c7942415a67: 'approval_field',
399
+ f7b3d09567323200c4098c7942415a65: 'journal_field',
400
+ },
401
+ outputs: {
402
+ aa7568070b23320085c083eb37673a73: 'state',
403
+ },
404
+ },
405
+ '4c9234ca0b18030085c083eb37673aaa': {
406
+ name: 'Wait For Condition',
407
+ inputs: {
408
+ '1fac6063876100102fa5a1bb36cb0bac': { name: 'timeout_duration', uiType: 'glide_duration' },
409
+ '72b2bcca0b18030085c083eb37673a0b': 'table_name',
410
+ '7de2fcca0b18030085c083eb37673aed': { name: 'conditions', uiType: 'conditions' },
411
+ ae1d6463876100102fa5a1bb36cb0b56: 'timeout_schedule',
412
+ bc93428187120010663ca1bb36cb0b83: { name: 'timeout_flag', uiType: 'boolean' },
413
+ c5d2fcca0b18030085c083eb37673a1c: 'record',
414
+ },
415
+ outputs: {
416
+ '1fbdac63876100102fa5a1bb36cb0ba2': 'state',
417
+ },
418
+ },
419
+ '81e15fbd7fcb12108e688c90ac866541': {
420
+ name: 'Wait For Email Reply',
421
+ inputs: {
422
+ '391597b17f0f12108e688c90ac866571': 'record',
423
+ '3e78d3b57f0f12108e688c90ac86653b': { name: 'timeout_duration', uiType: 'glide_duration' },
424
+ b3285f757f0f12108e688c90ac866575: { name: 'enable_timeout', uiType: 'boolean' },
425
+ b7a8d7b57f0f12108e688c90ac86659f: 'timeout_schedule',
426
+ },
427
+ outputs: {
428
+ '10991bf57f0f12108e688c90ac866577': 'email_reply',
429
+ '752ad3397f0f12108e688c90ac866579': 'state',
430
+ },
431
+ },
432
+ '0d9746f0931012105cd181664489188c': {
433
+ name: 'Wait For Message',
434
+ inputs: {
435
+ '15a942b4931012105cd18166448918bc': { name: 'timeout_duration', uiType: 'glide_duration' },
436
+ '83e74ef0931012105cd181664489182b': 'message',
437
+ d728c634931012105cd18166448918b0: { name: 'enable_timeout', uiType: 'boolean' },
438
+ },
439
+ outputs: {
440
+ '640b4ef4931012105cd181664489180b': 'payload',
441
+ },
442
+ },
443
+ '8f5c107a53a3230034c6ddeeff7b129d': {
444
+ name: 'Create or Update Record',
445
+ inputs: {
446
+ '5eac547a53a3230034c6ddeeff7b12c7': { name: 'fields', uiType: 'template_value' },
447
+ '728c907a53a3230034c6ddeeff7b12e9': 'table',
448
+ },
449
+ outputs: {
450
+ '5d0ade9c537b230034c6ddeeff7b12ac': 'record',
451
+ '9c9ad6dc537b230034c6ddeeff7b127e': 'table_name',
452
+ '9dbbda1053bb230034c6ddeeff7b12c8': 'error_message',
453
+ b32b521053bb230034c6ddeeff7b12d2: 'status',
454
+ },
455
+ },
456
+ f760b5c2737c001086592f163cf6a758: {
457
+ name: 'SMS',
458
+ inputs: {
459
+ c951b106737c001086592f163cf6a75a: 'message',
460
+ dd317dc2737c001086592f163cf6a7fe: 'recipients',
461
+ },
462
+ outputs: {
463
+ '29817506737c001086592f163cf6a72d': 'email',
464
+ },
465
+ },
466
+ '05a6e480a301311029c4d1f3e31e61f1': {
467
+ name: 'Collect Activity Context',
468
+ inputs: {},
469
+ outputs: {
470
+ '89e202b9a3013110fc7ad1f3e31e616d': 'activity_context',
471
+ },
472
+ },
473
+ '65a40b525b12101083f30f216581c787': {
474
+ name: 'Create App From Payload',
475
+ inputs: {
476
+ '03c116415b03101083f30f216581c74d': 'template_instance_id',
477
+ c74f30905b33101083f30f216581c7f0: 'scan_id',
478
+ },
479
+ outputs: {
480
+ f343f3925b12101083f30f216581c739: 'sys_app_id',
481
+ },
482
+ },
483
+ e0b9272d53112110aba6ddeeff7b1224: {
484
+ name: 'Create Record For Remote Table',
485
+ inputs: {
486
+ '8d068211a3913110aba698e6d31e61b6': 'query_id',
487
+ c442d88a53912110aba6ddeeff7b1277: 'create_record_table_name',
488
+ e5d96b2d53112110aba6ddeeff7b1236: { name: 'create_record_field_values', uiType: 'template_value' },
489
+ },
490
+ outputs: {
491
+ '2b3a236d53112110aba6ddeeff7b129d': 'table_name',
492
+ },
493
+ },
494
+ '0e07df020f13101051218e8ebc767e57': {
495
+ name: 'Get Latest Response Text From Email',
496
+ inputs: {
497
+ '44d757420f13101051218e8ebc767eee': 'email_record',
498
+ },
499
+ outputs: {
500
+ '6f88df420f13101051218e8ebc767e67': 'latest_response_text',
501
+ },
502
+ },
503
+ }
504
+
505
+ /**
506
+ * Reverse lookup: step definition name → first matching sys_id.
507
+ * Used during Fluent→XML build to resolve string step type names
508
+ * back to their platform sys_ids.
509
+ */
510
+ export const BUILT_IN_STEP_NAME_TO_SYSID: { [name: string]: string } = {}
511
+ for (const [sysId, def] of Object.entries(BUILT_IN_STEP_DEFINITIONS)) {
512
+ if (!BUILT_IN_STEP_NAME_TO_SYSID[def.name]) {
513
+ BUILT_IN_STEP_NAME_TO_SYSID[def.name] = sysId
514
+ }
515
+ }
516
+
110
517
  export const COLUMN_DEFAULTS = {
111
518
  string: '',
112
519
  boolean: false,
113
520
  integer: 0,
114
521
  }
115
522
 
523
+ /**
524
+ * Maps platform-internal sys_element_mapping field names to their Fluent API names.
525
+ * Some step inputs are stored in sys_element_mapping using platform-internal names
526
+ * (e.g. __snc_dont_fail_on_error) that differ from the Fluent API property names.
527
+ */
528
+ export const ELEMENT_MAPPING_FIELD_ALIASES: { [platformName: string]: string } = {
529
+ __snc_dont_fail_on_error: 'dont_fail_flow_on_error',
530
+ }
531
+
116
532
  export enum ChoiceDropdown {
117
533
  DROPDOWN_WITH_NONE = 1,
118
534
  DROPDOWN_WITHOUT_NONE = 3,
@@ -168,7 +168,7 @@ export async function buildVariableRecords(options: {
168
168
  internal_type = COLUMN_API_TO_TYPE[callExpr.getCallee() as keyof typeof COLUMN_API_TO_TYPE] ?? 'string'
169
169
  }
170
170
  // Handle reference columns - extract reference table
171
- if (internal_type === 'reference') {
171
+ if (internal_type === 'reference' || internal_type === 'records') {
172
172
  const referenceTable = config.get('referenceTable')?.ifString()?.getValue()
173
173
  if (referenceTable) {
174
174
  additionalProperties['reference'] = referenceTable
@@ -223,7 +223,8 @@ export async function buildVariableRecords(options: {
223
223
  export function buildVariableShapes(
224
224
  variableRecords: Record[],
225
225
  descendants: Database,
226
- logger?: Logger
226
+ logger?: Logger,
227
+ snapshotValues?: Map<string, string>
227
228
  ): globalThis.Record<string, CallExpressionShape> | undefined {
228
229
  const shapes: globalThis.Record<string, CallExpressionShape> = {}
229
230
 
@@ -271,12 +272,15 @@ export function buildVariableShapes(
271
272
 
272
273
  // Only include $id and co_type_name if NOT deterministically generated
273
274
  const schema = JSON.parse(serializedContent)
275
+ const snapshotValue =
276
+ snapshotValues?.get(name) ?? variable.get('default_value')?.ifString()?.ifNotEmpty()?.getValue()
274
277
  shapes[name] = buildComplexObjectFromSchema(
275
278
  variable,
276
279
  schema,
277
280
  attributes,
278
281
  isDeterministic ? undefined : complexObjectSysId,
279
- isDeterministic ? undefined : maybeCoTypeName
282
+ isDeterministic ? undefined : maybeCoTypeName,
283
+ snapshotValue
280
284
  )
281
285
  } else {
282
286
  const variableName = variable.get('name').ifString()?.getValue()
@@ -289,7 +293,8 @@ export function buildVariableShapes(
289
293
  variable,
290
294
  additionalProps,
291
295
  descendants,
292
- documentation
296
+ documentation,
297
+ snapshotValues?.get(name)
293
298
  )
294
299
  }
295
300
  }
@@ -297,12 +302,38 @@ export function buildVariableShapes(
297
302
  return shapes
298
303
  }
299
304
 
305
+ /**
306
+ * Coerces a raw string value to the appropriate type for the given field type.
307
+ * Datapill template strings (e.g. {{action.field}}) are returned as-is.
308
+ * Returns undefined if the value is undefined or empty.
309
+ */
310
+ function coerceValue(raw: string | undefined, fieldType: string): unknown {
311
+ if (raw === undefined || raw === '') {
312
+ return undefined
313
+ }
314
+ const strVal = String(raw)
315
+ if (strVal.includes('{{')) {
316
+ return strVal
317
+ }
318
+ if (fieldType === 'string') {
319
+ return strVal
320
+ }
321
+ if (fieldType === 'boolean') {
322
+ return strVal === 'true' || strVal === '1'
323
+ }
324
+ if (fieldType === 'integer') {
325
+ return Number(raw)
326
+ }
327
+ return raw
328
+ }
329
+
300
330
  function buildBasicVariableShape(
301
331
  callExpressionName: string,
302
332
  variable: Record,
303
333
  additionalProps: globalThis.Record<string, unknown>,
304
334
  descendants: Database,
305
- documentation: Record[]
335
+ documentation: Record[],
336
+ snapshotValue?: string
306
337
  ) {
307
338
  if (callExpressionName === ChoiceColumn.name) {
308
339
  // choice column with choices from other table
@@ -376,20 +407,15 @@ function buildBasicVariableShape(
376
407
  .def(choiceDropdown[1]),
377
408
  default: $.from('default_value')
378
409
  .map((value) => {
379
- if (!value.isDefined()) {
380
- return undefined
410
+ // Snapshot output value (datapill or static) takes priority
411
+ if (snapshotValue !== undefined && snapshotValue !== '') {
412
+ return coerceValue(snapshotValue, fieldType)
381
413
  }
382
-
383
- if (fieldType === 'string') {
384
- return value.toString().getValue()
385
- }
386
- if (fieldType === 'boolean') {
387
- return Boolean(value.getValue())
388
- }
389
- if (fieldType === 'integer') {
390
- return Number(value.getValue())
414
+ const raw = value.isDefined() ? value.getValue() : undefined
415
+ if (raw === undefined || raw === null || raw === '') {
416
+ return undefined
391
417
  }
392
- return value.getValue()
418
+ return coerceValue(String(raw), fieldType)
393
419
  })
394
420
  .def(COLUMN_DEFAULTS[fieldType as keyof typeof COLUMN_DEFAULTS] ?? ''),
395
421
  ...(hint ? { hint: $.val(hint) } : {}),
@@ -247,6 +247,10 @@ export class ApprovalDueDateShape extends ObjectShape {
247
247
  duration: 1,
248
248
  duration_type: 'days',
249
249
  schedule: '',
250
+ // schedule_label is a display-only field derived by ServiceNow from the schedule sys_id at runtime.
251
+ // It is always serialized as '' here because it is not stored in ApprovalDueDateType —
252
+ // ServiceNow ignores the stored value and recomputes it from the schedule sys_id on load.
253
+ schedule_label: '',
250
254
  }
251
255
 
252
256
  //Convert the Due Date to the format expected by Flow Designer and populate with default values