@servicenow/sdk-build-plugins 4.6.0 → 4.7.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/dist/acl-plugin.js +3 -4
- package/dist/acl-plugin.js.map +1 -1
- package/dist/applicability-plugin.js +0 -2
- package/dist/applicability-plugin.js.map +1 -1
- package/dist/application-menu-plugin.js +0 -2
- package/dist/application-menu-plugin.js.map +1 -1
- package/dist/arrow-function-plugin.js +0 -1
- package/dist/arrow-function-plugin.js.map +1 -1
- package/dist/atf/test-plugin.js +6 -10
- package/dist/atf/test-plugin.js.map +1 -1
- package/dist/basic-syntax-plugin.js +10 -4
- package/dist/basic-syntax-plugin.js.map +1 -1
- package/dist/business-rule-plugin.js +0 -1
- package/dist/business-rule-plugin.js.map +1 -1
- package/dist/call-expression-plugin.js +0 -1
- package/dist/call-expression-plugin.js.map +1 -1
- package/dist/claims-plugin.js +0 -1
- package/dist/claims-plugin.js.map +1 -1
- package/dist/client-script-plugin.js +0 -1
- package/dist/client-script-plugin.js.map +1 -1
- package/dist/column-plugin.js +120 -49
- package/dist/column-plugin.js.map +1 -1
- package/dist/cross-scope-privilege-plugin.js +0 -1
- package/dist/cross-scope-privilege-plugin.js.map +1 -1
- package/dist/dashboard/dashboard-plugin.js +0 -2
- package/dist/dashboard/dashboard-plugin.js.map +1 -1
- package/dist/data-plugin.js +0 -1
- package/dist/data-plugin.js.map +1 -1
- package/dist/data-policy-plugin.d.ts +2 -0
- package/dist/data-policy-plugin.js +276 -0
- package/dist/data-policy-plugin.js.map +1 -0
- package/dist/email-notification-plugin.js +2 -3
- package/dist/email-notification-plugin.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-constants.d.ts +2 -0
- package/dist/flow/flow-logic/flow-logic-constants.js +6 -1
- package/dist/flow/flow-logic/flow-logic-constants.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-diagnostics.js +192 -56
- package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +2 -1
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +44 -5
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-plugin.js +279 -29
- package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-shapes.d.ts +15 -0
- package/dist/flow/flow-logic/flow-logic-shapes.js +25 -1
- package/dist/flow/flow-logic/flow-logic-shapes.js.map +1 -1
- package/dist/flow/plugins/approval-rules-plugin.js +0 -1
- package/dist/flow/plugins/approval-rules-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-action-definition-plugin.js +804 -205
- package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-data-pill-plugin.js +3 -5
- package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-definition-plugin.js +84 -17
- package/dist/flow/plugins/flow-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-diagnostics-plugin.js +65 -3
- package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-instance-plugin.js +13 -5
- package/dist/flow/plugins/flow-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-trigger-instance-plugin.js +0 -1
- package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/inline-script-plugin.js +0 -1
- package/dist/flow/plugins/inline-script-plugin.js.map +1 -1
- package/dist/flow/plugins/step-definition-plugin.js +0 -2
- package/dist/flow/plugins/step-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/step-instance-plugin.js +216 -77
- package/dist/flow/plugins/step-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/trigger-plugin.js +0 -2
- package/dist/flow/plugins/trigger-plugin.js.map +1 -1
- package/dist/flow/plugins/wfa-datapill-plugin.js +0 -1
- package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -1
- package/dist/flow/utils/datapill-transformer.js +9 -5
- package/dist/flow/utils/datapill-transformer.js.map +1 -1
- package/dist/flow/utils/flow-constants.d.ts +12 -0
- package/dist/flow/utils/flow-constants.js +17 -3
- package/dist/flow/utils/flow-constants.js.map +1 -1
- package/dist/flow/utils/flow-io-to-record.d.ts +1 -1
- package/dist/flow/utils/flow-io-to-record.js +21 -13
- package/dist/flow/utils/flow-io-to-record.js.map +1 -1
- package/dist/flow/utils/flow-pill-utils.d.ts +26 -0
- package/dist/flow/utils/flow-pill-utils.js +50 -0
- package/dist/flow/utils/flow-pill-utils.js.map +1 -0
- package/dist/flow/utils/flow-stage-processor.d.ts +138 -0
- package/dist/flow/utils/flow-stage-processor.js +665 -0
- package/dist/flow/utils/flow-stage-processor.js.map +1 -0
- package/dist/flow/utils/pill-string-parser.js +28 -43
- package/dist/flow/utils/pill-string-parser.js.map +1 -1
- package/dist/flow/utils/utils.d.ts +11 -6
- package/dist/flow/utils/utils.js +37 -28
- package/dist/flow/utils/utils.js.map +1 -1
- package/dist/form-plugin.js +4 -14
- package/dist/form-plugin.js.map +1 -1
- package/dist/html-import-plugin.js +0 -1
- package/dist/html-import-plugin.js.map +1 -1
- package/dist/import-sets-plugin.js +0 -2
- package/dist/import-sets-plugin.js.map +1 -1
- package/dist/inbound-email-action-plugin.js +0 -1
- package/dist/inbound-email-action-plugin.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/instance-scan-plugin.js +0 -7
- package/dist/instance-scan-plugin.js.map +1 -1
- package/dist/json-plugin.js +0 -1
- package/dist/json-plugin.js.map +1 -1
- package/dist/list-plugin.js +4 -1
- package/dist/list-plugin.js.map +1 -1
- package/dist/now-attach-plugin.js +0 -1
- package/dist/now-attach-plugin.js.map +1 -1
- package/dist/now-config-plugin.js +1 -1
- package/dist/now-config-plugin.js.map +1 -1
- package/dist/now-id-plugin.js +0 -1
- package/dist/now-id-plugin.js.map +1 -1
- package/dist/now-include-plugin.js +0 -1
- package/dist/now-include-plugin.js.map +1 -1
- package/dist/now-ref-plugin.js +0 -1
- package/dist/now-ref-plugin.js.map +1 -1
- package/dist/now-unresolved-plugin.js +0 -1
- package/dist/now-unresolved-plugin.js.map +1 -1
- package/dist/package-json-plugin.js +3 -2
- package/dist/package-json-plugin.js.map +1 -1
- package/dist/property-plugin.js +0 -2
- package/dist/property-plugin.js.map +1 -1
- package/dist/record-plugin.d.ts +2 -0
- package/dist/record-plugin.js +5 -4
- package/dist/record-plugin.js.map +1 -1
- package/dist/repack/lint/Rules.d.ts +1 -2
- package/dist/rest-api-plugin.js +6 -5
- package/dist/rest-api-plugin.js.map +1 -1
- package/dist/role-plugin.js +0 -1
- package/dist/role-plugin.js.map +1 -1
- package/dist/schedule-script/scheduled-script-plugin.js +5 -4
- package/dist/schedule-script/scheduled-script-plugin.js.map +1 -1
- package/dist/script-action-plugin.js +0 -2
- package/dist/script-action-plugin.js.map +1 -1
- package/dist/script-include-plugin.js +4 -4
- package/dist/script-include-plugin.js.map +1 -1
- package/dist/server-module-plugin/index.js +2 -3
- package/dist/server-module-plugin/index.js.map +1 -1
- package/dist/service-catalog/catalog-clientscript-plugin.js +2 -4
- package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -1
- package/dist/service-catalog/catalog-item-plugin.js +0 -2
- package/dist/service-catalog/catalog-item-plugin.js.map +1 -1
- package/dist/service-catalog/catalog-ui-policy-plugin.js +2 -4
- package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -1
- package/dist/service-catalog/sc-record-producer-plugin.js +0 -2
- package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -1
- package/dist/service-catalog/service-catalog-base.d.ts +2 -2
- package/dist/service-catalog/service-catalog-base.js +2 -2
- package/dist/service-catalog/service-catalog-base.js.map +1 -1
- package/dist/service-catalog/utils.js +1 -1
- package/dist/service-catalog/utils.js.map +1 -1
- package/dist/service-catalog/variable-set-plugin.js +0 -2
- package/dist/service-catalog/variable-set-plugin.js.map +1 -1
- package/dist/service-portal/angular-provider-plugin.js +0 -2
- package/dist/service-portal/angular-provider-plugin.js.map +1 -1
- package/dist/service-portal/dependency-plugin.js +3 -5
- package/dist/service-portal/dependency-plugin.js.map +1 -1
- package/dist/service-portal/header-footer-plugin.js +3 -5
- package/dist/service-portal/header-footer-plugin.js.map +1 -1
- package/dist/service-portal/menu-plugin.js +0 -1
- package/dist/service-portal/menu-plugin.js.map +1 -1
- package/dist/service-portal/page-plugin.js +0 -1
- package/dist/service-portal/page-plugin.js.map +1 -1
- package/dist/service-portal/page-route-map-plugin.js +0 -1
- package/dist/service-portal/page-route-map-plugin.js.map +1 -1
- package/dist/service-portal/portal-plugin.js +0 -2
- package/dist/service-portal/portal-plugin.js.map +1 -1
- package/dist/service-portal/theme-plugin.js +0 -2
- package/dist/service-portal/theme-plugin.js.map +1 -1
- package/dist/service-portal/widget-plugin.js +3 -5
- package/dist/service-portal/widget-plugin.js.map +1 -1
- package/dist/sla-plugin.js +0 -2
- package/dist/sla-plugin.js.map +1 -1
- package/dist/static-content-plugin.js +32 -3
- package/dist/static-content-plugin.js.map +1 -1
- package/dist/table-plugin.js +303 -66
- package/dist/table-plugin.js.map +1 -1
- package/dist/ui-action-plugin.js +26 -17
- package/dist/ui-action-plugin.js.map +1 -1
- package/dist/ui-page-plugin.js +159 -17
- package/dist/ui-page-plugin.js.map +1 -1
- package/dist/ui-policy-plugin.js +28 -97
- package/dist/ui-policy-plugin.js.map +1 -1
- package/dist/user-preference-plugin.js +0 -2
- package/dist/user-preference-plugin.js.map +1 -1
- package/dist/utils.d.ts +5 -9
- package/dist/utils.js +38 -11
- package/dist/utils.js.map +1 -1
- package/dist/ux-list-menu-config-plugin.js +0 -2
- package/dist/ux-list-menu-config-plugin.js.map +1 -1
- package/dist/view-plugin.js +0 -1
- package/dist/view-plugin.js.map +1 -1
- package/dist/workspace-plugin.js +0 -2
- package/dist/workspace-plugin.js.map +1 -1
- package/package.json +6 -6
- package/src/acl-plugin.ts +4 -5
- package/src/applicability-plugin.ts +0 -2
- package/src/application-menu-plugin.ts +0 -2
- package/src/arrow-function-plugin.ts +0 -1
- package/src/atf/test-plugin.ts +6 -11
- package/src/basic-syntax-plugin.ts +11 -4
- package/src/business-rule-plugin.ts +1 -2
- package/src/call-expression-plugin.ts +0 -1
- package/src/claims-plugin.ts +0 -1
- package/src/client-script-plugin.ts +1 -2
- package/src/column-plugin.ts +163 -76
- package/src/cross-scope-privilege-plugin.ts +1 -2
- package/src/dashboard/dashboard-plugin.ts +0 -2
- package/src/data-plugin.ts +0 -1
- package/src/data-policy-plugin.ts +333 -0
- package/src/email-notification-plugin.ts +8 -4
- package/src/flow/flow-logic/flow-logic-constants.ts +6 -0
- package/src/flow/flow-logic/flow-logic-diagnostics.ts +236 -58
- package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +59 -6
- package/src/flow/flow-logic/flow-logic-plugin.ts +368 -38
- package/src/flow/flow-logic/flow-logic-shapes.ts +25 -0
- package/src/flow/plugins/approval-rules-plugin.ts +0 -1
- package/src/flow/plugins/flow-action-definition-plugin.ts +940 -208
- package/src/flow/plugins/flow-data-pill-plugin.ts +3 -5
- package/src/flow/plugins/flow-definition-plugin.ts +159 -26
- package/src/flow/plugins/flow-diagnostics-plugin.ts +89 -3
- package/src/flow/plugins/flow-instance-plugin.ts +26 -12
- package/src/flow/plugins/flow-trigger-instance-plugin.ts +0 -1
- package/src/flow/plugins/inline-script-plugin.ts +0 -1
- package/src/flow/plugins/step-definition-plugin.ts +0 -2
- package/src/flow/plugins/step-instance-plugin.ts +259 -65
- package/src/flow/plugins/trigger-plugin.ts +0 -2
- package/src/flow/plugins/wfa-datapill-plugin.ts +0 -1
- package/src/flow/utils/datapill-transformer.ts +13 -5
- package/src/flow/utils/flow-constants.ts +19 -1
- package/src/flow/utils/flow-io-to-record.ts +29 -19
- package/src/flow/utils/flow-pill-utils.ts +48 -0
- package/src/flow/utils/flow-stage-processor.ts +831 -0
- package/src/flow/utils/pill-string-parser.ts +29 -47
- package/src/flow/utils/utils.ts +39 -35
- package/src/form-plugin.ts +5 -15
- package/src/html-import-plugin.ts +0 -1
- package/src/import-sets-plugin.ts +0 -2
- package/src/inbound-email-action-plugin.ts +1 -2
- package/src/index.ts +7 -1
- package/src/instance-scan-plugin.ts +0 -7
- package/src/json-plugin.ts +0 -1
- package/src/list-plugin.ts +6 -2
- package/src/now-attach-plugin.ts +0 -1
- package/src/now-config-plugin.ts +1 -1
- package/src/now-id-plugin.ts +0 -1
- package/src/now-include-plugin.ts +0 -1
- package/src/now-ref-plugin.ts +0 -1
- package/src/now-unresolved-plugin.ts +0 -1
- package/src/package-json-plugin.ts +8 -3
- package/src/property-plugin.ts +0 -2
- package/src/record-plugin.ts +14 -6
- package/src/repack/lint/Rules.ts +1 -1
- package/src/rest-api-plugin.ts +7 -6
- package/src/role-plugin.ts +1 -2
- package/src/schedule-script/scheduled-script-plugin.ts +11 -5
- package/src/script-action-plugin.ts +0 -2
- package/src/script-include-plugin.ts +8 -4
- package/src/server-module-plugin/index.ts +2 -3
- package/src/service-catalog/catalog-clientscript-plugin.ts +2 -4
- package/src/service-catalog/catalog-item-plugin.ts +0 -2
- package/src/service-catalog/catalog-ui-policy-plugin.ts +2 -4
- package/src/service-catalog/sc-record-producer-plugin.ts +0 -2
- package/src/service-catalog/service-catalog-base.ts +2 -2
- package/src/service-catalog/utils.ts +1 -1
- package/src/service-catalog/variable-set-plugin.ts +0 -2
- package/src/service-portal/angular-provider-plugin.ts +0 -2
- package/src/service-portal/dependency-plugin.ts +0 -2
- package/src/service-portal/header-footer-plugin.ts +0 -2
- package/src/service-portal/menu-plugin.ts +1 -2
- package/src/service-portal/page-plugin.ts +1 -2
- package/src/service-portal/page-route-map-plugin.ts +1 -2
- package/src/service-portal/portal-plugin.ts +0 -2
- package/src/service-portal/theme-plugin.ts +0 -2
- package/src/service-portal/widget-plugin.ts +0 -2
- package/src/sla-plugin.ts +0 -2
- package/src/static-content-plugin.ts +37 -4
- package/src/table-plugin.ts +371 -92
- package/src/ui-action-plugin.ts +30 -17
- package/src/ui-page-plugin.ts +188 -20
- package/src/ui-policy-plugin.ts +33 -130
- package/src/user-preference-plugin.ts +0 -2
- package/src/utils.ts +48 -11
- package/src/ux-list-menu-config-plugin.ts +0 -2
- package/src/view-plugin.ts +0 -1
- package/src/workspace-plugin.ts +0 -2
|
@@ -21,6 +21,9 @@ import {
|
|
|
21
21
|
BUILT_IN_STEP_DEFINITIONS,
|
|
22
22
|
BUILT_IN_STEP_NAME_TO_SYSID,
|
|
23
23
|
BUILT_IN_STEP_PREFIX,
|
|
24
|
+
STEP_DEF_INPUT_TABLE_PREFIX,
|
|
25
|
+
EXT_INPUT_TABLE_PREFIX,
|
|
26
|
+
EXT_OUTPUT_TABLE_PREFIX,
|
|
24
27
|
buildExtVarAttributes,
|
|
25
28
|
getVarEntryName,
|
|
26
29
|
getVarEntryType,
|
|
@@ -28,8 +31,8 @@ import {
|
|
|
28
31
|
FLOW_ARRAY_API_NAME,
|
|
29
32
|
} from '../utils/flow-constants'
|
|
30
33
|
import { normalizeInputValue } from './flow-instance-plugin'
|
|
34
|
+
import { stripPillType, collectPillTypes } from '../utils/flow-pill-utils'
|
|
31
35
|
import { ApprovalRulesShape, ApprovalDueDateShape } from '../utils/flow-shapes'
|
|
32
|
-
import { createSdkDocEntry } from '../../utils'
|
|
33
36
|
import {
|
|
34
37
|
generateSchemaFromObject,
|
|
35
38
|
getComplexObjectAttributes,
|
|
@@ -123,42 +126,7 @@ function resolveFieldToPillString(fieldShape: Shape, cidMap?: Map<string, string
|
|
|
123
126
|
return undefined
|
|
124
127
|
}
|
|
125
128
|
|
|
126
|
-
|
|
127
|
-
* Extracts pill type annotations from a pill string and stores them in the pillTypeMap.
|
|
128
|
-
* Captures types from both step pills ({{step[CID].path|type}}) and action pills
|
|
129
|
-
* ({{action.path|type}}). The "|type" portion is captured before it gets stripped
|
|
130
|
-
* for the element_mapping value. The collected types are used later when building the label_cache.
|
|
131
|
-
*/
|
|
132
|
-
const STEP_PILL_TYPE_REGEX = /\{\{step\[([^\]]+)\]\.([^|}]+)(?:\|([^}]+))?\}\}/g
|
|
133
|
-
const ACTION_PILL_TYPE_REGEX = /\{\{action\.([^|}]+)(?:\|([^}]+))?\}\}/g
|
|
134
|
-
function collectPillTypes(pillString: string, pillTypeMap?: Map<string, string>): void {
|
|
135
|
-
if (!pillTypeMap) {
|
|
136
|
-
return
|
|
137
|
-
}
|
|
138
|
-
for (const match of pillString.matchAll(STEP_PILL_TYPE_REGEX)) {
|
|
139
|
-
const [, cid, pillPath, dataType] = match
|
|
140
|
-
if (cid && pillPath && dataType) {
|
|
141
|
-
pillTypeMap.set(`${cid}::${pillPath}`, dataType)
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
for (const match of pillString.matchAll(ACTION_PILL_TYPE_REGEX)) {
|
|
145
|
-
const [, path, dataType] = match
|
|
146
|
-
if (path && dataType) {
|
|
147
|
-
pillTypeMap.set(`action::${path}`, dataType)
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Strips the |type suffix from a pill string.
|
|
154
|
-
* e.g., "{{action.desc|string}}" → "{{action.desc}}"
|
|
155
|
-
*
|
|
156
|
-
* Note: This is called on individual pill strings (from resolveFieldToPillString),
|
|
157
|
-
* never on concatenated multi-pill strings — so no `g` flag is needed.
|
|
158
|
-
*/
|
|
159
|
-
function stripPillType(pill: string): string {
|
|
160
|
-
return pill.replace(/\|[^}]+/, '')
|
|
161
|
-
}
|
|
129
|
+
// stripPillType, collectPillTypes, and STEP_PILL_TYPE_REGEX are imported from ../utils/flow-pill-utils
|
|
162
130
|
|
|
163
131
|
/**
|
|
164
132
|
* Resolves a TemplateExpressionShape into a concatenated string, replacing
|
|
@@ -266,7 +234,6 @@ export class StepInstanceShape extends CallExpressionShape {
|
|
|
266
234
|
|
|
267
235
|
export const StepInstancePlugin = Plugin.create({
|
|
268
236
|
name: 'StepInstancePlugin',
|
|
269
|
-
docs: [createSdkDocEntry('wfa.actionStep', ['sys_hub_step_instance'])],
|
|
270
237
|
shapes: [
|
|
271
238
|
{
|
|
272
239
|
shape: CallExpressionShape,
|
|
@@ -368,9 +335,11 @@ export const StepInstancePlugin = Plugin.create({
|
|
|
368
335
|
...(inputDefinitions ? { inputDefinitions } : {}),
|
|
369
336
|
}
|
|
370
337
|
|
|
338
|
+
const newShape = new StepInstanceShape(shapeArgs)
|
|
339
|
+
|
|
371
340
|
return {
|
|
372
341
|
success: true,
|
|
373
|
-
value:
|
|
342
|
+
value: newShape,
|
|
374
343
|
}
|
|
375
344
|
},
|
|
376
345
|
},
|
|
@@ -624,7 +593,7 @@ async function buildStepInstanceRecord({
|
|
|
624
593
|
const inputVarObj = inputVariablesShape.asObject()
|
|
625
594
|
const inputVarProps = inputVarObj.properties({ resolve: false })
|
|
626
595
|
|
|
627
|
-
const extInputTableName =
|
|
596
|
+
const extInputTableName = `${EXT_INPUT_TABLE_PREFIX}${stepInstanceSysId}`
|
|
628
597
|
|
|
629
598
|
for (const [name, configShapeRaw] of Object.entries(inputVarProps)) {
|
|
630
599
|
const configObj = configShapeRaw.asObject()
|
|
@@ -799,7 +768,7 @@ async function buildStepInstanceRecord({
|
|
|
799
768
|
model: stepInstanceSysId,
|
|
800
769
|
model_id: stepInstanceSysId,
|
|
801
770
|
model_table: 'sys_hub_step_instance',
|
|
802
|
-
name:
|
|
771
|
+
name: `${EXT_OUTPUT_TABLE_PREFIX}${stepInstanceSysId}`,
|
|
803
772
|
element: columnName,
|
|
804
773
|
label: columnLabel || columnName,
|
|
805
774
|
internal_type: 'string',
|
|
@@ -823,7 +792,7 @@ async function buildStepInstanceRecord({
|
|
|
823
792
|
model: stepInstanceSysId,
|
|
824
793
|
model_id: stepInstanceSysId,
|
|
825
794
|
model_table: 'sys_hub_step_instance',
|
|
826
|
-
name:
|
|
795
|
+
name: `${EXT_OUTPUT_TABLE_PREFIX}${stepInstanceSysId}`,
|
|
827
796
|
element: columnName,
|
|
828
797
|
label: columnLabel || columnName,
|
|
829
798
|
internal_type: internalType,
|
|
@@ -847,6 +816,165 @@ async function buildStepInstanceRecord({
|
|
|
847
816
|
...complexObjectRecords
|
|
848
817
|
)
|
|
849
818
|
}
|
|
819
|
+
/**
|
|
820
|
+
* Resolves datapill shapes (CallExpressionShape from wfa.dataPill()) inside an ApprovalRulesShape
|
|
821
|
+
* back to pill strings (e.g. {{action.reference}}) so approvalRulesJsonToString() can serialize them.
|
|
822
|
+
* Also collects pill types for label_cache and reports whether any pills were found.
|
|
823
|
+
*
|
|
824
|
+
* IMPORTANT: Must use Shape API with resolve=false to access raw CallExpressionShape instances.
|
|
825
|
+
* getApprovalRules()/getValue() resolves shapes to Symbols, losing the pill information.
|
|
826
|
+
*/
|
|
827
|
+
function resolveApprovalRulesPills(
|
|
828
|
+
shape: ApprovalRulesShape,
|
|
829
|
+
callExpression: { getSource(): Source },
|
|
830
|
+
cidMap?: Map<string, string>,
|
|
831
|
+
pillTypeMap?: Map<string, string>
|
|
832
|
+
): { resolvedShape: ApprovalRulesShape; hasPills: boolean } {
|
|
833
|
+
// Get the resolved rules data (non-pill fields resolve to plain values correctly)
|
|
834
|
+
const rules = shape.getApprovalRules()
|
|
835
|
+
let hasPills = false
|
|
836
|
+
|
|
837
|
+
// Walk the raw Shape tree in parallel to find unresolved CallExpressionShape pills.
|
|
838
|
+
// shape.get('ruleSets', false) returns the raw ArrayShape without resolving nested shapes.
|
|
839
|
+
const ruleSetsShape = shape.get('ruleSets', false).ifArray()
|
|
840
|
+
if (!ruleSetsShape) {
|
|
841
|
+
return { resolvedShape: shape, hasPills: false }
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
ruleSetsShape.getElements(false).forEach((ruleSetShape, rsIdx) => {
|
|
845
|
+
const ruleSetObj = ruleSetShape.ifObject()
|
|
846
|
+
const rulesArrayShape = ruleSetObj?.get('rules', false).ifArray()
|
|
847
|
+
|
|
848
|
+
rulesArrayShape?.getElements(false).forEach((ruleShape, rIdx) => {
|
|
849
|
+
const ruleArray = ruleShape.ifArray()
|
|
850
|
+
|
|
851
|
+
ruleArray?.getElements(false).forEach((conditionShape, cIdx) => {
|
|
852
|
+
const conditionObj = conditionShape.ifObject()
|
|
853
|
+
if (!conditionObj) {
|
|
854
|
+
return
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
const ruleSet = rules.ruleSets?.[rsIdx]
|
|
858
|
+
const rule = ruleSet?.rules?.[rIdx]
|
|
859
|
+
const condition = rule?.[cIdx]
|
|
860
|
+
if (!condition) {
|
|
861
|
+
return
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// Resolve pills in users array
|
|
865
|
+
conditionObj
|
|
866
|
+
.get('users', false)
|
|
867
|
+
.ifArray()
|
|
868
|
+
?.getElements(false)
|
|
869
|
+
.forEach((userShape, uIdx) => {
|
|
870
|
+
const pillStr = resolveShapeToPill(userShape, cidMap, pillTypeMap)
|
|
871
|
+
if (pillStr && condition.users) {
|
|
872
|
+
hasPills = true
|
|
873
|
+
condition.users[uIdx] = pillStr
|
|
874
|
+
}
|
|
875
|
+
})
|
|
876
|
+
|
|
877
|
+
// Resolve pills in groups array
|
|
878
|
+
conditionObj
|
|
879
|
+
.get('groups', false)
|
|
880
|
+
.ifArray()
|
|
881
|
+
?.getElements(false)
|
|
882
|
+
.forEach((groupShape, gIdx) => {
|
|
883
|
+
const pillStr = resolveShapeToPill(groupShape, cidMap, pillTypeMap)
|
|
884
|
+
if (pillStr && condition.groups) {
|
|
885
|
+
hasPills = true
|
|
886
|
+
condition.groups[gIdx] = pillStr
|
|
887
|
+
}
|
|
888
|
+
})
|
|
889
|
+
})
|
|
890
|
+
})
|
|
891
|
+
})
|
|
892
|
+
|
|
893
|
+
if (!hasPills) {
|
|
894
|
+
return { resolvedShape: shape, hasPills: false }
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
return {
|
|
898
|
+
resolvedShape: new ApprovalRulesShape({
|
|
899
|
+
source: callExpression.getSource(),
|
|
900
|
+
value: rules,
|
|
901
|
+
}),
|
|
902
|
+
hasPills: true,
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Resolves datapill shapes (CallExpressionShape from wfa.dataPill()) inside an ApprovalDueDateShape
|
|
908
|
+
* back to pill strings (e.g. {{action.date}}) so the JSON serialization produces correct output.
|
|
909
|
+
*
|
|
910
|
+
* IMPORTANT: Must use shape.get('date', false) to access the raw Shape. getApprovalDueDate()
|
|
911
|
+
* calls getValue() which resolves CallExpressionShape to Symbol, losing the pill information.
|
|
912
|
+
*/
|
|
913
|
+
function resolveApprovalDueDatePills(
|
|
914
|
+
shape: ApprovalDueDateShape,
|
|
915
|
+
callExpression: { getSource(): Source },
|
|
916
|
+
cidMap?: Map<string, string>,
|
|
917
|
+
pillTypeMap?: Map<string, string>
|
|
918
|
+
): ApprovalDueDateShape {
|
|
919
|
+
// Access 'date' as raw Shape (not resolved via getValue())
|
|
920
|
+
const dateShape = shape.get('date', false)
|
|
921
|
+
const pillStr = resolveShapeToPill(dateShape, cidMap, pillTypeMap)
|
|
922
|
+
if (!pillStr) {
|
|
923
|
+
// Unresolvable pill (e.g. step pill when cidMap is not yet populated).
|
|
924
|
+
// Return original shape — resolveUnresolvedStepPills() will handle it later.
|
|
925
|
+
return shape
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
// Get all other resolved values and override date with the pill string
|
|
929
|
+
const dueDate = shape.getApprovalDueDate()
|
|
930
|
+
return new ApprovalDueDateShape({
|
|
931
|
+
source: callExpression.getSource(),
|
|
932
|
+
value: { ...dueDate, date: pillStr },
|
|
933
|
+
})
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* If `shape` is a datapill (CallExpressionShape with callee wfa.dataPill, or PillShape),
|
|
938
|
+
* resolves it to a pill string (e.g. {{action.reference}}), strips the type suffix,
|
|
939
|
+
* collects pill types for label_cache, and returns the stripped string.
|
|
940
|
+
* Returns undefined if the shape is not a pill.
|
|
941
|
+
*/
|
|
942
|
+
function resolveShapeToPill(
|
|
943
|
+
shape: Shape,
|
|
944
|
+
cidMap?: Map<string, string>,
|
|
945
|
+
pillTypeMap?: Map<string, string>
|
|
946
|
+
): string | undefined {
|
|
947
|
+
const pillString = resolveFieldToPillString(shape, cidMap)
|
|
948
|
+
if (!pillString) {
|
|
949
|
+
return undefined
|
|
950
|
+
}
|
|
951
|
+
collectPillTypes(pillString, pillTypeMap)
|
|
952
|
+
return stripPillType(pillString)
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Checks if a wfa.dataPill() CallExpressionShape is an action pill (params.inputs.*).
|
|
957
|
+
* Used to distinguish action pills from step pills when deciding whether to defer resolution.
|
|
958
|
+
*/
|
|
959
|
+
function isActionPillShape(shape: CallExpressionShape): boolean {
|
|
960
|
+
const expressionArg = shape.getArgument(0, false)
|
|
961
|
+
if (!(expressionArg instanceof PropertyAccessShape)) {
|
|
962
|
+
return false
|
|
963
|
+
}
|
|
964
|
+
const elements = expressionArg.getElements()
|
|
965
|
+
if (elements.length < 3) {
|
|
966
|
+
return false
|
|
967
|
+
}
|
|
968
|
+
const first = elements[0]
|
|
969
|
+
const second = elements[1]
|
|
970
|
+
return (
|
|
971
|
+
first instanceof IdentifierShape &&
|
|
972
|
+
first.getName() === 'params' &&
|
|
973
|
+
second instanceof IdentifierShape &&
|
|
974
|
+
second.getName() === 'inputs'
|
|
975
|
+
)
|
|
976
|
+
}
|
|
977
|
+
|
|
850
978
|
async function createVariableRecords(
|
|
851
979
|
valuesProperties: globalThis.Record<string, Shape>,
|
|
852
980
|
inputs: ObjectShape | undefined,
|
|
@@ -890,19 +1018,47 @@ async function createVariableRecords(
|
|
|
890
1018
|
// ApprovalDueDateShape: store JSON in sys_element_mapping.value (ServiceNow reads from there)
|
|
891
1019
|
// and create sys_variable_value with empty value
|
|
892
1020
|
if (valueShape.is(ApprovalDueDateShape)) {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1021
|
+
// Resolve any datapill shapes (e.g. wfa.dataPill()) inside the due date
|
|
1022
|
+
// back to pill strings (e.g. {{action.date}}) before serialization
|
|
1023
|
+
const resolvedDueDateShape = resolveApprovalDueDatePills(
|
|
1024
|
+
valueShape as ApprovalDueDateShape,
|
|
1025
|
+
callExpression,
|
|
1026
|
+
cidMap,
|
|
1027
|
+
pillTypeMap
|
|
1028
|
+
)
|
|
1029
|
+
|
|
1030
|
+
// Check if date contains an unresolved step pill. During initial auto-processing
|
|
1031
|
+
// (inside transform.toShape), cidMap is not yet populated so step pills can't be
|
|
1032
|
+
// resolved. In that case, skip element_mapping creation here —
|
|
1033
|
+
// resolveUnresolvedStepPills() in flow-action-definition-plugin will create it
|
|
1034
|
+
// once cidMap is fully built.
|
|
1035
|
+
const dateShape = (valueShape as ApprovalDueDateShape).get('date', false)
|
|
1036
|
+
const hasUnresolvedStepPill =
|
|
1037
|
+
dateShape instanceof CallExpressionShape &&
|
|
1038
|
+
dateShape.getCallee() === 'wfa.dataPill' &&
|
|
1039
|
+
!isActionPillShape(dateShape) &&
|
|
1040
|
+
!resolveShapeToPill(dateShape, cidMap, pillTypeMap)
|
|
1041
|
+
|
|
1042
|
+
const records: BuildRecord[] = []
|
|
1043
|
+
|
|
1044
|
+
if (!hasUnresolvedStepPill) {
|
|
1045
|
+
const jsonValue = resolvedDueDateShape.toString().getValue()
|
|
1046
|
+
records.push(
|
|
1047
|
+
await factory.createRecord({
|
|
1048
|
+
source: callExpression,
|
|
1049
|
+
table: 'sys_element_mapping',
|
|
1050
|
+
properties: {
|
|
1051
|
+
field: key,
|
|
1052
|
+
id: stepInstanceSysId,
|
|
1053
|
+
table: `${STEP_DEF_INPUT_TABLE_PREFIX}${stepDefinitionSysId}`,
|
|
1054
|
+
value: jsonValue,
|
|
1055
|
+
},
|
|
1056
|
+
})
|
|
1057
|
+
)
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
records.push(
|
|
1061
|
+
await factory.createRecord({
|
|
906
1062
|
source: callExpression,
|
|
907
1063
|
table: 'sys_variable_value',
|
|
908
1064
|
properties: {
|
|
@@ -913,9 +1069,10 @@ async function createVariableRecords(
|
|
|
913
1069
|
value: '',
|
|
914
1070
|
variable: variableSysId,
|
|
915
1071
|
},
|
|
916
|
-
})
|
|
917
|
-
|
|
918
|
-
|
|
1072
|
+
})
|
|
1073
|
+
)
|
|
1074
|
+
|
|
1075
|
+
allRecords.push(...records)
|
|
919
1076
|
return
|
|
920
1077
|
}
|
|
921
1078
|
|
|
@@ -964,7 +1121,7 @@ async function createVariableRecords(
|
|
|
964
1121
|
properties: {
|
|
965
1122
|
field: key,
|
|
966
1123
|
id: stepInstanceSysId,
|
|
967
|
-
table:
|
|
1124
|
+
table: `${STEP_DEF_INPUT_TABLE_PREFIX}${stepDefinitionSysId}`,
|
|
968
1125
|
value: encodedValue,
|
|
969
1126
|
},
|
|
970
1127
|
})
|
|
@@ -978,10 +1135,47 @@ async function createVariableRecords(
|
|
|
978
1135
|
// DurationShape.getValue() returns a symbol, so use toString() instead
|
|
979
1136
|
actualValue = (valueShape as DurationShape).toString().getValue()
|
|
980
1137
|
} else if (valueShape.is(ApprovalRulesShape)) {
|
|
981
|
-
//
|
|
982
|
-
//
|
|
983
|
-
|
|
984
|
-
|
|
1138
|
+
// Resolve any datapill shapes (e.g. wfa.dataPill()) inside approval rules
|
|
1139
|
+
// back to pill strings (e.g. {{action.reference}}) before serialization
|
|
1140
|
+
const { resolvedShape: resolvedRulesShape, hasPills: rulesHasPills } = resolveApprovalRulesPills(
|
|
1141
|
+
valueShape as ApprovalRulesShape,
|
|
1142
|
+
callExpression,
|
|
1143
|
+
cidMap,
|
|
1144
|
+
pillTypeMap
|
|
1145
|
+
)
|
|
1146
|
+
const serializedRules = resolvedRulesShape.toString().getValue()
|
|
1147
|
+
|
|
1148
|
+
if (rulesHasPills) {
|
|
1149
|
+
// Pills found — store in sys_element_mapping (platform reads pills from there)
|
|
1150
|
+
// and create empty sys_variable_value (same pattern as ApprovalDueDateShape)
|
|
1151
|
+
const [elementMappingRecord, variableValueRecord] = await Promise.all([
|
|
1152
|
+
factory.createRecord({
|
|
1153
|
+
source: callExpression,
|
|
1154
|
+
table: 'sys_element_mapping',
|
|
1155
|
+
properties: {
|
|
1156
|
+
field: key,
|
|
1157
|
+
id: stepInstanceSysId,
|
|
1158
|
+
table: `${STEP_DEF_INPUT_TABLE_PREFIX}${stepDefinitionSysId}`,
|
|
1159
|
+
value: serializedRules,
|
|
1160
|
+
},
|
|
1161
|
+
}),
|
|
1162
|
+
factory.createRecord({
|
|
1163
|
+
source: callExpression,
|
|
1164
|
+
table: 'sys_variable_value',
|
|
1165
|
+
properties: {
|
|
1166
|
+
document: 'sys_hub_step_instance',
|
|
1167
|
+
document_key: stepInstanceSysId,
|
|
1168
|
+
order: 100,
|
|
1169
|
+
value: '',
|
|
1170
|
+
variable: variableSysId,
|
|
1171
|
+
},
|
|
1172
|
+
}),
|
|
1173
|
+
])
|
|
1174
|
+
allRecords.push(elementMappingRecord, variableValueRecord)
|
|
1175
|
+
return
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
actualValue = serializedRules
|
|
985
1179
|
} else if (valueShape.is(TemplateExpressionShape)) {
|
|
986
1180
|
const { result, hasPills } = resolveTemplateExpression(
|
|
987
1181
|
valueShape as TemplateExpressionShape,
|
|
@@ -996,7 +1190,7 @@ async function createVariableRecords(
|
|
|
996
1190
|
properties: {
|
|
997
1191
|
field: key,
|
|
998
1192
|
id: stepInstanceSysId,
|
|
999
|
-
table:
|
|
1193
|
+
table: `${STEP_DEF_INPUT_TABLE_PREFIX}${stepDefinitionSysId}`,
|
|
1000
1194
|
value: result,
|
|
1001
1195
|
},
|
|
1002
1196
|
})
|
|
@@ -1017,7 +1211,7 @@ async function createVariableRecords(
|
|
|
1017
1211
|
properties: {
|
|
1018
1212
|
field: key,
|
|
1019
1213
|
id: stepInstanceSysId,
|
|
1020
|
-
table:
|
|
1214
|
+
table: `${STEP_DEF_INPUT_TABLE_PREFIX}${stepDefinitionSysId}`,
|
|
1021
1215
|
value: stripPillType(pillString),
|
|
1022
1216
|
},
|
|
1023
1217
|
})
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { CallExpressionShape, Plugin } from '@servicenow/sdk-build-core'
|
|
2
2
|
import { buildVariableShapes, complexObjectMatchesIoRecord } from '../utils/flow-io-to-record'
|
|
3
3
|
import { NowIdShape } from '../../now-id-plugin'
|
|
4
|
-
import { createSdkDocEntry } from '../../utils'
|
|
5
4
|
|
|
6
5
|
export const TriggerPlugin = Plugin.create({
|
|
7
6
|
name: 'TriggerPlugin',
|
|
8
|
-
docs: [createSdkDocEntry('TriggerDefinition', ['sys_hub_trigger_definition'])],
|
|
9
7
|
records: {
|
|
10
8
|
sys_hub_trigger_definition: {
|
|
11
9
|
relationships: {
|
|
@@ -383,10 +383,14 @@ export function processInstanceForDatapills(
|
|
|
383
383
|
let configArgIndex: number
|
|
384
384
|
|
|
385
385
|
if (isFlowLogic) {
|
|
386
|
-
// For SetFlowVariables and AssignSubflowOutputs, transform the values object (3rd
|
|
387
|
-
// For ForEach, transform the config (2nd argument)
|
|
388
|
-
//
|
|
389
|
-
if (
|
|
386
|
+
// For SetFlowVariables, AppendToFlowVariables, and AssignSubflowOutputs, transform the values object (3rd
|
|
387
|
+
// argument). For ForEach, transform the config (2nd argument). For other flow logic, transform the config (1st
|
|
388
|
+
// argument).
|
|
389
|
+
if (
|
|
390
|
+
callee === FLOW_LOGIC.SET_FLOW_VARIABLES ||
|
|
391
|
+
callee === FLOW_LOGIC.APPEND_TO_FLOW_VARIABLES ||
|
|
392
|
+
callee === FLOW_LOGIC.ASSIGN_SUBFLOW_OUTPUTS
|
|
393
|
+
) {
|
|
390
394
|
configArgIndex = 2
|
|
391
395
|
propsArg = callExpression.getArgument(2)
|
|
392
396
|
} else if (callee === FLOW_LOGIC.FOR_EACH) {
|
|
@@ -412,7 +416,11 @@ export function processInstanceForDatapills(
|
|
|
412
416
|
// The schema argument (arg 1) contains PropertyAccessShape with placeholder identifier (_params)
|
|
413
417
|
// that needs to be resolved to the actual parameter name
|
|
414
418
|
let transformedSchemaArg: Shape | undefined
|
|
415
|
-
if (
|
|
419
|
+
if (
|
|
420
|
+
callee === FLOW_LOGIC.SET_FLOW_VARIABLES ||
|
|
421
|
+
callee === FLOW_LOGIC.APPEND_TO_FLOW_VARIABLES ||
|
|
422
|
+
callee === FLOW_LOGIC.ASSIGN_SUBFLOW_OUTPUTS
|
|
423
|
+
) {
|
|
416
424
|
const schemaArg = callExpression.getArgument(1)
|
|
417
425
|
if (schemaArg) {
|
|
418
426
|
const schemaResult = processShapeForDatapills(
|
|
@@ -15,7 +15,6 @@ export const CATALOG_VARIABLE_TABLE = 'item_option_new'
|
|
|
15
15
|
export const CATALOG_VARIABLE_SET_TABLE = 'io_set_item'
|
|
16
16
|
|
|
17
17
|
export const UNSUPPORTED_FLOW_DESCENDANTS = [
|
|
18
|
-
FLOW_STAGE_TABLE,
|
|
19
18
|
PILL_COMPOUND_TABLE,
|
|
20
19
|
TRIGGER_INSTANCE_TABLE,
|
|
21
20
|
ACTION_INSTANCE_TABLE,
|
|
@@ -23,6 +22,15 @@ export const UNSUPPORTED_FLOW_DESCENDANTS = [
|
|
|
23
22
|
FLOW_LOGIC_INSTANCE_TABLE,
|
|
24
23
|
]
|
|
25
24
|
|
|
25
|
+
/** Callee name for wfa.stage() calls in the flow body. */
|
|
26
|
+
export const STAGE_API_NAME = 'wfa.stage'
|
|
27
|
+
|
|
28
|
+
/** Callee name for FlowStage() declarations in the stages config header. */
|
|
29
|
+
export const FLOW_STAGE_CALLEE = 'FlowStage'
|
|
30
|
+
|
|
31
|
+
/** Default duration written to sys_hub_flow_stage when the developer omits `duration` (zero duration in UTC). */
|
|
32
|
+
export const STAGE_DEFAULT_DURATION = '1970-01-01 00:00:00'
|
|
33
|
+
|
|
26
34
|
//Plugins callee names
|
|
27
35
|
export const FLOW_API_NAME = 'Flow'
|
|
28
36
|
export const SUBFLOW_API_NAME = 'Subflow'
|
|
@@ -35,12 +43,20 @@ export const SUBFLOW_INSTANCE_API_NAME = 'wfa.subflow'
|
|
|
35
43
|
export const ACTION_STEP_INSTANCE_API_NAME = 'wfa.actionStep'
|
|
36
44
|
export const APPROVAL_RULES_API_NAME = 'wfa.approvalRules'
|
|
37
45
|
export const APPROVAL_DUE_DATE_API_NAME = 'wfa.approvalDueDate'
|
|
46
|
+
export const ASSIGN_ACTION_OUTPUTS_CALLEE = 'wfa.assignActionOutputs'
|
|
47
|
+
export const ERROR_EVALUATION_CALLEE = 'wfa.errorEvaluation'
|
|
38
48
|
|
|
39
49
|
export const FLOW_OBJECT_API_NAME = 'FlowObject'
|
|
40
50
|
export const FLOW_ARRAY_API_NAME = 'FlowArray'
|
|
41
51
|
|
|
42
52
|
export const ELEMENT_MAPPING_PROVIDER = 'com.glide.flow_design.action.data.FlowDesignVariableMapper'
|
|
43
53
|
|
|
54
|
+
// Element mapping table name prefixes — used in sys_element_mapping.table to identify the source
|
|
55
|
+
export const STEP_DEF_INPUT_TABLE_PREFIX = 'var__m_sys_flow_step_definition_input_'
|
|
56
|
+
export const EXT_INPUT_TABLE_PREFIX = 'var__m_sys_hub_step_ext_input_'
|
|
57
|
+
export const EXT_OUTPUT_TABLE_PREFIX = 'var__m_sys_hub_step_ext_output_'
|
|
58
|
+
export const ACTION_OUTPUT_TABLE_PREFIX = 'var__m_sys_hub_action_output_'
|
|
59
|
+
|
|
44
60
|
const UI_TYPE_LABEL: { [key: string]: string } = {
|
|
45
61
|
string: 'String',
|
|
46
62
|
integer: 'Integer',
|
|
@@ -640,6 +656,8 @@ export async function createActionErrorAndStatusRecords(
|
|
|
640
656
|
order: 2,
|
|
641
657
|
max_length: 40,
|
|
642
658
|
...props,
|
|
659
|
+
internal_type: 'boolean',
|
|
660
|
+
default_value: 'true',
|
|
643
661
|
attributes: getActionOutputAttributes(actionTypeId, 'action_error'),
|
|
644
662
|
},
|
|
645
663
|
})
|
|
@@ -24,7 +24,13 @@ import {
|
|
|
24
24
|
} from './complex-objects'
|
|
25
25
|
import { getChoiceRecords, getDocumentationRecords } from '../../column/column-to-record'
|
|
26
26
|
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
ChoiceDropdown,
|
|
29
|
+
COLUMN_DEFAULTS,
|
|
30
|
+
ELEMENT_MAPPING_PROVIDER,
|
|
31
|
+
createActionErrorAndStatusRecords,
|
|
32
|
+
getUiTypeLabel,
|
|
33
|
+
} from './flow-constants'
|
|
28
34
|
import { NowIdShape } from '../../now-id-plugin'
|
|
29
35
|
|
|
30
36
|
/**
|
|
@@ -157,16 +163,30 @@ export async function buildVariableRecords(options: {
|
|
|
157
163
|
} else {
|
|
158
164
|
// Extract attributes from column config if present
|
|
159
165
|
const userAttributes = extractUserAttributes(config)
|
|
160
|
-
const attributesStr = Object.entries(userAttributes)
|
|
161
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
162
|
-
.join(',')
|
|
163
|
-
additionalProperties['attributes'] = attributesStr
|
|
164
166
|
let internal_type: string
|
|
165
167
|
if (callExpr.getCallee() === GenericColumn.name) {
|
|
166
168
|
internal_type = config.get('columnType')?.ifString()?.getValue() ?? 'string'
|
|
167
169
|
} else {
|
|
168
170
|
internal_type = COLUMN_API_TO_TYPE[callExpr.getCallee() as keyof typeof COLUMN_API_TO_TYPE] ?? 'string'
|
|
169
171
|
}
|
|
172
|
+
|
|
173
|
+
// For output variables, add element_mapping_provider and related attributes
|
|
174
|
+
// so Flow Designer knows to resolve datapill values via sys_element_mapping records
|
|
175
|
+
if (isOutput) {
|
|
176
|
+
const actionDefId = parentRecord.getId().getValue()
|
|
177
|
+
const systemAttributes: globalThis.Record<string, string> = {
|
|
178
|
+
element_mapping_provider: ELEMENT_MAPPING_PROVIDER,
|
|
179
|
+
pwd2droppable: 'true',
|
|
180
|
+
uiType: internal_type,
|
|
181
|
+
uiTypeLabel: getUiTypeLabel(internal_type),
|
|
182
|
+
uiUniqueId: `${actionDefId}-${k}`,
|
|
183
|
+
}
|
|
184
|
+
const allAttributes = { ...systemAttributes, ...userAttributes }
|
|
185
|
+
additionalProperties['attributes'] = formatComplexObjectAttributes(allAttributes)
|
|
186
|
+
} else {
|
|
187
|
+
additionalProperties['attributes'] = formatComplexObjectAttributes(userAttributes)
|
|
188
|
+
}
|
|
189
|
+
|
|
170
190
|
// Handle reference columns - extract reference table
|
|
171
191
|
if (internal_type === 'reference' || internal_type === 'records') {
|
|
172
192
|
const referenceTable = config.get('referenceTable')?.ifString()?.getValue()
|
|
@@ -223,8 +243,7 @@ export async function buildVariableRecords(options: {
|
|
|
223
243
|
export function buildVariableShapes(
|
|
224
244
|
variableRecords: Record[],
|
|
225
245
|
descendants: Database,
|
|
226
|
-
logger?: Logger
|
|
227
|
-
snapshotValues?: Map<string, string>
|
|
246
|
+
logger?: Logger
|
|
228
247
|
): globalThis.Record<string, CallExpressionShape> | undefined {
|
|
229
248
|
const shapes: globalThis.Record<string, CallExpressionShape> = {}
|
|
230
249
|
|
|
@@ -272,15 +291,12 @@ export function buildVariableShapes(
|
|
|
272
291
|
|
|
273
292
|
// Only include $id and co_type_name if NOT deterministically generated
|
|
274
293
|
const schema = JSON.parse(serializedContent)
|
|
275
|
-
const snapshotValue =
|
|
276
|
-
snapshotValues?.get(name) ?? variable.get('default_value')?.ifString()?.ifNotEmpty()?.getValue()
|
|
277
294
|
shapes[name] = buildComplexObjectFromSchema(
|
|
278
295
|
variable,
|
|
279
296
|
schema,
|
|
280
297
|
attributes,
|
|
281
298
|
isDeterministic ? undefined : complexObjectSysId,
|
|
282
|
-
isDeterministic ? undefined : maybeCoTypeName
|
|
283
|
-
snapshotValue
|
|
299
|
+
isDeterministic ? undefined : maybeCoTypeName
|
|
284
300
|
)
|
|
285
301
|
} else {
|
|
286
302
|
const variableName = variable.get('name').ifString()?.getValue()
|
|
@@ -293,8 +309,7 @@ export function buildVariableShapes(
|
|
|
293
309
|
variable,
|
|
294
310
|
additionalProps,
|
|
295
311
|
descendants,
|
|
296
|
-
documentation
|
|
297
|
-
snapshotValues?.get(name)
|
|
312
|
+
documentation
|
|
298
313
|
)
|
|
299
314
|
}
|
|
300
315
|
}
|
|
@@ -332,8 +347,7 @@ function buildBasicVariableShape(
|
|
|
332
347
|
variable: Record,
|
|
333
348
|
additionalProps: globalThis.Record<string, unknown>,
|
|
334
349
|
descendants: Database,
|
|
335
|
-
documentation: Record[]
|
|
336
|
-
snapshotValue?: string
|
|
350
|
+
documentation: Record[]
|
|
337
351
|
) {
|
|
338
352
|
if (callExpressionName === ChoiceColumn.name) {
|
|
339
353
|
// choice column with choices from other table
|
|
@@ -407,10 +421,6 @@ function buildBasicVariableShape(
|
|
|
407
421
|
.def(choiceDropdown[1]),
|
|
408
422
|
default: $.from('default_value')
|
|
409
423
|
.map((value) => {
|
|
410
|
-
// Snapshot output value (datapill or static) takes priority
|
|
411
|
-
if (snapshotValue !== undefined && snapshotValue !== '') {
|
|
412
|
-
return coerceValue(snapshotValue, fieldType)
|
|
413
|
-
}
|
|
414
424
|
const raw = value.isDefined() ? value.getValue() : undefined
|
|
415
425
|
if (raw === undefined || raw === null || raw === '') {
|
|
416
426
|
return undefined
|