@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,420 +0,0 @@
1
- import {
2
- Acl,
3
- TableAcl,
4
- NamedAcl,
5
- AclAttributes,
6
- AclBase,
7
- AclOperations,
8
- AclTypes,
9
- AclSchema,
10
- } from '@servicenow/sdk-core/runtime/app'
11
- import {
12
- Plugin,
13
- extractCallExpression,
14
- generateCallExpressionExportForDocument,
15
- getOrCreateEntitySourceFile,
16
- getSysUpdateName,
17
- linkDocument,
18
- removeNode,
19
- transformFunctionArguments,
20
- FluentDiagnostic,
21
- findObjectPropertyValue,
22
- EntityData,
23
- ObjectData,
24
- ArrayData,
25
- Data,
26
- getCallExpressionName,
27
- } from '@servicenow/sdk-build-core'
28
- import { addObjectToArrayById, removeObjectFromArrayById } from './Util'
29
- import { additionalProperties } from '@servicenow/sdk-core/runtime/util'
30
- import { Record as DBRecord, TableName } from '@servicenow/sdk-core/runtime/db'
31
- import { except } from '../scripts/scriptUtils'
32
- import { ts } from '@servicenow/sdk-project'
33
- import { AclNamedTypes } from '@servicenow/sdk-core/runtime/app'
34
- import { processScript } from '../ScriptTemplatePlugin'
35
- import { Diagnostic } from '@servicenow/sdk-project'
36
- import { ModuleFunctionData } from '../ServerModulePlugin'
37
- import { RecordPlugin } from '../db'
38
-
39
- type AclDoc = {
40
- table: string
41
- data: {
42
- sys_id: string
43
- }
44
- }
45
-
46
- type AclRole = {
47
- table: string
48
- data: {
49
- sys_security_acl: string
50
- sys_user_role: string
51
- }
52
- }
53
-
54
- type AclData = AclBase & {
55
- name: string
56
- type: keyof typeof AclTypes
57
- }
58
-
59
- const ExecuteOnlyTypes = new Set([
60
- 'client_callable_flow_object',
61
- 'client_callable_script_include',
62
- 'graphql',
63
- 'processor',
64
- 'rest_endpoint',
65
- ])
66
-
67
- function aclAsRecord<T extends TableName>(config: Acl<T>) {
68
- const tableConfig = config as TableAcl<T>
69
- const namedConfig = config as NamedAcl
70
-
71
- const field = String(tableConfig.field || '')
72
- const name = namedConfig.name || (field ? `${tableConfig.table}.${field}` : tableConfig.table)
73
- if (!name) {
74
- throw new Error(`ACL of type ${config.type} and $id '${config.$id}' has no name or associated table`)
75
- }
76
-
77
- if (config.operation !== 'execute' && ExecuteOnlyTypes.has(config.type)) {
78
- throw new Error(`ACL ${name} must use operation 'execute', because it is of type '${config.type}'`)
79
- }
80
- if (config.script && config.type === 'graphql') {
81
- throw new Error(`ACL ${name} does not support scripts, because it is of type ${config.type}`)
82
- }
83
- if (tableConfig.applies_to && tableConfig.type !== 'record') {
84
- throw new Error(`ACL ${name} cannot set applies_to unless its type is 'record'`)
85
- }
86
- if (tableConfig.operation === 'add_to_list' && (config.script || config.condition)) {
87
- throw new Error(`ACL ${name} cannot have a script or condition due to its 'add_to_list' operation`)
88
- }
89
-
90
- return DBRecord({
91
- table: 'sys_security_acl',
92
- $id: config.$id,
93
- data: {
94
- name,
95
- active: config.active ?? true,
96
- type: AclTypes[config.type ?? 'record'],
97
- operation: AclOperations[config.operation as keyof typeof AclOperations] || config.operation || '',
98
- decision_type: config.decision_type ?? 'allow',
99
- description: config.description || '',
100
- local_or_existing: config.local_or_existing || 'Local',
101
- admin_overrides: config.admin_overrides ?? true,
102
- advanced: !!config.script,
103
- condition: config.condition ?? '',
104
- applies_to: tableConfig.applies_to ?? '',
105
- script: config.script as any,
106
- security_attribute:
107
- (config.security_attribute && AclAttributes[config.security_attribute as keyof typeof AclAttributes]) ||
108
- config.security_attribute ||
109
- '',
110
- ...additionalProperties(config, AclSchema),
111
- },
112
- })
113
- }
114
-
115
- export default Plugin({
116
- name: 'Acl',
117
- ownedTables: {
118
- sys_security_acl: { diagnosticLevel: Diagnostic.Level.Warn },
119
- },
120
- extractors: {
121
- entity: {
122
- fluent: {
123
- CallExpression(node, context) {
124
- const result = extractCallExpression(Acl, 'record', node, context, (acl) =>
125
- context.registerExplicitId('sys_security_acl', acl.$id)
126
- )
127
-
128
- if (!result.handled || !result.data) {
129
- return result
130
- }
131
-
132
- const acl = result.data
133
- const aclRecord = aclAsRecord(acl.getValue())
134
- const scriptVal = ModuleFunctionData.getGlueCode(
135
- acl.getProperty('script'),
136
- (n) => `answer = ${n}(current)`
137
- )
138
-
139
- const m2mRoleToAcl =
140
- acl
141
- .getProperty('roles')
142
- ?.getValue(true)
143
- ?.map((role) => {
144
- const roleId = typeof role === 'string' ? role : role.$id
145
-
146
- const roleSysId =
147
- typeof role === 'string'
148
- ? role
149
- : context.registerExplicitId('sys_user_role', role.$id)
150
- const guid = context.keys.registerCompositeId('sys_security_acl_role', {
151
- sys_security_acl: aclRecord.$id,
152
- sys_user_role: roleId,
153
- })
154
-
155
- return new EntityData(
156
- 'record',
157
- guid,
158
- ObjectData.fromObjectValue(
159
- DBRecord({
160
- table: 'sys_security_acl_role',
161
- $id: guid,
162
- data: {
163
- sys_security_acl: acl.getGuid(),
164
- sys_user_role: roleSysId,
165
- },
166
- }),
167
- node
168
- ),
169
- node,
170
- acl.getInstallMethod()
171
- )
172
- }) || []
173
-
174
- const diagnostics = performDiagnosticChecksOnSecurityAttribute(
175
- node,
176
- acl.getValue(true),
177
- m2mRoleToAcl
178
- )
179
-
180
- const aclWithScript = { ...aclRecord, data: { ...aclRecord.data, script: scriptVal || '' } }
181
- const aclEntityData = new EntityData(
182
- 'record',
183
- acl.getGuid(),
184
- ObjectData.fromObjectValue(aclWithScript, node),
185
- node,
186
- acl.getInstallMethod()
187
- )
188
-
189
- const wrapperEntity = new EntityData(
190
- 'acl',
191
- acl.getGuid(),
192
- new ObjectData(
193
- {
194
- records: new ArrayData([aclEntityData, ...m2mRoleToAcl], node),
195
- },
196
- node
197
- ),
198
- node,
199
- acl.getInstallMethod(),
200
- acl.getExplicitIds()
201
- )
202
-
203
- return {
204
- handled: true,
205
- diagnostics: [...result.diagnostics, ...diagnostics],
206
- data: wrapperEntity,
207
- }
208
- },
209
- },
210
- },
211
- },
212
- composers: {
213
- entity: {
214
- acl(entity, context) {
215
- return Promise.all(
216
- entity
217
- .getPropertyOrThrow('records', 'array')
218
- .getElements()
219
- .map((record) => {
220
- if (!Data.isEntity(record)) {
221
- throw new Error('Expected entity')
222
- }
223
-
224
- return RecordPlugin.composers.entity.record(record, context)
225
- })
226
- .flat()
227
- )
228
- },
229
- },
230
- },
231
- arrangers: {
232
- record(document, context) {
233
- if ((document.data as any).table !== 'sys_security_acl_role') {
234
- return { handled: false }
235
- }
236
-
237
- const aclId = (document.data as any).data.sys_security_acl
238
- const aclDoc = context.getDocument(aclId, 'record')
239
- const aclDeleted = aclDoc && aclDoc.action === 'DELETE'
240
- if (aclDeleted && document.action === 'INSERT_OR_UPDATE') {
241
- throw new Error(
242
- `Existing sys_security_acl_role with id ${document.guid} is referencing deleted ACL ${aclId}. This can be fixed by either deleting the sys_security_acl_role record or updating its sys_security_acl reference.`
243
- )
244
- }
245
-
246
- return {
247
- handled: true,
248
- result: aclId ? { kind: 'record', guid: aclId } : undefined,
249
- }
250
- },
251
- },
252
- generators: {
253
- record(document, context, linkedDocuments) {
254
- const documentType = (document.data as any)?.table
255
- if (documentType === 'sys_security_acl_role') {
256
- if (!document.parent) {
257
- return undefined
258
- }
259
- const acl = linkedDocuments.find(
260
- (doc) =>
261
- (doc.data as AclDoc).table === 'sys_security_acl' &&
262
- doc.guid === (document.data as AclRole).data.sys_security_acl
263
- )
264
-
265
- return acl && acl.node ? { ...document, node: acl.node } : undefined
266
- }
267
-
268
- if (documentType !== 'sys_security_acl') {
269
- return undefined
270
- }
271
-
272
- return linkDocument(
273
- document,
274
- generateCallExpressionExportForDocument(
275
- context,
276
- {
277
- sourceFile: getOrCreateEntitySourceFile(
278
- context,
279
- getSysUpdateName(document, 'sys_security_acl')
280
- ),
281
- moduleSpecifier: '@servicenow/sdk/core',
282
- },
283
- Acl,
284
- { $id: document.guid }
285
- ).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
286
- )
287
- },
288
- },
289
- transformers: {
290
- record: {
291
- CallExpression(document, context) {
292
- const documentType = (document.data as any)?.table
293
-
294
- const [args] = document.node.getArguments()
295
- if (!ts.Node.isObjectLiteralExpression(args)) {
296
- return false
297
- }
298
-
299
- if (documentType === 'sys_security_acl_role') {
300
- if (!document.parent || getCallExpressionName(document.node) !== Acl.name) {
301
- // Record plugin can handle this as its own entity
302
- return false
303
- }
304
- const acl2Role = (document.data as AclRole).data
305
- if (document.action === 'DELETE') {
306
- const roleId = acl2Role.sys_user_role
307
- if (roleId) {
308
- removeObjectFromArrayById(document, 'roles', context)
309
- }
310
- return true
311
- }
312
-
313
- addObjectToArrayById(document, 'roles', acl2Role.sys_user_role, context)
314
- return true
315
- }
316
-
317
- if (document.action === 'DELETE') {
318
- removeNode(document.node)
319
- return true
320
- }
321
-
322
- if (documentType !== 'sys_security_acl' || !document.changedData) {
323
- return false
324
- }
325
-
326
- const modifiedAclData = (document.changedData as any).data as AclBase
327
- const unmodifiedAclData = (document.data as any).data as AclData
328
- const type = reverseLookup(AclTypes, unmodifiedAclData.type)
329
-
330
- const aclData = {
331
- ...except(
332
- modifiedAclData,
333
- (key) =>
334
- key.startsWith('sys_') ||
335
- key === 'advanced' ||
336
- key === 'name' ||
337
- key === 'operation' ||
338
- key === 'script'
339
- ),
340
- ...getTableOrName(type, unmodifiedAclData.name),
341
- security_attribute:
342
- reverseLookup(AclAttributes, unmodifiedAclData.security_attribute) ||
343
- unmodifiedAclData.security_attribute,
344
- operation: reverseLookup(AclOperations, unmodifiedAclData.operation) || unmodifiedAclData.operation,
345
- type,
346
- } as any
347
-
348
- const { script } = modifiedAclData as { script?: string }
349
- if (script !== undefined) {
350
- processScript(args, 'script', script)
351
- }
352
- transformFunctionArguments(document.node, Acl, aclData)
353
- context.argTypesToFix.push(document.node)
354
- return true
355
- },
356
- },
357
- },
358
- })
359
-
360
- // security_attribute.is_localizsed ? 'Local' : 'Existing'
361
- function performDiagnosticChecksOnSecurityAttribute<T>(
362
- callExpression: ts.CallExpression,
363
- aclData: AclBase,
364
- roles: Array<T>
365
- ) {
366
- const diagnostics: FluentDiagnostic[] = []
367
-
368
- if (roles.length < 1) {
369
- const attributeRecord = aclData.security_attribute as DBRecord<'sys_security_attribute'>
370
- if (!aclData.security_attribute && !aclData.script && !aclData.condition) {
371
- diagnostics.push(
372
- new FluentDiagnostic(
373
- callExpression,
374
- 'ACLs must have at least one of the following: roles, security_attribute, condition, or script',
375
- { level: Diagnostic.Level.Warn }
376
- )
377
- )
378
- } else if (attributeRecord && attributeRecord.data) {
379
- if (
380
- aclData.local_or_existing === 'Existing' &&
381
- (attributeRecord.data.type !== 'compound' || attributeRecord.data.is_localized)
382
- ) {
383
- diagnostics.push(
384
- new FluentDiagnostic(
385
- findObjectPropertyValue(callExpression, 'security_attribute'),
386
- `Invalid ACL with 'Existing' sys_security_attribute: Must have a security_attribute with a type of 'compound' and is_localized set to false.`
387
- )
388
- )
389
- } else if (
390
- (!aclData.local_or_existing || aclData.local_or_existing === 'Local') &&
391
- !attributeRecord.data.is_localized
392
- ) {
393
- diagnostics.push(
394
- new FluentDiagnostic(
395
- findObjectPropertyValue(callExpression, 'security_attribute'),
396
- `Invalid ACL with 'Local' security_attribute: security_attribute must have is_localized set to true`
397
- )
398
- )
399
- }
400
- }
401
- }
402
- return diagnostics
403
- }
404
-
405
- function getTableOrName(type: keyof typeof AclTypes, name: string) {
406
- if (AclNamedTypes[type]) {
407
- return { name }
408
- }
409
- const tablePathParts = name.split('.')
410
- const table = tablePathParts[0] || ''
411
- const field = tablePathParts[1] || ''
412
-
413
- return { table, field }
414
- }
415
-
416
- function reverseLookup<T extends object>(obj: T, sysId): keyof T {
417
- return (Object.entries(obj)
418
- .filter(([_, id]) => id === sysId)
419
- .map(([key]) => key)[0] || '') as keyof T
420
- }
@@ -1,254 +0,0 @@
1
- import { Role, RoleConfig, roleSchema } from '@servicenow/sdk-core/runtime/app'
2
- import {
3
- Context,
4
- Plugin,
5
- linkDocument,
6
- extractCallExpression,
7
- FluentDiagnostic,
8
- findObjectPropertyValue,
9
- Data,
10
- isSNScope,
11
- LinkedDocument,
12
- ArrayData,
13
- } from '@servicenow/sdk-build-core'
14
- import {
15
- generateCallExpressionExportForDocument,
16
- getOrCreateEntitySourceFile,
17
- transformFunctionArguments,
18
- getSysUpdateName,
19
- removeNode,
20
- } from '@servicenow/sdk-build-core'
21
- import { addObjectToArrayById, removeObjectFromArrayById } from './Util'
22
- import { except } from '../scripts/scriptUtils'
23
- import { Diagnostic, SupportedNode, ts } from '@servicenow/sdk-project'
24
-
25
- export function getRolesString(roles: ArrayData<unknown[]>): string {
26
- const uniqueRoles = [
27
- ...new Set(
28
- roles.getElements().map((role) => {
29
- return Data.isEntity(role) ? role.getPropertyOrThrow('name', 'string').getValue() : role.getValue()
30
- })
31
- ),
32
- ]
33
-
34
- return uniqueRoles.join(',')
35
- }
36
-
37
- function mapRoleToRole(context: Context, roleId: string, containedRoleId: string, node: SupportedNode): LinkedDocument {
38
- const mappingId = context.keys.registerCompositeId('sys_user_role_contains', {
39
- role: roleId,
40
- contains: containedRoleId,
41
- })
42
-
43
- return {
44
- kind: 'record',
45
- guid: mappingId,
46
- node,
47
- data: {
48
- $id: mappingId,
49
- table: 'sys_user_role_contains',
50
- data: {
51
- contains: containedRoleId,
52
- role: roleId,
53
- },
54
- },
55
- }
56
- }
57
-
58
- type RoleDoc = {
59
- table: string
60
- data: {
61
- sys_id: string
62
- }
63
- }
64
-
65
- type RoleContainsDoc = {
66
- table: string
67
- data: {
68
- role: string
69
- contains: string
70
- }
71
- }
72
-
73
- export default Plugin({
74
- name: 'Role',
75
- ownedTables: {
76
- sys_user_role: { diagnosticLevel: Diagnostic.Level.Error },
77
- },
78
- extractors: {
79
- entity: {
80
- fluent: {
81
- CallExpression: (node, context) => {
82
- const result = extractCallExpression(
83
- Role as (role: RoleConfig) => RoleConfig,
84
- 'role',
85
- node,
86
- context,
87
- ({ $id }) => context.registerExplicitId('sys_user_role', $id as string)
88
- )
89
-
90
- if (!result.handled || !result.data) {
91
- return result
92
- }
93
-
94
- const role = result.data
95
- const diagnostics = result.diagnostics
96
- const scope = context.app?.config?.scope
97
- const name = role.getProperty('name').getValue()
98
- if (!isSNScope(scope) && !name.startsWith(`${scope}.`)) {
99
- const nameValue = findObjectPropertyValue(node, 'name')
100
- diagnostics.push(new FluentDiagnostic(nameValue, `Role name must begin with '${scope}.'`))
101
- }
102
-
103
- return {
104
- handled: true,
105
- diagnostics,
106
- data: role,
107
- }
108
- },
109
- },
110
- },
111
- },
112
- composers: {
113
- entity: {
114
- role(entity, context) {
115
- const scope = context.app?.config?.scope
116
- const guid = entity.getGuid()
117
-
118
- const role = roleSchema.safeParse(entity.getValue())
119
- if (!role.success) {
120
- return Promise.resolve(undefined)
121
- }
122
-
123
- const { $id: _, name, contains_roles, ...rest } = role.data
124
-
125
- const roleMappingDocuments: LinkedDocument[] = []
126
- const containsRoles = entity.getProperty('contains_roles')
127
- if (Data.isArray(containsRoles)) {
128
- for (const containedRole of containsRoles.getElements()) {
129
- const containedRoleSysId = Data.isEntity(containedRole)
130
- ? containedRole.getGuid()
131
- : Data.isString(containedRole)
132
- ? containedRole.getValue()
133
- : undefined
134
-
135
- if (!containedRoleSysId) {
136
- throw new Error(`Invalid contained role value: ${containedRole.getValue()}`)
137
- }
138
-
139
- roleMappingDocuments.push(
140
- mapRoleToRole(context, guid, containedRoleSysId, containedRole.getNode())
141
- )
142
- }
143
- }
144
-
145
- const suffix = name.replace(new RegExp(`^${scope}\\.`), '')
146
- const roleDocument = {
147
- kind: 'record',
148
- guid,
149
- node: entity.getNode(),
150
- data: {
151
- $id: guid,
152
- table: 'sys_user_role',
153
- data: {
154
- name,
155
- suffix,
156
- ...rest,
157
- },
158
- },
159
- }
160
-
161
- return Promise.resolve([roleDocument, ...roleMappingDocuments])
162
- },
163
- },
164
- },
165
- arrangers: {
166
- record(document) {
167
- if ((document.data as any).table !== 'sys_user_role_contains') {
168
- return { handled: false }
169
- }
170
-
171
- const roleId = (document.data as any).data.role
172
- return {
173
- handled: true,
174
- result: roleId ? { kind: 'record', guid: roleId } : undefined,
175
- }
176
- },
177
- },
178
- generators: {
179
- record(document, context: Context, linkedDocuments) {
180
- const documentType = (document.data as any)?.table
181
- if (documentType === 'sys_user_role_contains') {
182
- const role = linkedDocuments.find(
183
- (doc) =>
184
- (doc.data as RoleDoc).table === 'sys_user_role' &&
185
- doc.guid === (document.data as RoleContainsDoc).data.role
186
- )
187
- return role && role.node ? { ...document, node: role.node } : undefined
188
- }
189
-
190
- if (documentType !== 'sys_user_role') {
191
- return undefined
192
- }
193
-
194
- return linkDocument(
195
- document,
196
- generateCallExpressionExportForDocument(
197
- context,
198
- {
199
- sourceFile: getOrCreateEntitySourceFile(context, getSysUpdateName(document, 'sys_user_role')),
200
- moduleSpecifier: '@servicenow/sdk/core',
201
- },
202
- Role,
203
- { $id: document.guid }
204
- ).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
205
- )
206
- },
207
- },
208
- transformers: {
209
- record: {
210
- CallExpression(document, context) {
211
- const documentType = (document.data as any)?.table
212
- if (documentType === 'sys_user_role_contains') {
213
- const [args] = document.node.getArguments()
214
- if (!ts.Node.isObjectLiteralExpression(args) || !document.parent) {
215
- return false
216
- }
217
- if (document.action === 'DELETE') {
218
- removeObjectFromArrayById(document, 'contains_roles', context)
219
- return true
220
- }
221
- const m2mData = (document.data as RoleContainsDoc).data
222
- addObjectToArrayById(document, 'contains_roles', m2mData.contains, context)
223
- return true
224
- }
225
-
226
- if (documentType !== 'sys_user_role') {
227
- return false
228
- }
229
-
230
- if (document.action === 'DELETE') {
231
- removeNode(document.node)
232
- return true
233
- }
234
-
235
- if (!document.changedData) {
236
- return true
237
- }
238
-
239
- const rawRoleData = (document.changedData as any).data
240
- const roleData = except(
241
- rawRoleData,
242
- (key) =>
243
- key.startsWith('sys_') ||
244
- key === 'requires_subscription' ||
245
- key === 'suffix' ||
246
- key === 'includes_roles'
247
- )
248
- transformFunctionArguments(document.node, Role, roleData)
249
- context.argTypesToFix.push(document.node)
250
- return true
251
- },
252
- },
253
- },
254
- })