@servicenow/sdk-build-plugins 3.0.3 → 4.0.1

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 (359) hide show
  1. package/dist/acl-plugin.d.ts +19 -0
  2. package/dist/acl-plugin.js +210 -0
  3. package/dist/acl-plugin.js.map +1 -0
  4. package/dist/application-menu-plugin.d.ts +18 -0
  5. package/dist/application-menu-plugin.js +104 -0
  6. package/dist/application-menu-plugin.js.map +1 -0
  7. package/dist/arrow-function-plugin.d.ts +16 -0
  8. package/dist/arrow-function-plugin.js +107 -0
  9. package/dist/arrow-function-plugin.js.map +1 -0
  10. package/dist/atf/step-configs.d.ts +39 -0
  11. package/dist/atf/step-configs.js +2334 -0
  12. package/dist/atf/step-configs.js.map +1 -0
  13. package/dist/atf/test-plugin.d.ts +4 -0
  14. package/dist/atf/test-plugin.js +600 -0
  15. package/dist/atf/test-plugin.js.map +1 -0
  16. package/dist/basic-syntax-plugin.d.ts +2 -0
  17. package/dist/basic-syntax-plugin.js +636 -0
  18. package/dist/basic-syntax-plugin.js.map +1 -0
  19. package/dist/business-rule-plugin.d.ts +3 -0
  20. package/dist/business-rule-plugin.js +205 -0
  21. package/dist/business-rule-plugin.js.map +1 -0
  22. package/dist/call-expression-plugin.d.ts +2 -0
  23. package/dist/call-expression-plugin.js +175 -0
  24. package/dist/call-expression-plugin.js.map +1 -0
  25. package/dist/client-script-plugin.d.ts +29 -0
  26. package/dist/client-script-plugin.js +164 -0
  27. package/dist/client-script-plugin.js.map +1 -0
  28. package/dist/column/column-helper.d.ts +12 -0
  29. package/dist/column/column-helper.js +84 -0
  30. package/dist/column/column-helper.js.map +1 -0
  31. package/dist/column/column-to-record.d.ts +3 -0
  32. package/dist/column/column-to-record.js +105 -0
  33. package/dist/column/column-to-record.js.map +1 -0
  34. package/dist/column-plugin.d.ts +8 -0
  35. package/dist/column-plugin.js +453 -0
  36. package/dist/column-plugin.js.map +1 -0
  37. package/dist/cross-scope-privilege-plugin.d.ts +15 -0
  38. package/dist/cross-scope-privilege-plugin.js +82 -0
  39. package/dist/cross-scope-privilege-plugin.js.map +1 -0
  40. package/dist/html-import-plugin.d.ts +2 -0
  41. package/dist/html-import-plugin.js +72 -0
  42. package/dist/html-import-plugin.js.map +1 -0
  43. package/dist/index.d.ts +37 -21
  44. package/dist/index.js +40 -45
  45. package/dist/index.js.map +1 -1
  46. package/dist/json-plugin.d.ts +15 -0
  47. package/dist/json-plugin.js +104 -0
  48. package/dist/json-plugin.js.map +1 -0
  49. package/dist/list-plugin.d.ts +2 -0
  50. package/dist/list-plugin.js +191 -0
  51. package/dist/list-plugin.js.map +1 -0
  52. package/dist/now-config-plugin.d.ts +4 -0
  53. package/dist/now-config-plugin.js +154 -0
  54. package/dist/now-config-plugin.js.map +1 -0
  55. package/dist/now-id-plugin.d.ts +11 -0
  56. package/dist/now-id-plugin.js +71 -0
  57. package/dist/now-id-plugin.js.map +1 -0
  58. package/dist/now-include-plugin.d.ts +16 -0
  59. package/dist/now-include-plugin.js +118 -0
  60. package/dist/now-include-plugin.js.map +1 -0
  61. package/dist/now-ref-plugin.d.ts +2 -0
  62. package/dist/now-ref-plugin.js +43 -0
  63. package/dist/now-ref-plugin.js.map +1 -0
  64. package/dist/now-unresolved-plugin.d.ts +2 -0
  65. package/dist/now-unresolved-plugin.js +32 -0
  66. package/dist/now-unresolved-plugin.js.map +1 -0
  67. package/dist/package-json-plugin.d.ts +2 -0
  68. package/dist/package-json-plugin.js +70 -0
  69. package/dist/package-json-plugin.js.map +1 -0
  70. package/dist/property-plugin.d.ts +2 -0
  71. package/dist/property-plugin.js +105 -0
  72. package/dist/property-plugin.js.map +1 -0
  73. package/dist/record-plugin.d.ts +43 -0
  74. package/dist/record-plugin.js +147 -0
  75. package/dist/record-plugin.js.map +1 -0
  76. package/dist/repack/index.d.ts +1 -0
  77. package/dist/repack/index.js +10 -2
  78. package/dist/repack/index.js.map +1 -1
  79. package/dist/repack/lint/Rules.d.ts +1 -1
  80. package/dist/repack/lint/Rules.js +7 -3
  81. package/dist/repack/lint/Rules.js.map +1 -1
  82. package/dist/repack/lint/index.js +1 -1
  83. package/dist/rest-api-plugin.d.ts +2 -0
  84. package/dist/rest-api-plugin.js +469 -0
  85. package/dist/rest-api-plugin.js.map +1 -0
  86. package/dist/role-plugin.d.ts +2 -0
  87. package/dist/role-plugin.js +117 -0
  88. package/dist/role-plugin.js.map +1 -0
  89. package/dist/script-action-plugin.d.ts +2 -0
  90. package/dist/script-action-plugin.js +62 -0
  91. package/dist/script-action-plugin.js.map +1 -0
  92. package/dist/script-include-plugin.d.ts +2 -0
  93. package/dist/script-include-plugin.js +102 -0
  94. package/dist/script-include-plugin.js.map +1 -0
  95. package/dist/server-module-plugin/index.d.ts +14 -0
  96. package/dist/server-module-plugin/index.js +378 -0
  97. package/dist/server-module-plugin/index.js.map +1 -0
  98. package/dist/server-module-plugin/sbom-builder.d.ts +45 -0
  99. package/dist/server-module-plugin/sbom-builder.js +179 -0
  100. package/dist/server-module-plugin/sbom-builder.js.map +1 -0
  101. package/dist/service-portal/angular-provider-plugin.d.ts +2 -0
  102. package/dist/service-portal/angular-provider-plugin.js +78 -0
  103. package/dist/service-portal/angular-provider-plugin.js.map +1 -0
  104. package/dist/service-portal/dependency-plugin.d.ts +2 -0
  105. package/dist/service-portal/dependency-plugin.js +235 -0
  106. package/dist/service-portal/dependency-plugin.js.map +1 -0
  107. package/dist/service-portal/widget-plugin.d.ts +6 -0
  108. package/dist/service-portal/widget-plugin.js +230 -0
  109. package/dist/service-portal/widget-plugin.js.map +1 -0
  110. package/dist/static-content-plugin.d.ts +2 -0
  111. package/dist/static-content-plugin.js +272 -0
  112. package/dist/static-content-plugin.js.map +1 -0
  113. package/dist/table-plugin.d.ts +3 -0
  114. package/dist/table-plugin.js +1324 -0
  115. package/dist/table-plugin.js.map +1 -0
  116. package/dist/ui-action-plugin.d.ts +2 -0
  117. package/dist/ui-action-plugin.js +291 -0
  118. package/dist/ui-action-plugin.js.map +1 -0
  119. package/dist/ui-page-plugin.d.ts +2 -0
  120. package/dist/ui-page-plugin.js +165 -0
  121. package/dist/ui-page-plugin.js.map +1 -0
  122. package/dist/user-preference-plugin.d.ts +15 -0
  123. package/dist/user-preference-plugin.js +63 -0
  124. package/dist/user-preference-plugin.js.map +1 -0
  125. package/dist/utils.d.ts +17 -0
  126. package/dist/utils.js +72 -0
  127. package/dist/utils.js.map +1 -0
  128. package/dist/view-plugin.d.ts +2 -0
  129. package/dist/view-plugin.js +45 -0
  130. package/dist/view-plugin.js.map +1 -0
  131. package/package.json +17 -13
  132. package/src/acl-plugin.ts +256 -0
  133. package/src/application-menu-plugin.ts +109 -0
  134. package/src/arrow-function-plugin.ts +127 -0
  135. package/src/atf/step-configs.ts +2384 -0
  136. package/src/atf/test-plugin.ts +739 -0
  137. package/src/basic-syntax-plugin.ts +729 -0
  138. package/src/business-rule-plugin.ts +266 -0
  139. package/src/call-expression-plugin.ts +202 -0
  140. package/src/client-script-plugin.ts +179 -0
  141. package/src/column/column-helper.ts +119 -0
  142. package/src/column/column-to-record.ts +131 -0
  143. package/src/column-plugin.ts +506 -0
  144. package/src/cross-scope-privilege-plugin.ts +82 -0
  145. package/src/html-import-plugin.ts +79 -0
  146. package/src/index.ts +39 -21
  147. package/src/json-plugin.ts +128 -0
  148. package/src/list-plugin.ts +222 -0
  149. package/src/now-config-plugin.ts +194 -0
  150. package/src/now-id-plugin.ts +78 -0
  151. package/src/now-include-plugin.ts +140 -0
  152. package/src/now-ref-plugin.ts +48 -0
  153. package/src/now-unresolved-plugin.ts +30 -0
  154. package/src/package-json-plugin.ts +87 -0
  155. package/src/property-plugin.ts +118 -0
  156. package/src/record-plugin.ts +171 -0
  157. package/src/repack/index.ts +10 -1
  158. package/src/repack/lint/Rules.ts +5 -4
  159. package/src/repack/lint/index.ts +1 -1
  160. package/src/rest-api-plugin.ts +658 -0
  161. package/src/role-plugin.ts +128 -0
  162. package/src/script-action-plugin.ts +63 -0
  163. package/src/script-include-plugin.ts +110 -0
  164. package/src/server-module-plugin/index.ts +470 -0
  165. package/src/server-module-plugin/sbom-builder.ts +183 -0
  166. package/src/service-portal/angular-provider-plugin.ts +83 -0
  167. package/src/service-portal/dependency-plugin.ts +284 -0
  168. package/src/service-portal/widget-plugin.ts +263 -0
  169. package/src/static-content-plugin.ts +254 -0
  170. package/src/table-plugin.ts +1698 -0
  171. package/src/ui-action-plugin.ts +324 -0
  172. package/src/ui-page-plugin.ts +168 -0
  173. package/src/user-preference-plugin.ts +62 -0
  174. package/src/utils.ts +69 -0
  175. package/src/view-plugin.ts +46 -0
  176. package/dist/AttachmentPlugin.d.ts +0 -254
  177. package/dist/AttachmentPlugin.js +0 -220
  178. package/dist/AttachmentPlugin.js.map +0 -1
  179. package/dist/BusinessRulePlugin.d.ts +0 -30
  180. package/dist/BusinessRulePlugin.js +0 -149
  181. package/dist/BusinessRulePlugin.js.map +0 -1
  182. package/dist/CrossScopePrivilegePlugin.d.ts +0 -35
  183. package/dist/CrossScopePrivilegePlugin.js +0 -80
  184. package/dist/CrossScopePrivilegePlugin.js.map +0 -1
  185. package/dist/DefaultPlugin.d.ts +0 -86
  186. package/dist/DefaultPlugin.js +0 -226
  187. package/dist/DefaultPlugin.js.map +0 -1
  188. package/dist/HtmlTemplatePlugin.d.ts +0 -21
  189. package/dist/HtmlTemplatePlugin.js +0 -29
  190. package/dist/HtmlTemplatePlugin.js.map +0 -1
  191. package/dist/IdPlugin.d.ts +0 -28
  192. package/dist/IdPlugin.js +0 -68
  193. package/dist/IdPlugin.js.map +0 -1
  194. package/dist/IncludePlugin.d.ts +0 -34
  195. package/dist/IncludePlugin.js +0 -155
  196. package/dist/IncludePlugin.js.map +0 -1
  197. package/dist/JsonPlugin.d.ts +0 -28
  198. package/dist/JsonPlugin.js +0 -69
  199. package/dist/JsonPlugin.js.map +0 -1
  200. package/dist/ListPlugin.d.ts +0 -93
  201. package/dist/ListPlugin.js +0 -456
  202. package/dist/ListPlugin.js.map +0 -1
  203. package/dist/NowConfigPlugin.d.ts +0 -45
  204. package/dist/NowConfigPlugin.js +0 -64
  205. package/dist/NowConfigPlugin.js.map +0 -1
  206. package/dist/PackageJsonPlugin.d.ts +0 -34
  207. package/dist/PackageJsonPlugin.js +0 -63
  208. package/dist/PackageJsonPlugin.js.map +0 -1
  209. package/dist/PropertyPlugin.d.ts +0 -51
  210. package/dist/PropertyPlugin.js +0 -181
  211. package/dist/PropertyPlugin.js.map +0 -1
  212. package/dist/ScriptTemplatePlugin.d.ts +0 -13
  213. package/dist/ScriptTemplatePlugin.js +0 -55
  214. package/dist/ScriptTemplatePlugin.js.map +0 -1
  215. package/dist/ServerModulePlugin.d.ts +0 -75
  216. package/dist/ServerModulePlugin.js +0 -368
  217. package/dist/ServerModulePlugin.js.map +0 -1
  218. package/dist/UserPreferencePlugin.d.ts +0 -19
  219. package/dist/UserPreferencePlugin.js +0 -32
  220. package/dist/UserPreferencePlugin.js.map +0 -1
  221. package/dist/aclAndRole/AclPlugin.d.ts +0 -82
  222. package/dist/aclAndRole/AclPlugin.js +0 -262
  223. package/dist/aclAndRole/AclPlugin.js.map +0 -1
  224. package/dist/aclAndRole/RolePlugin.d.ts +0 -66
  225. package/dist/aclAndRole/RolePlugin.js +0 -179
  226. package/dist/aclAndRole/RolePlugin.js.map +0 -1
  227. package/dist/aclAndRole/Util.d.ts +0 -3
  228. package/dist/aclAndRole/Util.js +0 -90
  229. package/dist/aclAndRole/Util.js.map +0 -1
  230. package/dist/app/ApplicationMenuPlugin.d.ts +0 -34
  231. package/dist/app/ApplicationMenuPlugin.js +0 -112
  232. package/dist/app/ApplicationMenuPlugin.js.map +0 -1
  233. package/dist/db/ColumnPlugins.d.ts +0 -750
  234. package/dist/db/ColumnPlugins.js +0 -114
  235. package/dist/db/ColumnPlugins.js.map +0 -1
  236. package/dist/db/DBUtils.d.ts +0 -2
  237. package/dist/db/DBUtils.js +0 -27
  238. package/dist/db/DBUtils.js.map +0 -1
  239. package/dist/db/DocumentationPlugin.d.ts +0 -67
  240. package/dist/db/DocumentationPlugin.js +0 -258
  241. package/dist/db/DocumentationPlugin.js.map +0 -1
  242. package/dist/db/LicensingPlugin.d.ts +0 -60
  243. package/dist/db/LicensingPlugin.js +0 -117
  244. package/dist/db/LicensingPlugin.js.map +0 -1
  245. package/dist/db/RecordPlugin.d.ts +0 -133
  246. package/dist/db/RecordPlugin.js +0 -337
  247. package/dist/db/RecordPlugin.js.map +0 -1
  248. package/dist/db/TablePlugin.d.ts +0 -231
  249. package/dist/db/TablePlugin.js +0 -1630
  250. package/dist/db/TablePlugin.js.map +0 -1
  251. package/dist/db/index.d.ts +0 -6
  252. package/dist/db/index.js +0 -32
  253. package/dist/db/index.js.map +0 -1
  254. package/dist/scriptedRESTAPI/RESTDeserializationUtils.d.ts +0 -10
  255. package/dist/scriptedRESTAPI/RESTDeserializationUtils.js +0 -373
  256. package/dist/scriptedRESTAPI/RESTDeserializationUtils.js.map +0 -1
  257. package/dist/scriptedRESTAPI/RESTSerializationUtils.d.ts +0 -13
  258. package/dist/scriptedRESTAPI/RESTSerializationUtils.js +0 -177
  259. package/dist/scriptedRESTAPI/RESTSerializationUtils.js.map +0 -1
  260. package/dist/scriptedRESTAPI/RestApiPlugin.d.ts +0 -81
  261. package/dist/scriptedRESTAPI/RestApiPlugin.js +0 -345
  262. package/dist/scriptedRESTAPI/RestApiPlugin.js.map +0 -1
  263. package/dist/scriptedRESTAPI/RestSchemaUtils.d.ts +0 -190
  264. package/dist/scriptedRESTAPI/RestSchemaUtils.js +0 -53
  265. package/dist/scriptedRESTAPI/RestSchemaUtils.js.map +0 -1
  266. package/dist/scriptedRESTAPI/RestUtils.d.ts +0 -69
  267. package/dist/scriptedRESTAPI/RestUtils.js +0 -497
  268. package/dist/scriptedRESTAPI/RestUtils.js.map +0 -1
  269. package/dist/scripts/ClientScriptPlugin.d.ts +0 -64
  270. package/dist/scripts/ClientScriptPlugin.js +0 -170
  271. package/dist/scripts/ClientScriptPlugin.js.map +0 -1
  272. package/dist/scripts/scriptUtils.d.ts +0 -1
  273. package/dist/scripts/scriptUtils.js +0 -9
  274. package/dist/scripts/scriptUtils.js.map +0 -1
  275. package/dist/uxf/ExperiencePlugin.d.ts +0 -45
  276. package/dist/uxf/ExperiencePlugin.js +0 -61
  277. package/dist/uxf/ExperiencePlugin.js.map +0 -1
  278. package/dist/uxf/RoutesPlugin.d.ts +0 -29
  279. package/dist/uxf/RoutesPlugin.js +0 -181
  280. package/dist/uxf/RoutesPlugin.js.map +0 -1
  281. package/dist/uxf/UxfFormulaParser/cleanUxValue.d.ts +0 -4
  282. package/dist/uxf/UxfFormulaParser/cleanUxValue.js +0 -65
  283. package/dist/uxf/UxfFormulaParser/cleanUxValue.js.map +0 -1
  284. package/dist/uxf/UxfFormulaParser/grammerParser/api.d.ts +0 -189
  285. package/dist/uxf/UxfFormulaParser/grammerParser/api.js +0 -158
  286. package/dist/uxf/UxfFormulaParser/grammerParser/api.js.map +0 -1
  287. package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.d.ts +0 -13
  288. package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +0 -604
  289. package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js.map +0 -1
  290. package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.d.ts +0 -12
  291. package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js +0 -551
  292. package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js.map +0 -1
  293. package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.d.ts +0 -31
  294. package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +0 -64
  295. package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js.map +0 -1
  296. package/dist/uxf/UxfFormulaParser/index.d.ts +0 -3
  297. package/dist/uxf/UxfFormulaParser/index.js +0 -11
  298. package/dist/uxf/UxfFormulaParser/index.js.map +0 -1
  299. package/dist/uxf/UxfFormulaParser/parser.d.ts +0 -8
  300. package/dist/uxf/UxfFormulaParser/parser.js +0 -87
  301. package/dist/uxf/UxfFormulaParser/parser.js.map +0 -1
  302. package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.d.ts +0 -8
  303. package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js +0 -17
  304. package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js.map +0 -1
  305. package/dist/uxf/constants.d.ts +0 -2
  306. package/dist/uxf/constants.js +0 -8
  307. package/dist/uxf/constants.js.map +0 -1
  308. package/dist/uxf/index.d.ts +0 -2
  309. package/dist/uxf/index.js +0 -11
  310. package/dist/uxf/index.js.map +0 -1
  311. package/dist/uxf/tectonicIdGenerator.d.ts +0 -12
  312. package/dist/uxf/tectonicIdGenerator.js +0 -79
  313. package/dist/uxf/tectonicIdGenerator.js.map +0 -1
  314. package/src/AttachmentPlugin.ts +0 -268
  315. package/src/BusinessRulePlugin.ts +0 -238
  316. package/src/CrossScopePrivilegePlugin.ts +0 -115
  317. package/src/DefaultPlugin.ts +0 -288
  318. package/src/HtmlTemplatePlugin.ts +0 -31
  319. package/src/IdPlugin.ts +0 -74
  320. package/src/IncludePlugin.ts +0 -206
  321. package/src/JsonPlugin.ts +0 -76
  322. package/src/ListPlugin.ts +0 -570
  323. package/src/NowConfigPlugin.ts +0 -69
  324. package/src/PackageJsonPlugin.ts +0 -68
  325. package/src/PropertyPlugin.ts +0 -237
  326. package/src/ScriptTemplatePlugin.ts +0 -53
  327. package/src/ServerModulePlugin.ts +0 -480
  328. package/src/UserPreferencePlugin.ts +0 -45
  329. package/src/aclAndRole/AclPlugin.ts +0 -420
  330. package/src/aclAndRole/RolePlugin.ts +0 -254
  331. package/src/aclAndRole/Util.ts +0 -113
  332. package/src/app/ApplicationMenuPlugin.ts +0 -165
  333. package/src/db/ColumnPlugins.ts +0 -114
  334. package/src/db/DBUtils.ts +0 -36
  335. package/src/db/DocumentationPlugin.ts +0 -316
  336. package/src/db/LicensingPlugin.ts +0 -138
  337. package/src/db/RecordPlugin.ts +0 -459
  338. package/src/db/TablePlugin.ts +0 -2072
  339. package/src/db/index.ts +0 -6
  340. package/src/scriptedRESTAPI/RESTDeserializationUtils.ts +0 -419
  341. package/src/scriptedRESTAPI/RESTSerializationUtils.ts +0 -228
  342. package/src/scriptedRESTAPI/RestApiPlugin.ts +0 -469
  343. package/src/scriptedRESTAPI/RestSchemaUtils.ts +0 -72
  344. package/src/scriptedRESTAPI/RestUtils.ts +0 -569
  345. package/src/scripts/ClientScriptPlugin.ts +0 -257
  346. package/src/scripts/scriptUtils.ts +0 -5
  347. package/src/uxf/ExperiencePlugin.ts +0 -67
  348. package/src/uxf/RoutesPlugin.ts +0 -211
  349. package/src/uxf/UxfFormulaParser/cleanUxValue.ts +0 -73
  350. package/src/uxf/UxfFormulaParser/grammerParser/api.js +0 -166
  351. package/src/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +0 -606
  352. package/src/uxf/UxfFormulaParser/grammerParser/grammarParser.js +0 -551
  353. package/src/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +0 -65
  354. package/src/uxf/UxfFormulaParser/index.ts +0 -4
  355. package/src/uxf/UxfFormulaParser/parser.ts +0 -64
  356. package/src/uxf/UxfFormulaParser/utils/getErrorMsg.ts +0 -13
  357. package/src/uxf/constants.ts +0 -4
  358. package/src/uxf/index.ts +0 -2
  359. package/src/uxf/tectonicIdGenerator.ts +0 -78
