@servicenow/sdk-build-plugins 4.4.0 → 4.5.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 (287) hide show
  1. package/dist/acl-plugin.js +54 -4
  2. package/dist/acl-plugin.js.map +1 -1
  3. package/dist/applicability-plugin.js +2 -0
  4. package/dist/applicability-plugin.js.map +1 -1
  5. package/dist/application-menu-plugin.js +2 -0
  6. package/dist/application-menu-plugin.js.map +1 -1
  7. package/dist/arrow-function-plugin.d.ts +6 -1
  8. package/dist/arrow-function-plugin.js +105 -12
  9. package/dist/arrow-function-plugin.js.map +1 -1
  10. package/dist/atf/test-plugin.js +2 -0
  11. package/dist/atf/test-plugin.js.map +1 -1
  12. package/dist/basic-syntax-plugin.js +20 -0
  13. package/dist/basic-syntax-plugin.js.map +1 -1
  14. package/dist/call-expression-plugin.js +1 -0
  15. package/dist/call-expression-plugin.js.map +1 -1
  16. package/dist/claims-plugin.js +1 -0
  17. package/dist/claims-plugin.js.map +1 -1
  18. package/dist/client-script-plugin.js +1 -0
  19. package/dist/client-script-plugin.js.map +1 -1
  20. package/dist/column-plugin.js +1 -0
  21. package/dist/column-plugin.js.map +1 -1
  22. package/dist/cross-scope-privilege-plugin.js +1 -0
  23. package/dist/cross-scope-privilege-plugin.js.map +1 -1
  24. package/dist/dashboard/dashboard-plugin.js +2 -0
  25. package/dist/dashboard/dashboard-plugin.js.map +1 -1
  26. package/dist/data-plugin.js +1 -0
  27. package/dist/data-plugin.js.map +1 -1
  28. package/dist/email-notification-plugin.js +9 -13
  29. package/dist/email-notification-plugin.js.map +1 -1
  30. package/dist/flow/constants/flow-plugin-constants.d.ts +1 -1
  31. package/dist/flow/constants/flow-plugin-constants.js +1 -1
  32. package/dist/flow/constants/flow-plugin-constants.js.map +1 -1
  33. package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +82 -2
  34. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +48 -40
  35. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -1
  36. package/dist/flow/flow-logic/flow-logic-plugin.js +1 -0
  37. package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -1
  38. package/dist/flow/plugins/approval-rules-plugin.js +1 -0
  39. package/dist/flow/plugins/approval-rules-plugin.js.map +1 -1
  40. package/dist/flow/plugins/flow-action-definition-plugin.js +4 -2
  41. package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -1
  42. package/dist/flow/plugins/flow-data-pill-plugin.js +1 -0
  43. package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -1
  44. package/dist/flow/plugins/flow-definition-plugin.js +8 -3
  45. package/dist/flow/plugins/flow-definition-plugin.js.map +1 -1
  46. package/dist/flow/plugins/flow-diagnostics-plugin.js +1 -0
  47. package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -1
  48. package/dist/flow/plugins/flow-instance-plugin.js +68 -12
  49. package/dist/flow/plugins/flow-instance-plugin.js.map +1 -1
  50. package/dist/flow/plugins/flow-trigger-instance-plugin.js +1 -0
  51. package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -1
  52. package/dist/flow/plugins/inline-script-plugin.js +1 -0
  53. package/dist/flow/plugins/inline-script-plugin.js.map +1 -1
  54. package/dist/flow/plugins/step-definition-plugin.js +3 -2
  55. package/dist/flow/plugins/step-definition-plugin.js.map +1 -1
  56. package/dist/flow/plugins/step-instance-plugin.js +1 -0
  57. package/dist/flow/plugins/step-instance-plugin.js.map +1 -1
  58. package/dist/flow/plugins/trigger-plugin.js +2 -0
  59. package/dist/flow/plugins/trigger-plugin.js.map +1 -1
  60. package/dist/flow/plugins/wfa-datapill-plugin.js +1 -0
  61. package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -1
  62. package/dist/flow/post-install.d.ts +2 -0
  63. package/dist/flow/post-install.js +58 -0
  64. package/dist/flow/post-install.js.map +1 -0
  65. package/dist/flow/utils/complex-objects.js +4 -2
  66. package/dist/flow/utils/complex-objects.js.map +1 -1
  67. package/dist/flow/utils/flow-constants.d.ts +24 -0
  68. package/dist/flow/utils/flow-constants.js +29 -2
  69. package/dist/flow/utils/flow-constants.js.map +1 -1
  70. package/dist/flow/utils/flow-to-xml.d.ts +3 -2
  71. package/dist/flow/utils/flow-to-xml.js +3 -4
  72. package/dist/flow/utils/flow-to-xml.js.map +1 -1
  73. package/dist/flow/utils/label-cache-processor.d.ts +5 -0
  74. package/dist/flow/utils/label-cache-processor.js +14 -2
  75. package/dist/flow/utils/label-cache-processor.js.map +1 -1
  76. package/dist/flow/utils/service-catalog.js +5 -1
  77. package/dist/flow/utils/service-catalog.js.map +1 -1
  78. package/dist/form-plugin.d.ts +2 -0
  79. package/dist/form-plugin.js +1134 -0
  80. package/dist/form-plugin.js.map +1 -0
  81. package/dist/html-import-plugin.js +1 -0
  82. package/dist/html-import-plugin.js.map +1 -1
  83. package/dist/import-sets-plugin.js +2 -0
  84. package/dist/import-sets-plugin.js.map +1 -1
  85. package/dist/index.d.ts +9 -0
  86. package/dist/index.js +13 -1
  87. package/dist/index.js.map +1 -1
  88. package/dist/instance-scan-plugin.d.ts +2 -0
  89. package/dist/instance-scan-plugin.js +298 -0
  90. package/dist/instance-scan-plugin.js.map +1 -0
  91. package/dist/json-plugin.js +1 -0
  92. package/dist/json-plugin.js.map +1 -1
  93. package/dist/list-plugin.js +1 -0
  94. package/dist/list-plugin.js.map +1 -1
  95. package/dist/now-attach-plugin.js +1 -0
  96. package/dist/now-attach-plugin.js.map +1 -1
  97. package/dist/now-config-plugin.js +659 -51
  98. package/dist/now-config-plugin.js.map +1 -1
  99. package/dist/now-id-plugin.js +1 -0
  100. package/dist/now-id-plugin.js.map +1 -1
  101. package/dist/now-include-plugin.js +1 -0
  102. package/dist/now-include-plugin.js.map +1 -1
  103. package/dist/now-ref-plugin.js +1 -0
  104. package/dist/now-ref-plugin.js.map +1 -1
  105. package/dist/now-unresolved-plugin.js +1 -0
  106. package/dist/now-unresolved-plugin.js.map +1 -1
  107. package/dist/package-json-plugin.js +1 -0
  108. package/dist/package-json-plugin.js.map +1 -1
  109. package/dist/property-plugin.js +3 -1
  110. package/dist/property-plugin.js.map +1 -1
  111. package/dist/record-plugin.d.ts +30 -0
  112. package/dist/record-plugin.js +37 -1
  113. package/dist/record-plugin.js.map +1 -1
  114. package/dist/repack/lint/Rules.d.ts +11 -2
  115. package/dist/repack/lint/Rules.js +160 -16
  116. package/dist/repack/lint/Rules.js.map +1 -1
  117. package/dist/repack/lint/index.d.ts +10 -5
  118. package/dist/repack/lint/index.js +76 -50
  119. package/dist/repack/lint/index.js.map +1 -1
  120. package/dist/rest-api-plugin.js +14 -0
  121. package/dist/rest-api-plugin.js.map +1 -1
  122. package/dist/role-plugin.js +1 -0
  123. package/dist/role-plugin.js.map +1 -1
  124. package/dist/schedule-script/index.d.ts +1 -0
  125. package/dist/schedule-script/index.js +18 -0
  126. package/dist/schedule-script/index.js.map +1 -0
  127. package/dist/schedule-script/scheduled-script-plugin.d.ts +2 -0
  128. package/dist/schedule-script/scheduled-script-plugin.js +551 -0
  129. package/dist/schedule-script/scheduled-script-plugin.js.map +1 -0
  130. package/dist/schedule-script/timeZoneConverter.d.ts +61 -0
  131. package/dist/schedule-script/timeZoneConverter.js +170 -0
  132. package/dist/schedule-script/timeZoneConverter.js.map +1 -0
  133. package/dist/script-action-plugin.js +2 -0
  134. package/dist/script-action-plugin.js.map +1 -1
  135. package/dist/script-include-plugin.js +2 -0
  136. package/dist/script-include-plugin.js.map +1 -1
  137. package/dist/server-module-plugin/index.js +13 -2
  138. package/dist/server-module-plugin/index.js.map +1 -1
  139. package/dist/service-catalog/catalog-clientscript-plugin.js +2 -0
  140. package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -1
  141. package/dist/service-catalog/catalog-item-plugin.js +2 -0
  142. package/dist/service-catalog/catalog-item-plugin.js.map +1 -1
  143. package/dist/service-catalog/catalog-ui-policy-plugin.js +2 -0
  144. package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -1
  145. package/dist/service-catalog/sc-record-producer-plugin.js +2 -0
  146. package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -1
  147. package/dist/service-catalog/service-catalog-diagnostics.d.ts +6 -0
  148. package/dist/service-catalog/service-catalog-diagnostics.js +20 -0
  149. package/dist/service-catalog/service-catalog-diagnostics.js.map +1 -1
  150. package/dist/service-catalog/shape-to-record.js +7 -2
  151. package/dist/service-catalog/shape-to-record.js.map +1 -1
  152. package/dist/service-catalog/variable-set-plugin.js +2 -0
  153. package/dist/service-catalog/variable-set-plugin.js.map +1 -1
  154. package/dist/service-portal/angular-provider-plugin.js +2 -0
  155. package/dist/service-portal/angular-provider-plugin.js.map +1 -1
  156. package/dist/service-portal/dependency-plugin.js +5 -31
  157. package/dist/service-portal/dependency-plugin.js.map +1 -1
  158. package/dist/service-portal/menu-plugin.d.ts +2 -0
  159. package/dist/service-portal/menu-plugin.js +353 -0
  160. package/dist/service-portal/menu-plugin.js.map +1 -0
  161. package/dist/service-portal/page-plugin.d.ts +2 -0
  162. package/dist/service-portal/page-plugin.js +702 -0
  163. package/dist/service-portal/page-plugin.js.map +1 -0
  164. package/dist/service-portal/portal-plugin.d.ts +2 -0
  165. package/dist/service-portal/portal-plugin.js +296 -0
  166. package/dist/service-portal/portal-plugin.js.map +1 -0
  167. package/dist/service-portal/theme-plugin.d.ts +2 -0
  168. package/dist/service-portal/theme-plugin.js +112 -0
  169. package/dist/service-portal/theme-plugin.js.map +1 -0
  170. package/dist/service-portal/utils.d.ts +8 -0
  171. package/dist/service-portal/utils.js +50 -0
  172. package/dist/service-portal/utils.js.map +1 -0
  173. package/dist/service-portal/widget-plugin.js +45 -8
  174. package/dist/service-portal/widget-plugin.js.map +1 -1
  175. package/dist/sla-plugin.js +2 -0
  176. package/dist/sla-plugin.js.map +1 -1
  177. package/dist/static-content-plugin.js +1 -0
  178. package/dist/static-content-plugin.js.map +1 -1
  179. package/dist/table-plugin.js +1 -0
  180. package/dist/table-plugin.js.map +1 -1
  181. package/dist/ui-action-plugin.js +2 -0
  182. package/dist/ui-action-plugin.js.map +1 -1
  183. package/dist/ui-page-plugin.js +33 -8
  184. package/dist/ui-page-plugin.js.map +1 -1
  185. package/dist/ui-policy-plugin.js +1 -0
  186. package/dist/ui-policy-plugin.js.map +1 -1
  187. package/dist/user-preference-plugin.js +2 -0
  188. package/dist/user-preference-plugin.js.map +1 -1
  189. package/dist/utils.d.ts +20 -2
  190. package/dist/utils.js +34 -3
  191. package/dist/utils.js.map +1 -1
  192. package/dist/ux-list-menu-config-plugin.js +2 -0
  193. package/dist/ux-list-menu-config-plugin.js.map +1 -1
  194. package/dist/view-plugin.js +1 -0
  195. package/dist/view-plugin.js.map +1 -1
  196. package/dist/workspace-plugin.js +2 -0
  197. package/dist/workspace-plugin.js.map +1 -1
  198. package/package.json +10 -11
  199. package/src/_types/eslint-community-eslint-utils.d.ts +15 -0
  200. package/src/acl-plugin.ts +97 -8
  201. package/src/applicability-plugin.ts +2 -0
  202. package/src/application-menu-plugin.ts +2 -0
  203. package/src/arrow-function-plugin.ts +128 -13
  204. package/src/atf/test-plugin.ts +2 -0
  205. package/src/basic-syntax-plugin.ts +21 -0
  206. package/src/call-expression-plugin.ts +1 -0
  207. package/src/claims-plugin.ts +1 -0
  208. package/src/client-script-plugin.ts +2 -1
  209. package/src/column-plugin.ts +1 -0
  210. package/src/cross-scope-privilege-plugin.ts +2 -1
  211. package/src/dashboard/dashboard-plugin.ts +2 -0
  212. package/src/data-plugin.ts +1 -0
  213. package/src/email-notification-plugin.ts +3 -23
  214. package/src/flow/constants/flow-plugin-constants.ts +1 -1
  215. package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +47 -45
  216. package/src/flow/flow-logic/flow-logic-plugin.ts +1 -0
  217. package/src/flow/plugins/approval-rules-plugin.ts +1 -0
  218. package/src/flow/plugins/flow-action-definition-plugin.ts +4 -2
  219. package/src/flow/plugins/flow-data-pill-plugin.ts +1 -0
  220. package/src/flow/plugins/flow-definition-plugin.ts +10 -4
  221. package/src/flow/plugins/flow-diagnostics-plugin.ts +1 -0
  222. package/src/flow/plugins/flow-instance-plugin.ts +103 -14
  223. package/src/flow/plugins/flow-trigger-instance-plugin.ts +1 -0
  224. package/src/flow/plugins/inline-script-plugin.ts +1 -0
  225. package/src/flow/plugins/step-definition-plugin.ts +3 -2
  226. package/src/flow/plugins/step-instance-plugin.ts +1 -0
  227. package/src/flow/plugins/trigger-plugin.ts +2 -0
  228. package/src/flow/plugins/wfa-datapill-plugin.ts +1 -0
  229. package/src/flow/post-install.ts +92 -0
  230. package/src/flow/utils/complex-objects.ts +10 -2
  231. package/src/flow/utils/flow-constants.ts +30 -1
  232. package/src/flow/utils/flow-to-xml.ts +4 -4
  233. package/src/flow/utils/label-cache-processor.ts +14 -2
  234. package/src/flow/utils/service-catalog.ts +5 -2
  235. package/src/form-plugin.ts +1411 -0
  236. package/src/html-import-plugin.ts +1 -0
  237. package/src/import-sets-plugin.ts +2 -0
  238. package/src/index.ts +9 -0
  239. package/src/instance-scan-plugin.ts +318 -0
  240. package/src/json-plugin.ts +1 -0
  241. package/src/list-plugin.ts +2 -1
  242. package/src/now-attach-plugin.ts +1 -0
  243. package/src/now-config-plugin.ts +833 -53
  244. package/src/now-id-plugin.ts +1 -0
  245. package/src/now-include-plugin.ts +1 -0
  246. package/src/now-ref-plugin.ts +1 -0
  247. package/src/now-unresolved-plugin.ts +1 -0
  248. package/src/package-json-plugin.ts +1 -0
  249. package/src/property-plugin.ts +3 -1
  250. package/src/record-plugin.ts +42 -2
  251. package/src/repack/lint/Rules.ts +171 -22
  252. package/src/repack/lint/index.ts +80 -56
  253. package/src/rest-api-plugin.ts +21 -1
  254. package/src/role-plugin.ts +2 -1
  255. package/src/schedule-script/index.ts +1 -0
  256. package/src/schedule-script/scheduled-script-plugin.ts +679 -0
  257. package/src/schedule-script/timeZoneConverter.ts +188 -0
  258. package/src/script-action-plugin.ts +2 -0
  259. package/src/script-include-plugin.ts +2 -0
  260. package/src/server-module-plugin/index.ts +14 -2
  261. package/src/service-catalog/catalog-clientscript-plugin.ts +2 -0
  262. package/src/service-catalog/catalog-item-plugin.ts +2 -0
  263. package/src/service-catalog/catalog-ui-policy-plugin.ts +2 -0
  264. package/src/service-catalog/sc-record-producer-plugin.ts +2 -0
  265. package/src/service-catalog/service-catalog-diagnostics.ts +30 -0
  266. package/src/service-catalog/shape-to-record.ts +8 -2
  267. package/src/service-catalog/variable-set-plugin.ts +2 -0
  268. package/src/service-portal/angular-provider-plugin.ts +2 -0
  269. package/src/service-portal/dependency-plugin.ts +6 -53
  270. package/src/service-portal/menu-plugin.ts +435 -0
  271. package/src/service-portal/page-plugin.ts +830 -0
  272. package/src/service-portal/portal-plugin.ts +319 -0
  273. package/src/service-portal/theme-plugin.ts +135 -0
  274. package/src/service-portal/utils.ts +69 -0
  275. package/src/service-portal/widget-plugin.ts +79 -9
  276. package/src/sla-plugin.ts +2 -0
  277. package/src/static-content-plugin.ts +1 -0
  278. package/src/table-plugin.ts +2 -1
  279. package/src/ui-action-plugin.ts +2 -0
  280. package/src/ui-page-plugin.ts +34 -8
  281. package/src/ui-policy-plugin.ts +2 -1
  282. package/src/user-preference-plugin.ts +2 -0
  283. package/src/utils.ts +42 -2
  284. package/src/ux-list-menu-config-plugin.ts +2 -0
  285. package/src/view-plugin.ts +1 -0
  286. package/src/workspace-plugin.ts +2 -0
  287. package/src/_types/eslint-plugin-es-x.d.ts +0 -17
