@servicenow/sdk-build-plugins 3.0.2 → 4.0.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 (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 +37 -0
  11. package/dist/atf/step-configs.js +2236 -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 +591 -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 +157 -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 +2284 -0
  136. package/src/atf/test-plugin.ts +728 -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 +170 -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 +651 -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 -1628
  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 -2070
  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
@@ -0,0 +1,78 @@
1
+ import { ts, Plugin, type Source, type Record, ElementAccessExpressionShape } from '@servicenow/sdk-build-core'
2
+
3
+ export class NowIdShape extends ElementAccessExpressionShape {
4
+ constructor({ source, id }: { source: Source; id: string | number }) {
5
+ super({ source, callee: 'Now.ID', arg: id })
6
+ }
7
+
8
+ override getValue(): string | number {
9
+ return this.getArg().getValue()
10
+ }
11
+
12
+ static override from(record: Record): NowIdShape {
13
+ const id = record.getId().getNowIdKey() ?? record.getId().getValue()
14
+
15
+ return new NowIdShape({ source: record, id })
16
+ }
17
+
18
+ override getCode(): string {
19
+ return `Now.ID[${this.getArg().getCode()}]`
20
+ }
21
+ }
22
+
23
+ export const NowIdPlugin = Plugin.create({
24
+ name: 'NowIdPlugin',
25
+ shapes: [
26
+ {
27
+ shape: ElementAccessExpressionShape,
28
+ fileTypes: ['fluent'],
29
+ toSubclass(expression, { diagnostics }) {
30
+ if (expression.getCallee() !== 'Now.ID') {
31
+ return { success: false }
32
+ }
33
+
34
+ const arg = expression.getArg()
35
+ if (!arg.isString() && !arg.isNumber()) {
36
+ diagnostics.error(arg, 'Now.ID argument must be a string or number')
37
+ return { success: false }
38
+ }
39
+
40
+ return {
41
+ success: true,
42
+ value: new NowIdShape({ source: expression, id: arg.getValue().toString() }),
43
+ }
44
+ },
45
+ },
46
+ ],
47
+ nodes: [
48
+ {
49
+ node: 'PropertyAccessExpression',
50
+ fileTypes: ['fluent'],
51
+ async toShape(node, { transform }) {
52
+ if (node.getName() !== '$id') {
53
+ return { success: false }
54
+ }
55
+
56
+ const identifier = node.getExpressionIfKind(ts.SyntaxKind.Identifier)
57
+ if (!identifier) {
58
+ return { success: false }
59
+ }
60
+
61
+ const result = await transform.toShape(identifier)
62
+ if (!result.success || !result.value.isIdentifier()) {
63
+ return { success: false }
64
+ }
65
+
66
+ const record = result.value.resolve()
67
+ if (!record.isRecord()) {
68
+ return { success: false }
69
+ }
70
+
71
+ return {
72
+ success: true,
73
+ value: record.getId(),
74
+ }
75
+ },
76
+ },
77
+ ],
78
+ })
@@ -0,0 +1,140 @@
1
+ import {
2
+ type ts,
3
+ path as pathModule,
4
+ CallExpressionShape,
5
+ Plugin,
6
+ type ProjectFile,
7
+ type Source,
8
+ StringShape,
9
+ Shape,
10
+ } from '@servicenow/sdk-build-core'
11
+ import { CallExpressionPlugin } from './call-expression-plugin'
12
+
13
+ export class NowIncludeShape extends CallExpressionShape {
14
+ private readonly includedFile: ProjectFile
15
+
16
+ constructor({ source, path, includedFile }: { source: Source; path: string; includedFile: ProjectFile }) {
17
+ super({ source, callee: 'Now.include', args: [path] })
18
+ this.includedFile = includedFile
19
+ }
20
+
21
+ getPath(): string {
22
+ return this.getArgument(0).asString().getValue()
23
+ }
24
+
25
+ getAbsolutePath(): string {
26
+ return this.getIncludedFile().getPath()
27
+ }
28
+
29
+ getRelativePathFrom(node: ts.Node): string {
30
+ return pathModule.relative(pathModule.dirname(node.getSourceFile().getFilePath()), this.getAbsolutePath())
31
+ }
32
+
33
+ getIncludedFile(): ProjectFile {
34
+ return this.includedFile
35
+ }
36
+
37
+ override getValue(): string {
38
+ return this.getIncludedFile().getContent()
39
+ }
40
+
41
+ override toString(): StringShape {
42
+ return Shape.from(this, this.getValue()).asString().withContentType('cdata')
43
+ }
44
+ }
45
+
46
+ export const NowIncludePlugin = Plugin.create({
47
+ name: 'NowIncludePlugin',
48
+ shapes: [
49
+ {
50
+ shape: CallExpressionShape,
51
+ fileTypes: ['fluent'],
52
+ toSubclass(callExpression, { diagnostics, project }) {
53
+ if (callExpression.getCallee() !== 'Now.include') {
54
+ return { success: false }
55
+ }
56
+
57
+ const arg = callExpression.getArgument(0)
58
+ if (!arg.isString()) {
59
+ diagnostics.error(arg, 'Now.include() must have a string argument')
60
+ return { success: false }
61
+ }
62
+
63
+ const path = arg.getValue()
64
+
65
+ if (!/^\.\.?\/.*$/.test(path.trim()) && path.includes('/')) {
66
+ diagnostics.error(arg, 'Now.include() argument must be a relative path')
67
+ return { success: false }
68
+ }
69
+
70
+ const absolutePath = pathModule.resolve(pathModule.dirname(callExpression.getOriginalFilePath()), path)
71
+ if (!project.isInRootDir(absolutePath)) {
72
+ diagnostics.error(arg, `Included file path is not within project: ${absolutePath}`)
73
+ return { success: false }
74
+ }
75
+
76
+ let includedFile: ProjectFile
77
+ try {
78
+ includedFile = project.addFile(absolutePath, {
79
+ resolveDependencies: false,
80
+ excludeFromCompiler: true,
81
+ })
82
+ } catch (e) {
83
+ diagnostics.error(arg, `Failed to include file. Reason: ${e instanceof Error ? e.message : e}`)
84
+ return { success: false }
85
+ }
86
+
87
+ return {
88
+ success: true,
89
+ value: new NowIncludeShape({ source: callExpression, path, includedFile }),
90
+ }
91
+ },
92
+ },
93
+ {
94
+ shape: NowIncludeShape,
95
+ async commit(shape, target, { transform, commit }) {
96
+ const targetResult = await transform.toShape(target)
97
+ if (!targetResult.success) {
98
+ return { success: false }
99
+ }
100
+
101
+ const { value: targetShape } = targetResult
102
+ if (targetShape.is(NowIncludeShape)) {
103
+ if (targetShape.getAbsolutePath() === shape.getAbsolutePath()) {
104
+ // It's already a Now.include() call pointing to the same file, so nothing to do
105
+ return { success: true }
106
+ }
107
+ } else {
108
+ if (targetShape.equals(shape.getIncludedFile().getContent())) {
109
+ // It's not a Now.include() call, but it's equivalent to the content, so leave it (probably an inline string literal)
110
+ return { success: true }
111
+ }
112
+ }
113
+
114
+ await commit(shape, target, CallExpressionPlugin)
115
+ return { success: true }
116
+ },
117
+ },
118
+ {
119
+ shape: StringShape,
120
+ async commit(shape, target, { transform }) {
121
+ const targetResult = await transform.toShape(target)
122
+ if (!targetResult.success) {
123
+ return { success: false }
124
+ }
125
+
126
+ const targetShape = targetResult.value.ifIdentifier()?.resolve() ?? targetResult.value
127
+ if (!targetShape.is(NowIncludeShape)) {
128
+ return { success: false }
129
+ }
130
+
131
+ const file = targetShape.getIncludedFile()
132
+ if (!shape.equals(file.getContent())) {
133
+ file.setContent(shape.getValue())
134
+ }
135
+
136
+ return { success: true }
137
+ },
138
+ },
139
+ ],
140
+ })
@@ -0,0 +1,48 @@
1
+ import { Plugin, CallExpressionShape, StringShape, ObjectShape } from '@servicenow/sdk-build-core'
2
+ import { CallExpressionPlugin } from './call-expression-plugin'
3
+
4
+ export const NowRefPlugin = Plugin.create({
5
+ name: 'NowRefPlugin',
6
+ nodes: [
7
+ {
8
+ node: 'CallExpression',
9
+ async toShape(node, { transform, factory }) {
10
+ const result = await transform.toShape(node, CallExpressionPlugin)
11
+ if (
12
+ !result.success ||
13
+ !result.value.is(CallExpressionShape) ||
14
+ result.value.getCallee() !== 'Now.ref'
15
+ ) {
16
+ return { success: false }
17
+ }
18
+
19
+ const callExpression = result.value
20
+ const table = callExpression
21
+ .getArgument(0)
22
+ .asString('The first argument to Now.ref() must be a table name')
23
+ const guidOrKeys = callExpression
24
+ .getArgument(1)
25
+ .as(
26
+ [StringShape, ObjectShape],
27
+ 'The second argument to Now.ref() must be a GUID or a coalesce keys object'
28
+ )
29
+ const maybeKeys = callExpression.hasArgument(2)
30
+ ? callExpression
31
+ .getArgument(2)
32
+ .asObject('The third argument to Now.ref() must be a coalesce keys object')
33
+ : undefined
34
+
35
+ const [guid, keys] = maybeKeys
36
+ ? [guidOrKeys.asString(), maybeKeys] // Now.ref(table, guid, keys)
37
+ : guidOrKeys.isString()
38
+ ? [guidOrKeys.asString(), undefined] // Now.ref(table, guid)
39
+ : [undefined, guidOrKeys.asObject()] // Now.ref(table, keys)
40
+
41
+ return {
42
+ success: true,
43
+ value: factory.createReference({ source: node, table, guid, keys }),
44
+ }
45
+ },
46
+ },
47
+ ],
48
+ })
@@ -0,0 +1,30 @@
1
+ import { Plugin, UnresolvedShape } from '@servicenow/sdk-build-core'
2
+
3
+ export const NowUnresolvedPlugin = Plugin.create({
4
+ name: 'NowUnresolvedPlugin',
5
+ shapes: [
6
+ {
7
+ shape: UnresolvedShape,
8
+ commit(shape, target) {
9
+ target.replaceWithText(shape.getCode())
10
+ return { success: true }
11
+ },
12
+ },
13
+ ],
14
+ nodes: [
15
+ {
16
+ node: 'PropertyAccessExpression',
17
+ fileTypes: ['fluent'],
18
+ toShape(node) {
19
+ if (node.getText() !== UnresolvedShape.CODE) {
20
+ return { success: false }
21
+ }
22
+
23
+ return {
24
+ success: true,
25
+ value: new UnresolvedShape({ source: node }),
26
+ }
27
+ },
28
+ },
29
+ ],
30
+ })
@@ -0,0 +1,87 @@
1
+ import {
2
+ type FileSystem,
3
+ type Logger,
4
+ path as pathModule,
5
+ Plugin,
6
+ type ObjectShape,
7
+ Shape,
8
+ } from '@servicenow/sdk-build-core'
9
+ import { RepackService } from './repack'
10
+ import { JsonFileShape } from './json-plugin'
11
+
12
+ export const PackageJsonPlugin = Plugin.create({
13
+ name: 'PackageJsonPlugin',
14
+ shapes: [
15
+ {
16
+ shape: JsonFileShape,
17
+ async toRecord(file, { config, packageJson, project, factory, fs, logger }) {
18
+ if (file.getBaseName() !== 'package.json') {
19
+ return { success: false }
20
+ }
21
+
22
+ const relativePath = pathModule.relative(project.getRootDir(), file.getPath())
23
+ const sysModulePath = pathModule.join(config.scope, packageJson.name, packageJson.version, relativePath)
24
+
25
+ const sbomRecord = factory.createRecord({
26
+ source: file,
27
+ table: 'sys_module',
28
+ explicitId: 'bom_json',
29
+ properties: {
30
+ path: pathModule.join(config.scope, packageJson.name, packageJson.version, 'bom.json'),
31
+ external_source: false,
32
+ },
33
+ })
34
+
35
+ return {
36
+ success: true,
37
+ value: factory
38
+ .createRecord({
39
+ source: file,
40
+ table: 'sys_module',
41
+ explicitId: relativePath.replaceAll(/[./\\]/g, '_'),
42
+ properties: {
43
+ // Module resolution at runtime requires this format
44
+ path: sysModulePath,
45
+ content: Shape.from(
46
+ file,
47
+ await fixDependencyVersion(file.getJson(), {
48
+ fs,
49
+ logger,
50
+ rootDir: project.getRootDir(),
51
+ })
52
+ )
53
+ .asString()
54
+ .withContentType('cdata'),
55
+ external_source: false,
56
+ sys_name: sysModulePath,
57
+ },
58
+ })
59
+ .with(sbomRecord),
60
+ }
61
+ },
62
+ },
63
+ ],
64
+ })
65
+
66
+ async function fixDependencyVersion(json: ObjectShape, context: { fs: FileSystem; logger: Logger; rootDir: string }) {
67
+ const deps = json.get('dependencies').ifObject()
68
+ if (!deps) {
69
+ return JSON.stringify(json.getValue(), null, 2)
70
+ }
71
+
72
+ const repack = await RepackService.create(context.logger, context.fs, context.rootDir)
73
+ const resolvedDeps = {}
74
+ for (const dep of deps.keys()) {
75
+ const { name, version } = await repack.getResolvedDepDetails(dep)
76
+ resolvedDeps[name] = version
77
+ }
78
+
79
+ return JSON.stringify(
80
+ {
81
+ ...json.getValue(),
82
+ dependencies: resolvedDeps,
83
+ },
84
+ null,
85
+ 2
86
+ )
87
+ }
@@ -0,0 +1,118 @@
1
+ import { isSNScope } from '@servicenow/sdk-build-core'
2
+ import { CallExpressionShape, Plugin, type Shape } from '@servicenow/sdk-build-core'
3
+ import { NowIdShape } from './now-id-plugin'
4
+
5
+ const getRolesArray = (roles: string): Array<string> => {
6
+ return roles
7
+ .split(',')
8
+ .map((role) => role.trim())
9
+ .filter((role) => role)
10
+ }
11
+
12
+ export const PropertyPlugin = Plugin.create({
13
+ name: 'PropertyPlugin',
14
+ records: {
15
+ sys_properties: {
16
+ toShape(record, { config }) {
17
+ return {
18
+ success: true,
19
+ value: new CallExpressionShape({
20
+ source: record,
21
+ callee: 'Property',
22
+ args: [
23
+ record.transform(({ $ }) => ({
24
+ $id: $.val(NowIdShape.from(record)),
25
+ name: $.from('name', 'suffix').map(
26
+ (name, suffix) =>
27
+ name.ifString() ??
28
+ (config.scope === 'global'
29
+ ? suffix
30
+ : `${config.scope}.${suffix.asString().getValue()}`)
31
+ ),
32
+ value: $,
33
+ description: $.def(''),
34
+ type: $.def('string'),
35
+ choices: $.map((c) => {
36
+ const value = c.toString().getValue()
37
+ return value
38
+ .split(/[,\n]/)
39
+ .map((v) => v.trim())
40
+ .filter((v) => v)
41
+ }).def([]),
42
+ isPrivate: $.from('is_private').toBoolean().def(false),
43
+ ignoreCache: $.from('ignore_cache').toBoolean().def(false),
44
+ roles: $.from('read_roles', 'write_roles')
45
+ .def({ read: [], write: [] })
46
+ .map((r, w) => ({
47
+ read: r.ifString()?.pipe((v) => getRolesArray(v.getValue())),
48
+ write: w.ifString()?.pipe((v) => getRolesArray(v.getValue())),
49
+ })),
50
+ })),
51
+ ],
52
+ }),
53
+ }
54
+ },
55
+ },
56
+ },
57
+ shapes: [
58
+ {
59
+ shape: CallExpressionShape,
60
+ fileTypes: ['fluent'],
61
+ async toRecord(callExpression, { config, diagnostics, factory }) {
62
+ if (callExpression.getCallee() !== 'Property') {
63
+ return { success: false }
64
+ }
65
+
66
+ const prop = callExpression.getArgument(0).asObject()
67
+ const scope = config.scope
68
+ const name = prop.get('name').asString()
69
+
70
+ if (!isSNScope(scope) && config.scope !== 'global' && !name.asString().startsWith(`${scope}.`)) {
71
+ diagnostics.error(name.getOriginalNode(), `Property name must begin with '${scope}.'`)
72
+ }
73
+
74
+ return {
75
+ success: true,
76
+ value: factory.createRecord({
77
+ source: callExpression,
78
+ table: 'sys_properties',
79
+ explicitId: prop.get('$id'),
80
+ properties: prop.transform(({ $, merge }) => ({
81
+ name: $,
82
+ suffix: $.from('name').map((v) =>
83
+ v.asString().replace(new RegExp(`^${config.scope}\\.`), '')
84
+ ),
85
+ description: $,
86
+ type: $.def('string'),
87
+ value: $.toString(), // TODO: Should be allowed to assign non-strings to string properties
88
+ is_private: $.from('isPrivate').def(false),
89
+ ignore_cache: $.from('ignoreCache').def(false),
90
+ choices: $.map((v) => v.ifArray()?.getValue().join(',')),
91
+ [merge]: $.from('roles')
92
+ .def({ read_roles: '', write_roles: '' })
93
+ .map((v) =>
94
+ v
95
+ .ifObject()
96
+ ?.transform(({ $ }) => ({
97
+ read_roles: $.from('read').map((r) => getRolesString(r)),
98
+ write_roles: $.from('write').map((r) => getRolesString(r)),
99
+ }))
100
+ .properties()
101
+ ),
102
+ })),
103
+ }),
104
+ }
105
+ },
106
+ },
107
+ ],
108
+ })
109
+
110
+ function getRolesString(roles: Shape): string | undefined {
111
+ return roles
112
+ .ifArray()
113
+ ?.pipe((r) =>
114
+ Array.from(new Set(r.getElements().map((r) => r.ifRecord()?.get('name').getValue() ?? r.getValue()))).join(
115
+ ','
116
+ )
117
+ )
118
+ }
@@ -0,0 +1,171 @@
1
+ import { CallExpressionShape, Plugin } from '@servicenow/sdk-build-core'
2
+ import { unloadBuilder } from '@servicenow/sdk-build-core'
3
+ import { NowIdShape } from './now-id-plugin'
4
+ import {
5
+ Acl,
6
+ ApplicationMenu,
7
+ BusinessRule,
8
+ CrossScopePrivilege,
9
+ Property,
10
+ Role,
11
+ Test,
12
+ UserPreference,
13
+ } from '@servicenow/sdk-core/runtime/app'
14
+ import {
15
+ SPWidget,
16
+ SPAngularProvider,
17
+ SPWidgetDependency,
18
+ CssInclude,
19
+ JsInclude,
20
+ } from '@servicenow/sdk-core/runtime/service-portal'
21
+ import { ClientScript } from '@servicenow/sdk-core/runtime/clientscript'
22
+ import { ScriptAction, ScriptInclude } from '@servicenow/sdk-core/runtime/sys'
23
+ import { List } from '@servicenow/sdk-core/runtime/ui'
24
+ import { Table } from '@servicenow/sdk-core/runtime/db'
25
+ import { RestApi } from '@servicenow/sdk-core/runtime/rest'
26
+ import { UiAction, UiPage } from '@servicenow/sdk-core/runtime/ui'
27
+
28
+ export const RecordPlugin = Plugin.create({
29
+ name: 'RecordPlugin',
30
+ records: {
31
+ '*': {
32
+ toShape(record) {
33
+ return {
34
+ success: true,
35
+ value: new CallExpressionShape({
36
+ source: record,
37
+ callee: 'Record',
38
+ args: [
39
+ {
40
+ $id: NowIdShape.from(record),
41
+ table: record.getTable(),
42
+ data: record.transform(
43
+ ({ $ }) =>
44
+ Object.fromEntries(
45
+ record
46
+ .keys()
47
+ .map((key) => [key, record.get(key).isString() ? $.def('') : $])
48
+ ) //to avoid writing empty string values to the code
49
+ ),
50
+ },
51
+ ],
52
+ }),
53
+ }
54
+ },
55
+ toFile(record, { config }) {
56
+ const recordBuilder = unloadBuilder(config)
57
+ const table = record.getTable()
58
+ const guid = record.getId().getValue()
59
+ const builder = recordBuilder.record(record)
60
+
61
+ record
62
+ .entries()
63
+ .sort(([a], [b]) => a.localeCompare(b)) // Sort keys to make outputs more deterministic
64
+ .forEach(([prop, shape]) => builder.field(prop, shape))
65
+
66
+ return {
67
+ success: true,
68
+ value: {
69
+ name: `${table}_${guid}.xml`,
70
+ category: record.getInstallCategory(),
71
+ content: recordBuilder.end(),
72
+ },
73
+ }
74
+ },
75
+ },
76
+ },
77
+ shapes: [
78
+ {
79
+ shape: CallExpressionShape,
80
+ fileTypes: ['fluent'],
81
+ toRecord(callExpression, { factory, diagnostics }) {
82
+ if (callExpression.getCallee() !== 'Record') {
83
+ return { success: false }
84
+ }
85
+
86
+ const record = callExpression.getArgument(0).asObject()
87
+ const table = record.get('table').asString().getValue()
88
+ const tableOwningPlugin = TableOwnership[table]
89
+ if (tableOwningPlugin) {
90
+ diagnostics.hint(
91
+ callExpression,
92
+ `For a better experience, consider using the ${tableOwningPlugin} API`
93
+ )
94
+ }
95
+ return {
96
+ success: true,
97
+ value: factory.createRecord({
98
+ source: callExpression,
99
+ table,
100
+ explicitId: record.get('$id'),
101
+ properties: record.get('data').asObject(),
102
+ }),
103
+ }
104
+ },
105
+ },
106
+ ],
107
+ files: [
108
+ {
109
+ matcher: /\.xml$/,
110
+ toRecord(file, { parser, logger }) {
111
+ try {
112
+ const [first, ...rest] = parser.parsePayload(file)
113
+
114
+ if (!first) {
115
+ return { success: false }
116
+ }
117
+
118
+ return {
119
+ success: true,
120
+ value: first.with(...rest),
121
+ }
122
+ } catch (e) {
123
+ logger.debug(e)
124
+ return { success: false }
125
+ }
126
+ },
127
+ },
128
+ ],
129
+ })
130
+
131
+ export const TableOwnership = {
132
+ sys_security_acl: Acl.name,
133
+ sys_security_acl_role: Acl.name,
134
+ sys_app_application: ApplicationMenu.name,
135
+ sys_script: BusinessRule.name,
136
+ sys_script_client: ClientScript.name,
137
+ sys_scope_privilege: CrossScopePrivilege.name,
138
+ sys_ui_list_element: List.name,
139
+ sys_ui_list: List.name,
140
+ sys_properties: Property.name,
141
+ sys_user_role: Role.name,
142
+ sys_user_role_contains: Role.name,
143
+ sys_script_include: ScriptInclude.name,
144
+ sp_widget: SPWidget.name,
145
+ m2m_sp_widget_dependency: SPWidget.name,
146
+ m2m_sp_ng_pro_sp_widget: SPWidget.name,
147
+ sp_ng_template: SPWidget.name,
148
+ sp_dependency: SPWidgetDependency.name,
149
+ m2m_sp_dependency_css_include: SPWidgetDependency.name,
150
+ m2m_sp_dependency_js_include: SPWidgetDependency.name,
151
+ sp_css_include: CssInclude.name,
152
+ sp_js_include: JsInclude.name,
153
+ sp_angular_provider: SPAngularProvider.name,
154
+ m2m_sp_ng_pro_sp_ng_pro: SPAngularProvider.name,
155
+ sys_atf_test: Test.name,
156
+ sys_ws_header_map: RestApi.name,
157
+ sys_ws_query_parameter_map: RestApi.name,
158
+ sys_ws_definition: RestApi.name,
159
+ sys_ws_operation: RestApi.name,
160
+ sys_ws_version: RestApi.name,
161
+ sys_ws_header: RestApi.name,
162
+ sys_ws_query_parameter: RestApi.name,
163
+ sys_user_preference: UserPreference.name,
164
+ sys_ui_page: UiPage.name,
165
+ sys_ui_action: UiAction.name,
166
+ sys_ui_action_role: UiAction.name,
167
+ sys_ui_action_view: UiAction.name,
168
+ sysevent_script_action: ScriptAction.name,
169
+ sys_db_object: Table.name,
170
+ sys_dictionary: Table.name,
171
+ }