@@ -1,238 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import {
3
- BusinessRule,
4
- BusinessRuleSchema,
5
- BusinessRuleSchemaInc,
6
- getRolesArray,
7
- localWhenSchemaTransformer,
8
- } from '@servicenow/sdk-core/runtime/app'
9
- import {
10
- Plugin,
11
- generateCallExpressionExportForDocument,
12
- getSysUpdateName,
13
- getCallExpressionName,
14
- getOrCreateEntitySourceFile,
15
- linkDocument,
16
- removeNode,
17
- stringify,
18
- transformFunctionArguments,
19
- writeArrayPropertyAsReference,
20
- writeCustomProperty,
21
- getOrCreatePropertyAssignment,
22
- EntityData,
23
- ObjectData,
24
- StringData,
25
- NumberData,
26
- BooleanData,
27
- Data,
28
- UndefinedData,
29
- transformCustomizedProperties,
30
- } from '@servicenow/sdk-build-core'
31
- import { additionalProperties } from '@servicenow/sdk-core/runtime/util'
32
- import { processScript } from './ScriptTemplatePlugin'
33
- import { extractCallExpressionAsRecord } from './db/RecordPlugin'
34
- import * as z from 'zod'
35
- import { Diagnostic, ts } from '@servicenow/sdk-project'
36
- import { Record, TableName } from '@servicenow/sdk-core/runtime/db'
37
- import { getRolesString } from './aclAndRole/RolePlugin'
38
- import { ModuleFunctionData } from './ServerModulePlugin'
39
-
40
- // Similar to lodash's groupBy, but simply stores the last element of each group
41
- function groupByExistence<T>(collection: T[] | undefined, keyProvider: (element: T) => string): { [key: string]: T } {
42
- return (
43
- collection?.reduce((groups, e) => {
44
- groups[keyProvider(e)] = e
45
- return groups
46
- }, {}) ?? {}
47
- )
48
- }
49
-
50
- function businessRuleAsRecord<const T extends TableName>(entity: EntityData<BusinessRule<T>>): ObjectData<Record> {
51
- const node = entity.getNode()
52
- const br = entity.getProperties()
53
- const rest = additionalProperties(br, BusinessRuleSchema)
54
-
55
- const scriptData = br.script
56
- const script = new StringData(
57
- ModuleFunctionData.getGlueCode(scriptData, (n) => `${n}(current, previous)`),
58
- scriptData?.getNode() ?? node
59
- )
60
-
61
- const roleConditionsData = br.role_conditions
62
- const roleConditions = new StringData(
63
- roleConditionsData && Data.isArray(roleConditionsData) ? getRolesString(roleConditionsData) : '',
64
- roleConditionsData?.getNode() ?? node
65
- )
66
-
67
- const { insertAction, updateAction, deleteAction, queryAction } = groupByExistence(
68
- entity.getProperty('action', 'array')?.getElements(),
69
- (action) => `${action.getValue()}Action`
70
- )
71
-
72
- const when = new StringData(localWhenSchemaTransformer(br.when.getValue()), br.when.getNode())
73
-
74
- return new ObjectData(
75
- {
76
- $id: br.$id,
77
- table: new StringData('sys_script', node),
78
- data: new ObjectData(
79
- {
80
- ...rest,
81
- name: br.name,
82
- collection: br.table,
83
- script,
84
- order: br.order ?? new NumberData(100, node),
85
- action_insert: new BooleanData(!!insertAction, insertAction?.getNode() ?? node),
86
- action_update: new BooleanData(!!updateAction, updateAction?.getNode() ?? node),
87
- action_query: new BooleanData(!!queryAction, queryAction?.getNode() ?? node),
88
- action_delete: new BooleanData(!!deleteAction, deleteAction?.getNode() ?? node),
89
- active: br.active ?? new BooleanData(true, node),
90
- when: br.when ? when : new StringData('before', node),
91
- message: br.message ?? new UndefinedData(node),
92
- add_message: br.add_message ?? new BooleanData(br.message ? true : false, node),
93
- condition: br.condition ?? new UndefinedData(node),
94
- filter_condition: br.filter_condition ?? new UndefinedData(node),
95
- template: br.set_field_value ?? new UndefinedData(node),
96
- description: br.description ?? new UndefinedData(node),
97
- role_conditions: roleConditions,
98
- },
99
- node
100
- ),
101
- },
102
- node
103
- )
104
- }
105
-
106
- export default Plugin({
107
- name: 'BusinessRule',
108
- ownedTables: {
109
- sys_script: { diagnosticLevel: Diagnostic.Level.Warn },
110
- },
111
- extractors: {
112
- entity: {
113
- fluent: {
114
- CallExpression(node, context) {
115
- return extractCallExpressionAsRecord(
116
- BusinessRule,
117
- businessRuleAsRecord,
118
- (br) => context.registerExplicitId('sys_script', br.$id as string),
119
- node,
120
- context
121
- )
122
- },
123
- },
124
- },
125
- },
126
- generators: {
127
- record(document, context) {
128
- const tableName = document.data!['table']
129
- if (tableName !== 'sys_script') {
130
- return undefined
131
- }
132
-
133
- return linkDocument(
134
- document,
135
- generateCallExpressionExportForDocument(
136
- context,
137
- {
138
- sourceFile: getOrCreateEntitySourceFile(context, getSysUpdateName(document, 'sys_script')),
139
- moduleSpecifier: '@servicenow/sdk/core',
140
- },
141
- BusinessRule,
142
- { $id: document.guid }
143
- ).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
144
- )
145
- },
146
- },
147
- transformers: {
148
- record: {
149
- CallExpression(document) {
150
- if (getCallExpressionName(document.node) !== BusinessRule.name) {
151
- return false
152
- }
153
-
154
- if (document.action === 'DELETE') {
155
- removeNode(document.node)
156
- return true
157
- }
158
-
159
- const changedData = (document.changedData as any).data
160
- const modified_properties = BusinessRuleSchemaInc.deepPartial().safeParse(changedData)
161
- const merged_properties = BusinessRuleSchemaInc.safeParse((document.data as any).data)
162
- const incoming_properties = BusinessRuleSchemaInc.safeParse((document.xmlData as any).data)
163
- if (!modified_properties.success || !merged_properties.success || !incoming_properties.success) {
164
- return false
165
- }
166
-
167
- const [args] = document.node.getArguments()
168
- if (!ts.Node.isObjectLiteralExpression(args)) {
169
- return false
170
- }
171
- const {
172
- role_conditions: roles,
173
- filter_condition: filters,
174
- collection,
175
- script,
176
- template,
177
- action_delete,
178
- action_insert,
179
- action_query,
180
- action_update,
181
- ...rest
182
- } = modified_properties.data
183
-
184
- const xml_actions = getActionsArray(incoming_properties.data)
185
- if (xml_actions.length > 0 || getActionsArray(merged_properties.data).length > 0) {
186
- writeCustomProperty(args, 'action', '[]', stringify(xml_actions))
187
- } else {
188
- const actionsProp = getOrCreatePropertyAssignment(args, 'action', '[]')
189
- actionsProp.remove()
190
- }
191
-
192
- if (roles) {
193
- writeArrayPropertyAsReference(args, 'role_conditions', '[]', getRolesArray(roles))
194
- }
195
-
196
- if (filters) {
197
- writeCustomProperty(args, 'filter_condition', '', `\`${filters}\``)
198
- }
199
-
200
- if (script !== undefined) {
201
- processScript(args, 'script', script)
202
- }
203
-
204
- if (template) {
205
- writeCustomProperty(args, 'set_field_value', '', stringify(template))
206
- }
207
-
208
- const reqSchema = BusinessRuleSchemaInc.required()
209
- transformCustomizedProperties(BusinessRule, document.node, changedData, modified_properties.data)
210
- const result = transformFunctionArguments(document.node, BusinessRule, {
211
- table: collection,
212
- ...(rest as Partial<z.infer<typeof reqSchema>>),
213
- })
214
- return result
215
- },
216
- },
217
- },
218
- })
219
-
220
- function getActionsArray(data) {
221
- const actions: BR_ACTIONS[] = []
222
- if (data.action_update) {
223
- actions.push('update')
224
- }
225
- if (data.action_delete) {
226
- actions.push('delete')
227
- }
228
- if (data.action_insert) {
229
- actions.push('insert')
230
- }
231
- if (data.action_query) {
232
- actions.push('query')
233
- }
234
-
235
- return actions
236
- }
237
-
238
- type BR_ACTIONS = 'insert' | 'update' | 'delete' | 'query'
@@ -1,115 +0,0 @@
1
- import { CrossScopePrivilege, CrossScopePrivilegeSchema } from '@servicenow/sdk-core/runtime/app'
2
- import {
3
- EntityData,
4
- extractCallExpression,
5
- generateCallExpressionExportForDocument,
6
- getCallExpressionName,
7
- getOrCreateEntitySourceFile,
8
- getSysUpdateName,
9
- linkDocument,
10
- ObjectData,
11
- Plugin,
12
- removeNode,
13
- transformFunctionArguments,
14
- } from '@servicenow/sdk-build-core'
15
- import { RecordPlugin } from './db/RecordPlugin'
16
- import { Diagnostic, ts } from '@servicenow/sdk-project'
17
- import { Record } from '@servicenow/sdk-core/runtime/db'
18
- import { except } from './scripts/scriptUtils'
19
- import z from 'zod'
20
-
21
- export default Plugin({
22
- name: 'CrossScopePrivilege',
23
- ownedTables: {
24
- sys_scope_privilege: { diagnosticLevel: Diagnostic.Level.Warn },
25
- },
26
- extractors: {
27
- entity: {
28
- fluent: {
29
- CallExpression: (node, context) =>
30
- extractCallExpression(CrossScopePrivilege, 'sys_scope_privilege', node, context, (privilege) =>
31
- context.registerExplicitId('sys_scope_privilege', privilege.$id as string)
32
- ),
33
- },
34
- },
35
- },
36
- composers: {
37
- entity: {
38
- sys_scope_privilege(entity, context) {
39
- const scopeId = context.app.config.scopeId
40
- const privilege = CrossScopePrivilegeSchema.and(z.any()).safeParse(entity.getValue())
41
- if (!privilege.success) {
42
- return Promise.resolve(undefined)
43
- }
44
-
45
- const { $id, ...rest } = privilege.data
46
-
47
- const privilegeRecord = Record({
48
- table: 'sys_scope_privilege',
49
- $id,
50
- data: {
51
- source_scope: scopeId,
52
- ...rest,
53
- },
54
- })
55
-
56
- return context.composeEntities(
57
- [
58
- new EntityData(
59
- 'record',
60
- entity.getGuid(),
61
- ObjectData.fromObjectValue(privilegeRecord, entity.getNode()),
62
- entity.getNode(),
63
- entity.getInstallMethod()
64
- ),
65
- ],
66
- [RecordPlugin]
67
- )
68
- },
69
- },
70
- },
71
- generators: {
72
- record(document, ctx) {
73
- const tableName = document.data!['table']
74
- if (tableName !== 'sys_scope_privilege') {
75
- return undefined
76
- }
77
-
78
- return linkDocument(
79
- document,
80
- generateCallExpressionExportForDocument(
81
- ctx,
82
- {
83
- sourceFile: getOrCreateEntitySourceFile(ctx, getSysUpdateName(document, 'sys_scope_privilege')),
84
- moduleSpecifier: '@servicenow/sdk/core',
85
- },
86
- CrossScopePrivilege,
87
- { $id: document.guid }
88
- ).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
89
- )
90
- },
91
- },
92
-
93
- transformers: {
94
- record: {
95
- CallExpression(document) {
96
- if (getCallExpressionName(document.node) !== CrossScopePrivilege.name) {
97
- return false
98
- }
99
-
100
- if (document.action === 'DELETE') {
101
- removeNode(document.node)
102
- return true
103
- }
104
-
105
- if (!document.changedData) {
106
- return false
107
- }
108
-
109
- const crossScopeData = (document.changedData as any).data
110
- const cleanedData = except(crossScopeData, (key) => key.startsWith('sys_') || key === 'source_scope')
111
- return transformFunctionArguments(document.node, CrossScopePrivilege, cleanedData)
112
- },
113
- },
114
- },
115
- })
@@ -1,288 +0,0 @@
1
- import { isSupportedNode } from '@servicenow/sdk-project'
2
- import {
3
- getValueDeclaration,
4
- Plugin,
5
- BooleanData,
6
- FluentDiagnostic,
7
- StringData,
8
- NumberData,
9
- Data,
10
- ArrayData,
11
- ObjectData,
12
- getDirectiveDiagnostics,
13
- } from '@servicenow/sdk-build-core'
14
- import { ts } from '@servicenow/sdk-project'
15
-
16
- export default Plugin({
17
- name: 'Default',
18
- extractors: {
19
- raw: {
20
- any: {
21
- TrueKeyword(node) {
22
- return {
23
- handled: true,
24
- diagnostics: [],
25
- data: new BooleanData(true, node),
26
- }
27
- },
28
-
29
- FalseKeyword(node) {
30
- return {
31
- handled: true,
32
- diagnostics: [],
33
- data: new BooleanData(false, node),
34
- }
35
- },
36
-
37
- StringLiteral(node) {
38
- return {
39
- handled: true,
40
- diagnostics: [],
41
- data: new StringData(node.getLiteralValue(), node),
42
- }
43
- },
44
-
45
- NoSubstitutionTemplateLiteral(node) {
46
- return {
47
- handled: true,
48
- diagnostics: [],
49
- data: new StringData(node.getLiteralValue(), node),
50
- }
51
- },
52
-
53
- NumericLiteral(node) {
54
- return {
55
- handled: true,
56
- diagnostics: [],
57
- data: new NumberData(node.getLiteralValue(), node),
58
- }
59
- },
60
-
61
- AsExpression(node, context) {
62
- return context.extractAst(node.getExpression())
63
- },
64
-
65
- ExportAssignment(node, context) {
66
- return context.extractAst(node.getExpression())
67
- },
68
-
69
- ComputedPropertyName(node, context) {
70
- return context.extractAst(node.getExpression())
71
- },
72
-
73
- Identifier(node, context) {
74
- const extracted = context.extractAst(getValueDeclaration(node))
75
-
76
- const newDiagnostics: FluentDiagnostic[] = []
77
- if (extracted['diagnostics']) {
78
- extracted['diagnostics'].forEach((diagnostic) => {
79
- newDiagnostics.push(new FluentDiagnostic(node, diagnostic.message))
80
- })
81
- }
82
- return {
83
- handled: extracted.handled,
84
- data: extracted['data'],
85
- diagnostics: newDiagnostics,
86
- }
87
- },
88
-
89
- PropertyAccessExpression(node, context) {
90
- return context.extractAst(node.getNameNode())
91
- },
92
-
93
- ShorthandPropertyAssignment(node, context) {
94
- return context.extractAst(node.getNameNode())
95
- },
96
-
97
- VariableDeclaration(node, context) {
98
- const initializer = node.getInitializer()
99
- if (!initializer) {
100
- return {
101
- handled: true,
102
- diagnostics: [
103
- new FluentDiagnostic(
104
- node,
105
- `Expected variable declaration to have an initializer: ${node.getText()}`
106
- ),
107
- ],
108
- }
109
- }
110
-
111
- return context.extractAst(initializer)
112
- },
113
-
114
- PropertyAssignment(node, context) {
115
- const initializer = node.getInitializer()
116
- if (!initializer) {
117
- return {
118
- handled: true,
119
- diagnostics: [
120
- new FluentDiagnostic(
121
- node,
122
- `Expected property assignment to have an initializer: ${node.getText()}`
123
- ),
124
- ],
125
- }
126
- }
127
-
128
- return context.extractAst(initializer)
129
- },
130
-
131
- ArrayLiteralExpression(node, context) {
132
- const diagnostics: FluentDiagnostic[] = []
133
- const data: Data[] = []
134
-
135
- for (const element of node.getElements()) {
136
- const result = context.extractAst(element)
137
- if (!result.handled) {
138
- return {
139
- handled: true,
140
- diagnostics: [new FluentDiagnostic(element, 'Unsupported array element')],
141
- }
142
- }
143
-
144
- diagnostics.push(...result.diagnostics)
145
- if (result.data) {
146
- data.push(result.data)
147
- }
148
- }
149
-
150
- return {
151
- handled: true,
152
- diagnostics,
153
- data: new ArrayData(data, node),
154
- }
155
- },
156
-
157
- ObjectLiteralExpression(node, context) {
158
- const diagnostics: FluentDiagnostic[] = []
159
- const data: Record<string, Data> = {}
160
-
161
- for (const prop of node.getProperties()) {
162
- if (!ts.Node.isPropertyAssignment(prop) && !ts.Node.isShorthandPropertyAssignment(prop)) {
163
- diagnostics.push(new FluentDiagnostic(prop, 'Only property assignments are allowed'))
164
- continue
165
- }
166
-
167
- const nameNode = prop.getNameNode()
168
- const result = context.extractAst(prop)
169
- if (!result.handled) {
170
- return {
171
- handled: true,
172
- diagnostics: [new FluentDiagnostic(prop, 'Unsupported property assignment')],
173
- }
174
- }
175
-
176
- diagnostics.push(...result.diagnostics)
177
- if (!result.data) {
178
- diagnostics.push(
179
- new FluentDiagnostic(nameNode, `Property assignment has unsupported structure`)
180
- )
181
- continue
182
- }
183
-
184
- const name = ts.Node.isStringLiteral(nameNode) ? nameNode.getLiteralValue() : prop.getName()
185
- data[name] = result.data
186
- }
187
-
188
- return {
189
- handled: true,
190
- diagnostics,
191
- data: new ObjectData(data, node),
192
- }
193
- },
194
-
195
- TemplateExpression(node, context) {
196
- const diagnostics: FluentDiagnostic[] = []
197
- const text =
198
- node.getHead().getLiteralText() +
199
- node
200
- .getTemplateSpans()
201
- .map((s) => {
202
- const result = context.extractAst(s.getExpression())
203
- if (!result.handled) {
204
- diagnostics.push(new FluentDiagnostic(s, 'Unsupported expression in template'))
205
- return undefined
206
- }
207
-
208
- if (!result.data) {
209
- diagnostics.push(new FluentDiagnostic(s, `Unsupported expression in template`))
210
- return undefined
211
- }
212
-
213
- diagnostics.push(...result.diagnostics)
214
- return `${result.data.getValue()}${s.getLiteral().getLiteralText()}`
215
- })
216
- .join('')
217
-
218
- return {
219
- handled: true,
220
- diagnostics,
221
- data: new StringData(text, node),
222
- }
223
- },
224
-
225
- //Added support for -ve number alone. Can be upgraded later to support other expressions as required.
226
- PrefixUnaryExpression(node) {
227
- if (
228
- !ts.Node.isNumericLiteral(node.getOperand()) ||
229
- node.getOperatorToken() !== ts.SyntaxKind.MinusToken
230
- ) {
231
- return {
232
- handled: true,
233
- diagnostics: [new FluentDiagnostic(node, 'Unsupported prefix unary expression')],
234
- }
235
- }
236
-
237
- return {
238
- handled: true,
239
- diagnostics: [],
240
- data: new NumberData(
241
- -node.getOperand().asKind(ts.SyntaxKind.NumericLiteral)!.getLiteralValue(),
242
- node
243
- ),
244
- }
245
- },
246
- },
247
- },
248
- },
249
- diagnostics: {
250
- Node(node) {
251
- if (isSupportedNode(node)) {
252
- return getDirectiveDiagnostics(node)
253
- }
254
-
255
- return [new FluentDiagnostic(node, `${getRawKindName(node)} is not allowed`)]
256
- },
257
- },
258
- })
259
-
260
- let rawKindNames: Record<ts.SyntaxKind, string> | undefined
261
-
262
- /**
263
- * This is a hack to get more accurate names for given syntax kinds. TypeScript's
264
- * `SyntaxKind` enum has a lot of reused numeric values, so when you try to index
265
- * it with a number, you might get a different name than you expect. For example,
266
- * `VariableStatement` and `FirstStatement` both have the same numeric value, and
267
- * you probably never would expect the latter. Thankfully, all the names that you
268
- * probably never want are towards the end, so this just grabs all the first ones
269
- * and ignores any duplicates that come after.
270
- */
271
- function getRawKindName(node: ts.Node): string | undefined {
272
- if (!rawKindNames) {
273
- rawKindNames = Object.entries(ts.SyntaxKind)
274
- .filter(([k]) => isNaN(Number(k)))
275
- .reduce(
276
- (names, [name, value]) => {
277
- if (typeof value === 'number' && !names[value]) {
278
- names[value] = name // Only add if it hasn't been added already
279
- }
280
-
281
- return names
282
- },
283
- {} as Record<ts.SyntaxKind, string>
284
- )
285
- }
286
-
287
- return rawKindNames[node.getKind()]
288
- }
@@ -1,31 +0,0 @@
1
- import { Plugin, StringData, UndefinedData } from '@servicenow/sdk-build-core'
2
- import { ts } from '@servicenow/sdk-project'
3
-
4
- const TEMPLATE_LITERAL_TAG = 'html'
5
-
6
- export default Plugin({
7
- name: 'htmlTemplate',
8
- extractors: {
9
- raw: {
10
- fluent: {
11
- TaggedTemplateExpression: (node) => {
12
- if (node.getTag().getText() !== TEMPLATE_LITERAL_TAG) {
13
- return { handled: false }
14
- }
15
-
16
- const value = getTemplateLiteralValue(node)?.trim()
17
-
18
- return {
19
- handled: true,
20
- diagnostics: [],
21
- data: typeof value === 'string' ? new StringData(value, node) : new UndefinedData(node),
22
- }
23
- },
24
- },
25
- },
26
- },
27
- })
28
-
29
- function getTemplateLiteralValue(node: ts.TaggedTemplateExpression) {
30
- return node?.getTemplate().asKind(ts.SyntaxKind.NoSubstitutionTemplateLiteral)?.getLiteralValue()
31
- }