@@ -19,6 +19,7 @@ import {
19
19
  } from '@servicenow/sdk-build-core'
20
20
  import { NowIdShape } from '../now-id-plugin'
21
21
  import { ArrowFunctionShape } from '../arrow-function-plugin'
22
+ import { createSdkDocEntry } from '../utils'
22
23
  import { create } from 'xmlbuilder2'
23
24
  import { Test } from '@servicenow/sdk-core/runtime/app'
24
25
  import {
@@ -33,6 +34,7 @@ import type { Duration } from '@servicenow/sdk/core'
33
34
 
34
35
  export const TestPlugin = Plugin.create({
35
36
  name: 'TestPlugin',
37
+ docs: [createSdkDocEntry('Test', ['sys_atf_test'])],
36
38
  records: {
37
39
  sys_atf_test: {
38
40
  relationships: {
@@ -30,9 +30,11 @@ import {
30
30
  } from '@servicenow/sdk-build-core'
31
31
  import { isDataHelper } from './data-plugin'
32
32
  import { getCallExpressionName } from './utils'
33
+ import { NowIncludePlugin, NowIncludeShape } from './now-include-plugin'
33
34
 
34
35
  export const BasicSyntaxPlugin = Plugin.create({
35
36
  name: 'BasicSyntaxPlugin',
37
+ docs: [],
36
38
  files: [
37
39
  {
38
40
  entryPoint: true,
@@ -309,6 +311,7 @@ export const BasicSyntaxPlugin = Plugin.create({
309
311
 
310
312
  const propsToRetain = new Set<string>(['$meta'])
311
313
  const propsToAdd: ts.PropertyAssignmentStructure[] = []
314
+ const nowIncludePropsToCommit = new Set<string>()
312
315
  for (const [name, value] of shape.entries({ resolve: false })) {
313
316
  const existingPropKey = [...shape.getAliases(name), name].find((aliasedKey) =>
314
317
  existingNames.has(aliasedKey)
@@ -324,6 +327,9 @@ export const BasicSyntaxPlugin = Plugin.create({
324
327
 
325
328
  await commit(value, existingNames.get(existingPropKey) as ts.Expression)
326
329
  } else if (!value.equals(shape.getDefault(name))) {
330
+ if (value.is(NowIncludeShape)) {
331
+ nowIncludePropsToCommit.add(name)
332
+ }
327
333
  propsToAdd.push({
328
334
  name: ObjectShape.quotePropertyNameIfNeeded(name),
329
335
  initializer: value.getCode(),
@@ -338,6 +344,15 @@ export const BasicSyntaxPlugin = Plugin.create({
338
344
  target.addPropertyAssignments(propsToAdd)
339
345
  }
340
346
 
347
+ // commit Now.include props to generate the include file.
348
+ for (const prop of nowIncludePropsToCommit) {
349
+ const includeInitializer = target
350
+ .getPropertyOrThrow(prop)
351
+ .asKindOrThrow(ts.SyntaxKind.PropertyAssignment)
352
+ .getInitializerOrThrow()
353
+ await commit(shape.get(prop, false), includeInitializer, NowIncludePlugin)
354
+ }
355
+
341
356
  const propsToRemove = [...existingNames.keys()].filter((key) => !propsToRetain.has(key))
342
357
  propsToRemove.forEach((prop) => {
343
358
  target.getProperty(prop)?.asKindOrThrow(ts.SyntaxKind.PropertyAssignment).remove()
@@ -544,6 +559,12 @@ export const BasicSyntaxPlugin = Plugin.create({
544
559
  return transform.toShape(node.getExpression())
545
560
  },
546
561
  },
562
+ {
563
+ node: 'ParenthesizedExpression',
564
+ toShape(node, { transform }) {
565
+ return transform.toShape(node.getExpression())
566
+ },
567
+ },
547
568
  {
548
569
  node: 'Identifier',
549
570
  async toShape(node, { transform }) {
@@ -3,6 +3,7 @@ import { getCallExpressionName } from './utils'
3
3
 
4
4
  export const CallExpressionPlugin = Plugin.create({
5
5
  name: 'CallExpressionPlugin',
6
+ docs: [],
6
7
  nodes: [
7
8
  {
8
9
  node: 'CallExpression',
@@ -8,6 +8,7 @@ function getClaimsPath(project: Project, config: NowConfig): string {
8
8
 
9
9
  export const ClaimsPlugin = Plugin.create({
10
10
  name: 'ClaimsPlugin',
11
+ docs: [],
11
12
  files: [
12
13
  {
13
14
  entryPoint: true,
@@ -1,6 +1,6 @@
1
1
  import { CallExpressionShape, Plugin } from '@servicenow/sdk-build-core'
2
2
  import { NowIdShape } from './now-id-plugin'
3
- import { generateDeprecatedDiagnostics, validateClientSideScript } from './utils'
3
+ import { createSdkDocEntry, generateDeprecatedDiagnostics, validateClientSideScript } from './utils'
4
4
  import { NowIncludeShape } from './now-include-plugin'
5
5
 
6
6
  enum UITypeMapping {
@@ -44,6 +44,7 @@ const clientScriptAliases = {
44
44
  */
45
45
  export const ClientScriptPlugin = Plugin.create({
46
46
  name: 'ClientScriptPlugin',
47
+ docs: [createSdkDocEntry('ClientScript', ['sys_script_client'])],
47
48
  records: {
48
49
  sys_script_client: {
49
50
  async toShape(record, { transform }) {
@@ -66,6 +66,7 @@ const documentationAliases = {
66
66
 
67
67
  export const ColumnPlugin = Plugin.create({
68
68
  name: 'ColumnPlugin',
69
+ docs: [],
69
70
  records: {
70
71
  sys_choice: {
71
72
  coalesce: ['name', 'element', 'value'],
@@ -1,6 +1,6 @@
1
1
  import { CallExpressionShape, Plugin } from '@servicenow/sdk-build-core'
2
2
  import { NowIdShape } from './now-id-plugin'
3
- import { generateDeprecatedDiagnostics } from './utils'
3
+ import { createSdkDocEntry, generateDeprecatedDiagnostics } from './utils'
4
4
 
5
5
  const crossScopeAliases = {
6
6
  targetName: ['target_name'],
@@ -23,6 +23,7 @@ const crossScopeAliases = {
23
23
  */
24
24
  export const CrossScopePrivilegePlugin = Plugin.create({
25
25
  name: 'CrossScopePrivilegePlugin',
26
+ docs: [createSdkDocEntry('CrossScopePrivilege', ['sys_scope_privilege'])],
26
27
  records: {
27
28
  sys_scope_privilege: {
28
29
  relationships: {
@@ -1,6 +1,7 @@
1
1
  import { CallExpressionShape, type ObjectShape, Plugin, type Record as RecordType } from '@servicenow/sdk-build-core'
2
2
  import { NowIdShape } from '../now-id-plugin'
3
3
  import { resolveComponentToSysId, resolveComponentToName } from './dashboard-component-resolver'
4
+ import { createSdkDocEntry } from '../utils'
4
5
  import { DEFAULT_PROPERTY_VALUES, removeRestrictedValues } from './dashboard-component-property-defaults'
5
6
 
6
7
  const transformWidget = (widget: RecordType) =>
@@ -55,6 +56,7 @@ const createWidgetProperties = (widgetData: ObjectShape, canvas: ObjectShape) =>
55
56
  */
56
57
  export const DashboardPlugin = Plugin.create({
57
58
  name: 'DashboardPlugin',
59
+ docs: [createSdkDocEntry('Dashboard', ['par_dashboard'])],
58
60
  records: {
59
61
  par_dashboard: {
60
62
  relationships: {
@@ -41,6 +41,7 @@ const shapeCreators: Record<
41
41
 
42
42
  export const DataPlugin = Plugin.create({
43
43
  name: 'DataPlugin',
44
+ docs: [],
44
45
  shapes: [
45
46
  {
46
47
  shape: CallExpressionShape,
@@ -1,12 +1,6 @@
1
- import {
2
- CallExpressionShape,
3
- Plugin,
4
- isGUID,
5
- Shape,
6
- type ObjectShape,
7
- type Diagnostics,
8
- } from '@servicenow/sdk-build-core'
1
+ import { CallExpressionShape, Plugin, isGUID, Shape, type ObjectShape } from '@servicenow/sdk-build-core'
9
2
  import { NowIdShape } from './now-id-plugin'
3
+ import { showGuidFieldDiagnostic, createSdkDocEntry } from './utils'
10
4
  import type { EmailNotification } from '@servicenow/sdk-core/runtime/notification'
11
5
 
12
6
  // Use index access types instead of exported utility types
@@ -59,23 +53,9 @@ const isValidEmail = (email: string): boolean => {
59
53
  return emailRegex.test(email)
60
54
  }
61
55
 
62
- const showGuidFieldDiagnostic = (
63
- inputReceived: Shape | undefined,
64
- fieldName: string,
65
- tableName: string,
66
- diagnostics: Diagnostics
67
- ) => {
68
- if (inputReceived) {
69
- const receivedValue = inputReceived.getValue()
70
- diagnostics.error(
71
- inputReceived,
72
- `'${fieldName}' must be a valid GUID or a Record<'${tableName}'>. Received: '${receivedValue}'`
73
- )
74
- }
75
- }
76
-
77
56
  export const EmailNotificationPlugin = Plugin.create({
78
57
  name: 'EmailNotificationPlugin',
58
+ docs: [createSdkDocEntry('EmailNotification', ['sysevent_email_action'])],
79
59
  records: {
80
60
  sysevent_email_action: {
81
61
  toShape(record) {
@@ -15,7 +15,7 @@ export const FLOW_PRIORITY_DEFAULT = 'MEDIUM'
15
15
  /**
16
16
  * Default user context for flow execution
17
17
  */
18
- export const RUN_AS_DEFAULT = 'system'
18
+ export const RUN_AS_DEFAULT = 'user'
19
19
 
20
20
  /**
21
21
  * Default access level for flows
@@ -130,7 +130,7 @@ type FlowLogicParseResult =
130
130
  * FlowLogicValueInput objects with name/value pairs that represent the
131
131
  * original TypeScript configuration properties.
132
132
  */
133
- namespace FlowLogicValueProcessor {
133
+ export namespace FlowLogicValueProcessor {
134
134
  /**
135
135
  * Generic factory function for creating flow logic entry objects.
136
136
  * All entry types (AssignSubflowOutput, SetFlowVariablesInput, FlowLogicValueInput)
@@ -766,8 +766,6 @@ namespace FlowLogicValueProcessor {
766
766
  // Constants for type handling
767
767
  const ARRAY_TYPE_PREFIX = 'array.' as const
768
768
  const ARRAY_TYPE_PREFIX_LENGTH = ARRAY_TYPE_PREFIX.length
769
- const EXCLUDED_TYPE_ANNOTATIONS = new Set(['string', 'glide_date_time'])
770
-
771
769
  /**
772
770
  * Interface for child entry structure used in parsing
773
771
  */
@@ -829,50 +827,29 @@ namespace FlowLogicValueProcessor {
829
827
  return value
830
828
  }
831
829
 
832
- /**
833
- * Adds type annotation to a datapill if needed based on label cache
834
- * @param pillName - Datapill name without braces
835
- * @param labelCacheMap - Map of datapill names to types
836
- * @returns Datapill with annotation if applicable
837
- */
838
- function addTypeAnnotationIfNeeded(pillName: string, labelCacheMap?: Map<string, string>): string {
839
- if (!labelCacheMap) {
840
- return `{{${pillName}}}`
841
- }
842
-
843
- const cachedType = labelCacheMap.get(pillName.trim())
844
- if (cachedType && !EXCLUDED_TYPE_ANNOTATIONS.has(cachedType)) {
845
- return `{{${pillName}|${cachedType}}}`
846
- }
847
-
848
- return `{{${pillName}}}`
849
- }
850
-
851
830
  /**
852
831
  * Processes a pure datapill value (starts and ends with {{}})
832
+ * Strips any existing |type annotation and returns a clean datapill.
833
+ * Type info is preserved via labelCacheMap in wrapWithWfaDataPillExpression downstream.
853
834
  * @param value - Pure datapill string
854
- * @param labelCacheMap - Map of datapill names to types
855
- * @returns Processed datapill with type annotation if needed
835
+ * @param _labelCacheMap - Unused (type resolution handled downstream by transformDataPill)
836
+ * @returns Clean datapill without type annotation
856
837
  */
857
- function processPureDatapill(value: string, labelCacheMap?: Map<string, string>): string {
858
- const strippedValue = stripDatapillTypeAnnotation(value)
859
- const pillName = strippedValue.slice(2, -2) // Remove {{ and }}
860
- return addTypeAnnotationIfNeeded(pillName, labelCacheMap)
838
+ function processPureDatapill(value: string, _labelCacheMap?: Map<string, string>): string {
839
+ return stripDatapillTypeAnnotation(value)
861
840
  }
862
841
 
863
842
  /**
864
- * Processes a template expression containing datapills mixed with text
843
+ * Processes a template expression containing datapills mixed with text.
844
+ * Strips any existing |type annotations and returns clean datapills.
845
+ * Type info is preserved via labelCacheMap in wrapWithWfaDataPillExpression downstream.
865
846
  * @param value - Template expression string
866
- * @param labelCacheMap - Map of datapill names to types
867
- * @returns Processed template with type annotations added to datapills
847
+ * @param _labelCacheMap - Unused (type resolution handled downstream by transformDataPill)
848
+ * @returns Processed template with type annotations stripped from datapills
868
849
  */
869
- function processTemplateExpression(value: string, labelCacheMap?: Map<string, string>): string {
870
- if (!labelCacheMap) {
871
- return value
872
- }
873
-
874
- const datapillRegex = /\{\{([^}|]+)(?:\|[^}]+)?\}\}/g
875
- return value.replace(datapillRegex, (_match, pillName) => addTypeAnnotationIfNeeded(pillName, labelCacheMap))
850
+ function processTemplateExpression(value: string, _labelCacheMap?: Map<string, string>): string {
851
+ const datapillRegex = /\{\{([^}|]+)\|[^}]+\}\}/g
852
+ return value.replace(datapillRegex, '{{$1}}')
876
853
  }
877
854
 
878
855
  /**
@@ -972,12 +949,26 @@ namespace FlowLogicValueProcessor {
972
949
  if (parsed.complexObjectSchema) {
973
950
  // Find the $COCollectionField.$type_facets
974
951
  for (const schemaKey in parsed.complexObjectSchema) {
952
+ // Skip top-level $type_facets entries (handled as fallback below)
953
+ if (schemaKey.endsWith('.$type_facets')) {
954
+ continue
955
+ }
975
956
  const schema = parsed.complexObjectSchema[schemaKey]
976
- if (schema && schema.$COCollectionField && schema['$COCollectionField.$type_facets']) {
977
- const typeFacets = schema['$COCollectionField.$type_facets']
978
- if (typeFacets.SimpleMapFacet) {
979
- const facetData = JSON.parse(typeFacets.SimpleMapFacet)
980
- return facetData.child_type
957
+ if (schema && schema.$COCollectionField) {
958
+ // Array.Object format: child_type nested as $COCollectionField.$type_facets
959
+ if (schema['$COCollectionField.$type_facets']?.SimpleMapFacet) {
960
+ const facetData = JSON.parse(schema['$COCollectionField.$type_facets'].SimpleMapFacet)
961
+ if (facetData.child_type) {
962
+ return facetData.child_type
963
+ }
964
+ }
965
+ // DEF0798866: Array.String format: child_type stored in top-level key "schemaKey.$type_facets"
966
+ const topLevelTypeFacets = parsed.complexObjectSchema[`${schemaKey}.$type_facets`]
967
+ if (topLevelTypeFacets?.SimpleMapFacet) {
968
+ const facetData = JSON.parse(topLevelTypeFacets.SimpleMapFacet)
969
+ if (facetData.child_type) {
970
+ return facetData.child_type
971
+ }
981
972
  }
982
973
  }
983
974
  }
@@ -1081,8 +1072,15 @@ namespace FlowLogicValueProcessor {
1081
1072
  const firstBaseName = getBaseName(childObj.name)
1082
1073
 
1083
1074
  // Check if all children have the same base name (indicating FlowArray with repeated childName)
1075
+ // When elementType is defined (i.e., the schema identifies this as a FlowArray — Array.Object,
1076
+ // Array.String, Array.Integer, Array.DateTime, etc.), a single child is still a valid array
1077
+ // element: the child is the childName wrapper whose inner value/children are the actual element.
1078
+ // Without this, single-element FlowArray assignments fall into the object path, generating
1079
+ // { childName: { fields } } or { childName: value } instead of [{ fields }] or [value].
1080
+ // DEF0798866: single-element Array.Object/String subflow outputs generated incorrect Fluent code.
1081
+ const minChildrenForArray = elementType !== undefined ? 1 : 2
1084
1082
  const allSameName =
1085
- children.length > 1 &&
1083
+ children.length >= minChildrenForArray &&
1086
1084
  children.every((c) => {
1087
1085
  const entry = c as ChildEntry
1088
1086
  return getBaseName(entry.name) === firstBaseName
@@ -1525,7 +1523,11 @@ namespace FlowLogicValueProcessor {
1525
1523
  // Ignore parse errors
1526
1524
  }
1527
1525
  }
1528
- const elementType = getArrayElementType(entry)
1526
+ // DEF0798866: Use typeMap as fallback when schema-based detection fails.
1527
+ // If entry.value doesn't contain complexObjectSchema (e.g., some ServiceNow XML
1528
+ // formats omit the schema), fall back to the typeMap which always contains the
1529
+ // output/variable type (e.g., 'array.string' -> 'string' element type).
1530
+ const elementType = getArrayElementType(entry) ?? extractArrayElementType(typeMap?.get(entry.name))
1529
1531
  const nestedTypeMap = extractNestedTypeSchema(entry)
1530
1532
  const parsedValue = parseChildrenArray(
1531
1533
  entry.children,
@@ -72,6 +72,7 @@ import type { ArrowFunctionShape } from '../../arrow-function-plugin'
72
72
  */
73
73
  export const FlowLogicPlugin = Plugin.create({
74
74
  name: 'FlowLogicPlugin',
75
+ docs: [],
75
76
  records: {
76
77
  sys_hub_flow_logic_instance_v2: {
77
78
  relationships: {
@@ -5,6 +5,7 @@ import { getCallExpressionName } from '../../utils'
5
5
 
6
6
  export const ApprovalRulesPlugin = Plugin.create({
7
7
  name: 'ApprovalRulesPlugin',
8
+ docs: [],
8
9
  nodes: [
9
10
  {
10
11
  node: 'CallExpression',
@@ -3,6 +3,7 @@ import { buildVariableRecords, complexObjectMatchesIoRecord } from '../utils/flo
3
3
  import { generateXML } from '../utils/flow-to-xml'
4
4
  import { slugifyString } from '../utils/flow-constants'
5
5
  import { ArrowFunctionShape } from '../../arrow-function-plugin'
6
+ import { createSdkDocEntry } from '../../utils'
6
7
  import { StepInstanceShape } from './step-instance-plugin'
7
8
 
8
9
  const actionDefRelationships = {
@@ -108,6 +109,7 @@ const actionDefRelationships = {
108
109
 
109
110
  export const ActionDefinitionPlugin = Plugin.create({
110
111
  name: 'ActionDefinitionPlugin',
112
+ docs: [createSdkDocEntry('ActionDefinition', ['sys_hub_action_type_definition'])],
111
113
  records: {
112
114
  sys_hub_action_type_definition: {
113
115
  relationships: {
@@ -193,8 +195,8 @@ export const ActionDefinitionPlugin = Plugin.create({
193
195
  async diff(existing, incoming, descendants, context) {
194
196
  return deleteMultipleDiff(existing, incoming, descendants, context)
195
197
  },
196
- toFile(record, { config, database }) {
197
- return generateXML(record, { config, database })
198
+ toFile(record, { config, database, self }) {
199
+ return generateXML(record, { config, database, plugin: self })
198
200
  },
199
201
  },
200
202
  sys_hub_action_input: {
@@ -156,6 +156,7 @@ function getForEachParameterName(identifierShape: IdentifierShape): string | nul
156
156
 
157
157
  export const DataPillPlugin = Plugin.create({
158
158
  name: 'DataPillPlugin',
159
+ docs: [],
159
160
  shapes: [
160
161
  {
161
162
  shape: PropertyAccessShape,
@@ -38,7 +38,7 @@ import {
38
38
  uuidToSysId,
39
39
  validateFlowVariableCall,
40
40
  } from '../utils/utils'
41
- import { getCallExpressionName } from '../../utils'
41
+ import { createSdkDocEntry, getCallExpressionName } from '../../utils'
42
42
  import {
43
43
  extractLabelCache,
44
44
  createDefinitionMap,
@@ -610,9 +610,14 @@ function extractAllPills(
610
610
  const matchStart = match.index ?? 0
611
611
  const matchEnd = matchStart + fullMatch.length
612
612
 
613
+ // Strip type annotation if present (e.g., "uuid.field|integer" -> "uuid.field").
614
+ // ServiceNow stores datapills with type annotations like {{pill.path|datatype}}.
615
+ const pipeIndex = content.indexOf('|')
616
+ const cleanContent = pipeIndex !== -1 ? content.substring(0, pipeIndex) : content
617
+
613
618
  // Try UUID pattern first (more specific)
614
619
  // UUID format: 8-4-4-4-12 hex digits followed by dot and property path
615
- const uuidMatch = content.match(
620
+ const uuidMatch = cleanContent.match(
616
621
  /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.([a-zA-Z_][a-zA-Z0-9_.]*[a-zA-Z0-9_])$/
617
622
  )
618
623
 
@@ -1619,6 +1624,7 @@ function postProcessAssignSubflowOutputs(
1619
1624
 
1620
1625
  export const FlowDefinitionPlugin = Plugin.create({
1621
1626
  name: 'FlowDefinitionPlugin',
1627
+ docs: [createSdkDocEntry('Flow', ['sys_hub_flow'])],
1622
1628
  records: {
1623
1629
  sys_hub_flow: {
1624
1630
  relationships: {
@@ -1680,8 +1686,8 @@ export const FlowDefinitionPlugin = Plugin.create({
1680
1686
  getUpdateName(record) {
1681
1687
  return { success: true, value: `${record.getTable()}_${record.getId().getValue()}` }
1682
1688
  },
1683
- toFile(record, { config, database }) {
1684
- return generateXML(record, { config, database })
1689
+ toFile(record, { config, database, self }) {
1690
+ return generateXML(record, { config, database, plugin: self })
1685
1691
  },
1686
1692
  async diff(existing, incoming, descendants, context) {
1687
1693
  return deleteMultipleDiff(existing, incoming, descendants, context)
@@ -95,6 +95,7 @@ function isInsideFlowContext(node: ts.Node): boolean {
95
95
  */
96
96
  export const FlowDiagnosticsPlugin = Plugin.create({
97
97
  name: 'FlowDiagnosticsPlugin',
98
+ docs: [],
98
99
  shapes: [
99
100
  {
100
101
  shape: CallExpressionShape,