@servicenow/sdk-build-plugins 3.0.3 → 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 -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,257 +0,0 @@
1
- import { ClientScript } from '@servicenow/sdk-core/runtime/clientscript'
2
- import {
3
- Context,
4
- Plugin,
5
- extractCallExpression,
6
- getCallExpressionName,
7
- removeNode,
8
- getOrCreateEntitySourceFile,
9
- generateCallExpressionExportForDocument,
10
- linkDocument,
11
- mergeDataIntoObjectLiteral,
12
- writeCustomProperty,
13
- stringify,
14
- getSysUpdateName,
15
- FluentDiagnostic,
16
- EntityData,
17
- ObjectData,
18
- transformCustomizedProperties,
19
- } from '@servicenow/sdk-build-core'
20
- import { Record } from '@servicenow/sdk-core/runtime/db'
21
- import { ClientScriptSchema } from '@servicenow/sdk-core/runtime/clientscript'
22
- import { z } from 'zod'
23
- import { ts } from '@servicenow/sdk-project'
24
- import { processScript } from '../ScriptTemplatePlugin'
25
- import { Diagnostic } from '@servicenow/sdk-project'
26
- import { except } from './scriptUtils'
27
- import { additionalProperties } from '@servicenow/sdk-core/runtime/util'
28
-
29
- const UITypeMapping = {
30
- desktop: 0,
31
- mobile_or_service_portal: 1,
32
- all: 10,
33
- }
34
- const ClientScriptXmlSchema = ClientScriptSchema.extend({
35
- table: z.string(),
36
- ui_type: z.union([z.literal(0), z.literal(1), z.literal(10)]),
37
- sys_class_name: z.literal('sys_script_client'),
38
- })
39
- const PartialClientScriptXMLSchema = ClientScriptXmlSchema.partial()
40
-
41
- type ClientScriptSchema = z.infer<typeof ClientScriptSchema>
42
- type PatialClientScriptConfig = z.infer<typeof PartialClientScriptXMLSchema>
43
-
44
- export default Plugin({
45
- name: 'ClientScript',
46
- ownedTables: {
47
- sys_script_client: { diagnosticLevel: Diagnostic.Level.Warn },
48
- },
49
- extractors: {
50
- entity: {
51
- fluent: {
52
- CallExpression: (node, context) => {
53
- const result = extractCallExpression(ClientScript, 'clientScript', node, context, (script) =>
54
- context.registerExplicitId('sys_script_client', script.$id as string)
55
- )
56
-
57
- if (!result.handled || !result.data) {
58
- return result
59
- }
60
-
61
- const clientScriptEntityData = result.data
62
- const args = node.getArguments()[0] as ts.ObjectLiteralExpression
63
-
64
- if (!args) {
65
- result.diagnostics.push(new FluentDiagnostic(node, 'Client script arguments are missing'))
66
- return result
67
- }
68
-
69
- const diagnostics = result.diagnostics
70
- const data = ClientScriptSchema.and(z.any()).parse(clientScriptEntityData.getValue())
71
- const { script, type, field } = data
72
-
73
- if (field && !type) {
74
- diagnostics.push(
75
- new FluentDiagnostic(
76
- args.getProperty('field')!,
77
- `Field values are allowed only when type is set to onChange or onCellEdit`
78
- )
79
- )
80
- }
81
-
82
- if (script && !validateClientSideScripts(script, context)) {
83
- diagnostics.push(
84
- new FluentDiagnostic(
85
- args.getProperty('script')!,
86
- `Client side scripts cannot import or require modules.`
87
- )
88
- )
89
- }
90
-
91
- /**
92
- * Removing this diagnostic : Currently on instance if you empty script field and click update, it would show basic template set
93
- * for the field but the xml is not updated. Only after saving it again the xml gets updated with basic template.
94
- */
95
- // if (type && !script) {
96
- // diagnostics.push(
97
- // new FluentDiagnostic(
98
- // args.getProperty('type')!,
99
- // `Cannot have empty script value for type: ${type}`
100
- // )
101
- // )
102
- // }
103
-
104
- const record = createClientScriptRecord(data, script)
105
-
106
- return {
107
- handled: true,
108
- diagnostics,
109
- data: new EntityData(
110
- 'record',
111
- clientScriptEntityData.getGuid(),
112
- ObjectData.fromObjectValue(record, node),
113
- node,
114
- clientScriptEntityData.getInstallMethod(),
115
- clientScriptEntityData.getExplicitIds()
116
- ),
117
- }
118
- },
119
- },
120
- },
121
- },
122
-
123
- generators: {
124
- record(document, context) {
125
- const tableName = document.data!['table']
126
- if (tableName !== 'sys_script_client') {
127
- return undefined
128
- }
129
-
130
- return linkDocument(
131
- document,
132
- generateCallExpressionExportForDocument(
133
- context,
134
- {
135
- sourceFile: getOrCreateEntitySourceFile(
136
- context,
137
- getSysUpdateName(document, 'sys_script_client')
138
- ),
139
- moduleSpecifier: '@servicenow/sdk/core',
140
- },
141
- ClientScript,
142
- {
143
- $id: document.guid,
144
- }
145
- ).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
146
- )
147
- },
148
- },
149
-
150
- transformers: {
151
- record: {
152
- CallExpression(document) {
153
- if (getCallExpressionName(document.node) !== ClientScript.name) {
154
- return false
155
- }
156
-
157
- if (document.action === 'DELETE') {
158
- removeNode(document.node)
159
- return true
160
- }
161
-
162
- const modifiedClientScriptProps = ClientScriptXmlSchema.partial().safeParse(
163
- (document.changedData as any).data
164
- )
165
-
166
- if (!modifiedClientScriptProps.success) {
167
- return false
168
- }
169
-
170
- transformCustomizedProperties(
171
- ClientScript,
172
- document.node,
173
- (document.changedData as any).data,
174
- modifiedClientScriptProps.data
175
- )
176
-
177
- return transformClientScriptArguments(
178
- document.node,
179
- except(modifiedClientScriptProps.data, (key) => key === 'sys_class_name')
180
- )
181
- },
182
- },
183
- },
184
- })
185
-
186
- function validateClientSideScripts(script: string, context: Context) {
187
- const source = context.compiler.createSourceFile('tmp-file.ts', script)
188
- const importDeclarations = source.getDescendantsOfKind(ts.SyntaxKind.ImportDeclaration)
189
- const requireCalls = source.getDescendantsOfKind(ts.SyntaxKind.CallExpression).filter((callExpression) => {
190
- return isRequire(callExpression)
191
- })
192
- const isValid = !(importDeclarations.length > 0 || requireCalls.length > 0)
193
- context.compiler.removeSourceFile(source)
194
- return isValid
195
- }
196
-
197
- function getUITypeFromId(id: number) {
198
- const type = Object.keys(UITypeMapping).find((e) => UITypeMapping[e] === id)
199
- if (!type) {
200
- throw Error('Invalid UI Type encountered, check XML data before transforming again.')
201
- }
202
- return type
203
- }
204
-
205
- function transformClientScriptArguments(node: ts.CallExpression, data: PatialClientScriptConfig) {
206
- const argNode = node.getArguments()[0]!.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
207
- const { script, table, ui_type, type, ...rest } = data
208
-
209
- if (type !== undefined) {
210
- if (type) {
211
- writeCustomProperty(argNode, 'type', '', stringify(type))
212
- } else {
213
- argNode.getProperty('type')?.remove()
214
- }
215
- }
216
-
217
- if (Object.values(UITypeMapping).some((value) => value === ui_type)) {
218
- const uiType = getUITypeFromId(ui_type!)
219
- writeCustomProperty(argNode, 'ui_type', '', stringify(uiType))
220
- }
221
-
222
- if (table) {
223
- writeCustomProperty(argNode, 'table', '{}', stringify(table))
224
- }
225
-
226
- if (script !== undefined) {
227
- processScript(argNode, 'script', script)
228
- }
229
-
230
- mergeDataIntoObjectLiteral(argNode, rest)
231
-
232
- return true
233
- }
234
-
235
- function createClientScriptRecord(data: ClientScriptSchema, script: string) {
236
- data.script = script as any
237
- const { $id, ...csData } = ClientScriptSchema.parse(data)
238
- const rest = additionalProperties(data, ClientScriptSchema)
239
- csData.ui_type = getUITypeId(csData.ui_type)
240
- return Record({
241
- table: 'sys_script_client',
242
- $id,
243
- data: { ...(csData as any), ...rest },
244
- })
245
- }
246
-
247
- function getUITypeId(value: string) {
248
- if (value in UITypeMapping) {
249
- return UITypeMapping[value]
250
- }
251
- throw Error('Invalid ui_type found in xml')
252
- }
253
-
254
- function isRequire(callExpression: ts.CallExpression): boolean {
255
- const expression = callExpression.getExpression()
256
- return ts.Node.isIdentifier(expression) && expression.getText() === 'require'
257
- }
@@ -1,5 +0,0 @@
1
- export function except(obj: object, excludePredicate: (string) => boolean) {
2
- return Object.keys(obj)
3
- .filter((k) => !excludePredicate(k))
4
- .reduce((acc, k) => ({ ...acc, [k]: obj[k] }), {})
5
- }
@@ -1,67 +0,0 @@
1
- import { Experience, ExperienceSchema } from '@servicenow/sdk-core/runtime/experience'
2
- import { Record } from '@servicenow/sdk-core/runtime/db'
3
- import { Plugin, extractCallExpression } from '@servicenow/sdk-build-core'
4
- import { PARENT_APP_SHELL_ID, WORKSPACE_APP_SHELL_ID } from './constants'
5
-
6
- export default Plugin({
7
- name: 'Experience',
8
- ownedTables: {
9
- //TODO:: Uncomment below config once we start supporting Experience plugin.
10
- //sys_ux_app_config: { diagnosticLevel: Diagnostic.Level.Warn },
11
- },
12
- extractors: {
13
- entity: {
14
- fluent: {
15
- CallExpression: (node, context) =>
16
- extractCallExpression(Experience, 'experience', node, context, (experience) =>
17
- context.registerExplicitId('sys_ux_app_config', experience.$id as string)
18
- ),
19
- },
20
- },
21
- },
22
- composers: {
23
- entity: {
24
- experience(entity, context) {
25
- const node = entity.getNode()
26
- const data = entity.getValue()
27
- const guid = entity.getGuid()
28
- const recordData = ExperienceSchema.parse(data)
29
-
30
- const appConfig = Record({
31
- table: 'sys_ux_app_config',
32
- $id: guid,
33
- data: {
34
- name: recordData.name,
35
- active: recordData.active,
36
- base_url_path: recordData.baseUrlPath,
37
- landing_path: recordData.landingPath,
38
- description: recordData.description,
39
- },
40
- })
41
-
42
- const pageRegistry = Record({
43
- table: 'sys_ux_page_registry',
44
- $id: context.registerExplicitId('sys_ux_page_registry', `${guid}_registry`),
45
- data: {
46
- title: recordData.name,
47
- active: recordData.active,
48
- admin_panel: appConfig.$id as any,
49
- admin_panel_table: 'sys_ux_app_config',
50
- parent_app: PARENT_APP_SHELL_ID,
51
- path: recordData.baseUrlPath,
52
- root_macroponent: WORKSPACE_APP_SHELL_ID,
53
- },
54
- })
55
-
56
- return Promise.resolve(
57
- [appConfig, pageRegistry].map((r) => ({
58
- kind: 'record',
59
- guid: r.$id,
60
- node,
61
- data: r,
62
- }))
63
- )
64
- },
65
- },
66
- },
67
- })
@@ -1,211 +0,0 @@
1
- import { BaseUXRouteSchema, ExperienceSchema, Routes } from '@servicenow/sdk-core/runtime/experience'
2
- import { Record } from '@servicenow/sdk-core/runtime/db'
3
- import { Plugin, extractCallExpression } from '@servicenow/sdk-build-core'
4
- import { parser as uxValueParser, cleanUxValue } from './UxfFormulaParser'
5
- import { idGenerator } from './tectonicIdGenerator'
6
- import { WORKSPACE_APP_SHELL_ID } from './constants'
7
- import { Diagnostic } from '@servicenow/sdk-project'
8
-
9
- const PAGE_TEMPLATE_SYS_ID = '19be392623033300f4b4c50947bf65ba'
10
- type Component = Routes['routes'][string]['component']
11
-
12
- type RouteParts = {
13
- pathname: string
14
- parameters: {
15
- required: string[]
16
- optional: string[]
17
- }
18
- }
19
-
20
- function getRouteParts(route: string): RouteParts {
21
- const chunks = route.split('/').filter((chunk) => chunk && chunk.length > 0)
22
- if (chunks.length === 0) {
23
- throw new Error('Invalid route - routes may not be empty')
24
- }
25
-
26
- const parts: RouteParts = {
27
- pathname: chunks[0] || '',
28
- parameters: {
29
- required: [],
30
- optional: [],
31
- },
32
- }
33
-
34
- chunks.forEach((part) => {
35
- if (part.startsWith(':')) {
36
- if (part.endsWith('?')) {
37
- parts.parameters.optional.push(part.slice(1, -1))
38
- } else {
39
- parts.parameters.required.push(part.slice(1))
40
- }
41
- }
42
- })
43
-
44
- return parts
45
- }
46
-
47
- const HARDCODED_LAYOUT = {
48
- default: {
49
- children: null,
50
- items: [{ element_id: 'x', styles: {} }],
51
- root: null,
52
- rules: null,
53
- styles: { 'flex-direction': 'column' },
54
- templateId: '5832fd4d53c31010e6bcddeeff7b12db',
55
- type: 'flex',
56
- },
57
- version: '3.0.0',
58
- }
59
-
60
- const createComposition = (component: Component) => {
61
- const { tagName, properties = {} } = component
62
- const componentId = idGenerator(tagName)
63
-
64
- const UxfFormulaParser = new uxValueParser()
65
- const propertyValues = Object.keys(properties).reduce((newObj, key) => {
66
- const parseResult = UxfFormulaParser.parse(properties[key])
67
- if (parseResult.errors.length) {
68
- throw new Error('Failed to parse formula.')
69
- }
70
- newObj[key] = cleanUxValue(parseResult.result.uxValue)
71
- return newObj
72
- }, {})
73
-
74
- return [
75
- {
76
- definition: { id: componentId, type: 'MACROPONENT' },
77
- elementId: 'x',
78
- elementLabel: tagName,
79
- eventMappings: [],
80
- isHidden: { type: 'JSON_LITERAL', value: null },
81
- preset: null,
82
- propertyValues,
83
- slot: null,
84
- styles: null,
85
- },
86
- ]
87
- }
88
-
89
- export default Plugin({
90
- name: 'Routes',
91
- ownedTables: {
92
- sys_ux_app_route: { diagnosticLevel: Diagnostic.Level.Warn },
93
- },
94
- extractors: {
95
- entity: {
96
- fluent: {
97
- // TODO: This needs to extract separate entities for each route and the experience. Currently it is extracting an
98
- // anonymous "container" entity which goes against the design of the plugin architecture.
99
- CallExpression: (node, context) =>
100
- extractCallExpression(Routes, 'routes', node, context, () => 'NO_GUID_GENERATED'), // TODO: Generate GUID
101
- },
102
- },
103
- },
104
- composers: {
105
- entity: {
106
- routes(entity, context) {
107
- const node = entity.getNode()
108
- const experience = entity.getPropertyOrThrow('experience').getValue() as Routes['experience']
109
- const routes = entity.getPropertyOrThrow('routes').getValue() as Routes['routes']
110
-
111
- const { $id: appConfigId } = ExperienceSchema.parse(experience)
112
- const appConfigSysId = context.registerExplicitId('sys_ux_app_config', appConfigId)
113
-
114
- const records: Record[] = []
115
- for (const [path, route] of Object.entries(routes)) {
116
- const { $id: routeId, name, component, active, description } = BaseUXRouteSchema.parse(route)
117
- const routeParts = getRouteParts(path)
118
-
119
- const screenType = Record({
120
- table: 'sys_ux_screen_type',
121
- $id: context.registerExplicitId('sys_ux_screen_type', `${routeId}_screen_type`),
122
- data: {
123
- name,
124
- },
125
- })
126
-
127
- const routeRecord = Record({
128
- table: 'sys_ux_app_route',
129
- $id: context.registerExplicitId('sys_ux_app_route', routeId),
130
- data: {
131
- name,
132
- app_config: appConfigSysId,
133
- route_type: routeParts.pathname,
134
- fields: routeParts.parameters.required.join(','),
135
- optional_parameters: routeParts.parameters.optional.join(','),
136
- screen_type: screenType.$id,
137
- },
138
- })
139
-
140
- const routeParameters = [...routeParts.parameters.required, ...routeParts.parameters.optional]
141
- const screenMcp = Record({
142
- table: 'sys_ux_macroponent',
143
- $id: context.registerExplicitId('sys_ux_macroponent', `${routeId}_page`),
144
- data: {
145
- category: 'page',
146
- composition: JSON.stringify(createComposition(component), null, 2),
147
- extends: PAGE_TEMPLATE_SYS_ID,
148
- internal_event_mappings: JSON.stringify({}),
149
- layout: JSON.stringify(HARDCODED_LAYOUT, null, 2),
150
- name: `${name} - Page`,
151
- // Injecting Route parameters as props of the page, so that they can be passed into the
152
- // component in the composition.
153
- props: JSON.stringify(
154
- routeParameters.map((param) => {
155
- return {
156
- defaultValue: '',
157
- description: null,
158
- disabled: false,
159
- fieldType: 'string',
160
- label: param,
161
- mandatory: false,
162
- name: param,
163
- readOnly: true,
164
- selectable: false,
165
- typeMetadata: null,
166
- valueType: 'string',
167
- }
168
- }),
169
- null,
170
- 2
171
- ),
172
- schema_version: '1.0.0',
173
- },
174
- })
175
-
176
- // TODO(patrick): Still a lot of hardcoded stuff in here - needs
177
- // to be represented in the config, at least optionally.
178
- const screen = Record({
179
- table: 'sys_ux_screen',
180
- $id: context.registerExplicitId('sys_ux_screen', `${routeId}_screen`),
181
- data: {
182
- active: active!,
183
- app_config: appConfigSysId,
184
- description: description!,
185
- disable_auto_reflow: false,
186
- event_mappings: JSON.stringify([]),
187
- macroponent: screenMcp.$id,
188
- macroponent_config: JSON.stringify({}),
189
- name: `${name} - Default`,
190
- order: 0,
191
- parent_macroponent: WORKSPACE_APP_SHELL_ID,
192
- required_translations: JSON.stringify([]),
193
- screen_type: screenType.$id,
194
- },
195
- })
196
-
197
- records.push(screenType, routeRecord, screenMcp, screen)
198
- }
199
-
200
- return Promise.resolve(
201
- records.map((r) => ({
202
- kind: 'record',
203
- guid: r.$id as string,
204
- node,
205
- data: r,
206
- }))
207
- )
208
- },
209
- },
210
- },
211
- })
@@ -1,73 +0,0 @@
1
- // Copied from sn-uxf-formula-parser-library - https://code.devsnc.com/dev/uxf-formula-parser
2
-
3
- /**
4
- * https://code.devsnc.com/dev/uxf-formula-parser/blob/ci/master/src/uxf-formula-parser/clean/cleanUxValue.js
5
- */
6
-
7
- export const cleanUxValue = (uxValue) => {
8
- switch (uxValue?.type) {
9
- case 'JSON_LITERAL':
10
- return { type: uxValue.type, value: uxValue.value }
11
-
12
- case 'CONTEXT_BINDING':
13
- case 'DATA_OUTPUT_BINDING':
14
- case 'STATE_BINDING':
15
- case 'EVENT_PAYLOAD_BINDING':
16
- case 'ELEMENT_BINDING':
17
- case 'REPEATER_ITEM_BINDING':
18
- case 'ENV_BINDING':
19
- return { type: uxValue.type, binding: uxValue.binding }
20
-
21
- case 'CLIENT_TRANSFORM':
22
- return {
23
- type: uxValue.type,
24
- transform: {
25
- operator: uxValue.transform.operator,
26
- operands: cleanUxValue(uxValue.transform.operands),
27
- },
28
- }
29
-
30
- case 'UNARY':
31
- return {
32
- type: uxValue.type,
33
- operation: {
34
- ...uxValue.operation,
35
- operand: cleanUxValue(uxValue.operation.operand),
36
- },
37
- }
38
-
39
- case 'BINARY':
40
- return {
41
- type: uxValue.type,
42
- operation: {
43
- ...uxValue.operation,
44
- operator: uxValue.operation.operator,
45
- left: cleanUxValue(uxValue.operation.left),
46
- right: cleanUxValue(uxValue.operation.right),
47
- },
48
- }
49
-
50
- case 'LIST_CONTAINER':
51
- return {
52
- type: uxValue.type,
53
- container: uxValue.container.map((item) => cleanUxValue(item)),
54
- }
55
-
56
- case 'MAP_CONTAINER':
57
- return {
58
- type: uxValue.type,
59
- container: Object.entries(uxValue.container).reduce(
60
- (acc, [key, item]) => ({
61
- ...acc,
62
- [key]: cleanUxValue(item),
63
- }),
64
- {}
65
- ),
66
- }
67
-
68
- case 'TRANSLATION_LITERAL':
69
- return { type: uxValue.type, value: uxValue.value }
70
- }
71
-
72
- return uxValue
73
- }