@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
@@ -0,0 +1,658 @@
1
+ import {
2
+ CallExpressionShape,
3
+ type Factory,
4
+ Plugin,
5
+ Shape,
6
+ type Record,
7
+ type Diagnostics,
8
+ type ObjectShape,
9
+ type RecordId,
10
+ type NowConfig,
11
+ } from '@servicenow/sdk-build-core'
12
+ import { ModuleFunctionShape } from './server-module-plugin'
13
+ import { NowIdShape } from './now-id-plugin'
14
+ import { generateDeprecatedDiagnostics } from './utils'
15
+
16
+ const DEFAULT_MEDIA_TYPE = 'application/json,application/xml,text/xml'
17
+ const DEFAULT_REST_ENFORCED_ACL = 'cf9d01d3e73003009d6247e603f6a990'
18
+ const methodsAllowedToOverrideRequests = ['PUT', 'PATCH', 'POST']
19
+ const restDefAliases = {
20
+ serviceId: ['service_id'],
21
+ enforceAcl: ['enforce_acl'],
22
+ docLink: ['doc_link'],
23
+ shortDescription: ['short_description'],
24
+ }
25
+ const routeAliases = {
26
+ shortDescription: ['short_description'],
27
+ requestExample: ['request_example'],
28
+ enforceAcl: ['enforce_acl'],
29
+ }
30
+ const versionAliases = {
31
+ isDefault: ['is_default'],
32
+ shortDescription: ['short_description'],
33
+ }
34
+ const attributeAliases = {
35
+ shortDescription: ['short_description'],
36
+ exampleValue: ['example_value'],
37
+ }
38
+
39
+ function mergeAcls(acls: Shape | undefined) {
40
+ if (acls?.isArray()) {
41
+ return acls?.pipe((r) =>
42
+ Array.from(new Set(r.getElements().map((r) => r.ifRecord()?.getId().getValue() ?? r.getValue()))).join(',')
43
+ )
44
+ }
45
+
46
+ return DEFAULT_REST_ENFORCED_ACL
47
+ }
48
+
49
+ function splitAcls(acls: Shape | undefined) {
50
+ if (acls?.isString() && !acls?.isEmpty()) {
51
+ return acls?.pipe((r) => r.getValue().split(','))
52
+ }
53
+
54
+ return []
55
+ }
56
+
57
+ function getVersionNumber(versionShape: Shape, versions: Record[]) {
58
+ const versionId = versionShape.ifString()?.getValue() ?? versionShape.ifRecordId()?.getValue() ?? undefined
59
+ if (!versionId) {
60
+ return undefined
61
+ }
62
+ const version = versions.find((v) => v.getId().getValue() === versionId)
63
+ if (!version) {
64
+ return undefined
65
+ }
66
+ return version.get('version').toNumber().getValue()
67
+ }
68
+
69
+ function getAttributeRecord(attrAssociationRecord: Record, attrRecords: Record[], attrType: string) {
70
+ return attrRecords.find((r) => {
71
+ const attrId = r.getId().getValue()
72
+ const attr = attrAssociationRecord.get(`web_service_${attrType}`)
73
+ const associationId = attr.ifString()?.getValue() ?? attr.asRecordId().getValue()
74
+ return attrId === associationId
75
+ })
76
+ }
77
+
78
+ function getVersionId(
79
+ versionShape: Shape,
80
+ versionToVersionRecordMap: Map<string, Record>,
81
+ diagnostics: Diagnostics
82
+ ): string | RecordId {
83
+ const version = versionShape.ifNumber()?.getValue() ?? undefined
84
+ if (!version) {
85
+ return ''
86
+ }
87
+ if (!versionToVersionRecordMap.has(`v${version}`)) {
88
+ diagnostics.error(
89
+ versionShape,
90
+ `Unable to resolve version details for version number "${version}". Check if the version is listed in your API versions list.`
91
+ )
92
+ return ''
93
+ }
94
+ return versionToVersionRecordMap.get(`v${version}`)!.getId()
95
+ }
96
+
97
+ function generateVersionRecords(
98
+ versions: Shape[],
99
+ restApi: ObjectShape,
100
+ restRecord: Record,
101
+ defaultVersion: number,
102
+ factory: Factory,
103
+ diagnostics: Diagnostics,
104
+ callExpression: CallExpressionShape
105
+ ): Map<string, Record> {
106
+ const versionMap = new Map<string, Record>()
107
+ for (const v of versions) {
108
+ const version = v.asObject().get('version').getValue()
109
+ const versionId = `v${version}`
110
+ const versionRecord = factory.createRecord({
111
+ source: callExpression,
112
+ table: 'sys_ws_version',
113
+ explicitId: v.asObject().get('$id'),
114
+ properties: v.asObject().transform(({ $ }) => ({
115
+ active: $.def(true),
116
+ deprecated: $.def(false),
117
+ is_default: $.val(defaultVersion === version).def(false),
118
+ short_description: $.from('shortDescription').def(''),
119
+ version: $,
120
+ version_id: $.val(versionId),
121
+ web_service_definition: $.val(restRecord.getId()),
122
+ })),
123
+ })
124
+ /** versions have to be unique */
125
+ if (versionMap.has(versionId)) {
126
+ diagnostics.error(
127
+ v.asObject().get('version'),
128
+ `Duplicate versions with version number "${version}" found in RestApi with id "${restApi.get('$id').getValue()}". All versions are expected to be unique.`
129
+ )
130
+ }
131
+ versionMap.set(versionId, versionRecord)
132
+ }
133
+ return versionMap
134
+ }
135
+
136
+ function checkForDuplicateRecords(
137
+ recordMap: Map<string, Record>,
138
+ record: Record,
139
+ attrShape: ObjectShape,
140
+ diagnostics: Diagnostics
141
+ ): void {
142
+ const recordId = record.getId().getValue()
143
+ if (!recordMap.has(recordId)) {
144
+ recordMap.set(recordId, record)
145
+ } else {
146
+ const matchRec = recordMap.get(recordId)!
147
+ const originalShape = Shape.from(record.getSource(), record.getValue())
148
+ const matchedShape = Shape.from(matchRec.getSource(), matchRec.getValue())
149
+ if (!matchedShape.equals(originalShape)) {
150
+ diagnostics.error(
151
+ attrShape.get('$id'),
152
+ `Multiple route attributes found with the same ID "${attrShape.get('$id').getValue()}" but with different property values. Attributes with same ID are expected to have identical property values.`
153
+ )
154
+ }
155
+ }
156
+ }
157
+
158
+ function generateRouteAttributeRecords(
159
+ attributes: Shape[],
160
+ restDef: Record,
161
+ routeDef: Record,
162
+ attrType: string,
163
+ attrMap: Map<string, Record>,
164
+ factory: Factory,
165
+ diagnostics: Diagnostics,
166
+ callExpression: CallExpressionShape
167
+ ): Record[] {
168
+ const records: Record[] = []
169
+ for (const attr of attributes) {
170
+ const attrRecord = factory.createRecord({
171
+ source: callExpression,
172
+ table: `sys_ws_${attrType}`,
173
+ explicitId: attr.asObject().get('$id'),
174
+ properties: attr.asObject().transform(({ $ }) => ({
175
+ name: $,
176
+ required: $.def(false),
177
+ short_description: $.from('shortDescription').def(''),
178
+ example_value: $.from('exampleValue').def(''),
179
+ web_service_definition: $.val(restDef.getId()),
180
+ })),
181
+ })
182
+
183
+ checkForDuplicateRecords(attrMap, attrRecord, attr.asObject(), diagnostics)
184
+
185
+ const attributeMappingRecord = factory.createRecord({
186
+ source: callExpression,
187
+ table: `sys_ws_${attrType}_map`,
188
+ properties: attr.asObject().transform(({ $ }) => ({
189
+ web_service_operation: $.val(routeDef.getId()),
190
+ [`web_service_${attrType}`]: $.val(attrRecord.getId()),
191
+ })),
192
+ })
193
+
194
+ records.push(attrRecord.with(attributeMappingRecord))
195
+ }
196
+
197
+ return records
198
+ }
199
+
200
+ function generateRouteAndRouteAttrRecords(
201
+ routes: Shape[],
202
+ restDef: Record,
203
+ factory: Factory,
204
+ config: NowConfig,
205
+ diagnostics: Diagnostics,
206
+ versionToVersionRecordMap: Map<string, Record>,
207
+ callExpression: CallExpressionShape
208
+ ): Record[] {
209
+ const routeRecords: Record[] = []
210
+ const headersMap = new Map<string, Record>()
211
+ const parametersMap = new Map<string, Record>()
212
+
213
+ for (const r of routes) {
214
+ const route = r.asObject()
215
+ const routeVersion = route.get('version').getValue() as unknown as number
216
+ const versionId = getVersionId(route.get('version'), versionToVersionRecordMap, diagnostics)
217
+ let routeConsumes = route.get('consumes')?.ifString()?.getValue() ?? ''
218
+ const routeMethod = route.get('method').ifString()?.getValue() ?? 'GET'
219
+ const restConsumes = restDef.get('consumes').asString().getValue()
220
+ const restProduces = restDef.get('produces').asString().getValue()
221
+
222
+ if (
223
+ routeConsumes &&
224
+ routeConsumes !== restConsumes &&
225
+ !methodsAllowedToOverrideRequests.includes(routeMethod)
226
+ ) {
227
+ diagnostics.error(route.get('consumes'), `Cannot override consumer type for ${routeMethod} method`)
228
+ }
229
+
230
+ routeConsumes = routeConsumes ? routeConsumes : restConsumes
231
+ const routeProduces = route.get('produces').getValue() ?? restProduces
232
+
233
+ const baseURI = restDef.get('base_uri').getValue()
234
+ const routePath = route.get('path').getValue() ?? '/'
235
+ const defaultOperationURI = `${baseURI}${routePath}`
236
+ const operationURIPrefix = `/api/${restDef.get('namespace').getValue()}`
237
+ const operationURISuffix = `${restDef.get('service_id').getValue()}${routePath}`
238
+ const operationURI = versionId
239
+ ? `${operationURIPrefix}/v${routeVersion}/${operationURISuffix}`
240
+ : `${operationURIPrefix}/${operationURISuffix}`
241
+
242
+ if (route.get('script').isUnresolved()) {
243
+ diagnostics.error(
244
+ route.get('script').getOriginalNode(),
245
+ `Unable to resolve the script reference, ensure the imported module is within the ${config.serverModulesDir} directory.`
246
+ )
247
+ }
248
+
249
+ const routeRecord = factory.createRecord({
250
+ source: callExpression,
251
+ table: 'sys_ws_operation',
252
+ explicitId: route.get('$id'),
253
+ properties: route.transform(({ $ }) => ({
254
+ name: $.val(route.get('name').ifString()?.getValue() ?? routePath).def('something random'),
255
+ active: $.def(true),
256
+ consumes: $.val(routeConsumes),
257
+ consumes_customized: $.val(routeConsumes !== restConsumes),
258
+ default_operation_uri: $.val(defaultOperationURI),
259
+ http_method: $.from('method').def('GET'),
260
+ operation_script: $.from('script')
261
+ .map(
262
+ (v) =>
263
+ v.if(ModuleFunctionShape)?.toString((n) => `${n}({{PARAMS}})`, ['request', 'response']) ?? v
264
+ )
265
+ .toCdata()
266
+ .def(''),
267
+ operation_uri: $.val(operationURI),
268
+ produces: $.val(routeProduces),
269
+ produces_customized: $.val(routeProduces !== restProduces),
270
+ relative_path: $.from('path').def('/'),
271
+ enforce_acl: $.val(mergeAcls(route.get('enforceAcl'))),
272
+ requires_acl_authorization: $.from('authorization').def(true),
273
+ requires_authentication: $.from('authentication').def(true),
274
+ requires_snc_internal_role: $.from('internalRole').def(true),
275
+ short_description: $.from('shortDescription').def(''),
276
+ request_example: $.from('requestExample').def(''),
277
+ web_service_definition: $.val(restDef.getId()),
278
+ web_service_version: $.val(versionId),
279
+ sys_policy: $.from('policy').def(''),
280
+ })),
281
+ })
282
+
283
+ const routeHeaders = route.get('headers')?.ifArray()?.getElements() ?? []
284
+ routeHeaders.forEach((h) => {
285
+ h.asObject().withAliasedKeys(attributeAliases)
286
+ generateDeprecatedDiagnostics(h.asObject(), diagnostics)
287
+ })
288
+ const headerRecords = generateRouteAttributeRecords(
289
+ routeHeaders,
290
+ restDef,
291
+ routeRecord,
292
+ 'header',
293
+ headersMap,
294
+ factory,
295
+ diagnostics,
296
+ callExpression
297
+ )
298
+
299
+ const routeParameters = route.get('parameters')?.ifArray()?.getElements() ?? []
300
+ routeParameters.forEach((p) => {
301
+ p.asObject().withAliasedKeys(attributeAliases)
302
+ generateDeprecatedDiagnostics(p.asObject(), diagnostics)
303
+ })
304
+ const parameterRecords = generateRouteAttributeRecords(
305
+ routeParameters,
306
+ restDef,
307
+ routeRecord,
308
+ 'query_parameter',
309
+ parametersMap,
310
+ factory,
311
+ diagnostics,
312
+ callExpression
313
+ )
314
+
315
+ routeRecords.push(routeRecord.with(...headerRecords, ...parameterRecords))
316
+ }
317
+
318
+ return routeRecords
319
+ }
320
+
321
+ function validateAttributesAndAssociations(
322
+ attributes: Record[],
323
+ attributeRouteAssociations: Record[],
324
+ attributeType: string
325
+ ) {
326
+ const attributeIdToRecordMap = new Map<string, Record>()
327
+ attributes.forEach((attribute) => {
328
+ attributeIdToRecordMap.set(attribute.getId().getValue(), attribute)
329
+ })
330
+
331
+ const attributeIds = new Set(attributeIdToRecordMap.keys())
332
+ const referencedAttributeIds = new Set(
333
+ attributeRouteAssociations.map((m2m) => {
334
+ const attr = m2m.get(`web_service_${attributeType}`)
335
+ return attr.ifString()?.getValue() ?? attr.ifRecordId()?.getValue() ?? undefined
336
+ })
337
+ )
338
+
339
+ const orphanedAttributes = Array.from(attributeIds).filter((id) => !referencedAttributeIds.has(id))
340
+ if (orphanedAttributes.length > 0) {
341
+ const orphanedAttributeNames = orphanedAttributes
342
+ .map((id) => {
343
+ const attribute = attributeIdToRecordMap.get(id)
344
+ return attribute?.get('name')?.getValue() || id
345
+ })
346
+ .join(', ')
347
+
348
+ throw new Error(
349
+ `Found ${orphanedAttributes.length} attribute record(s) without route associations: ${orphanedAttributeNames}. ` +
350
+ `Either associate these attributes with routes or delete them.`
351
+ )
352
+ }
353
+
354
+ const invalidAttributeAssociations = attributeRouteAssociations.filter((association) => {
355
+ const attr = association.get(`web_service_${attributeType}`)
356
+ const attributeId = attr.ifString()?.getValue() ?? attr.ifRecordId()?.getValue() ?? ''
357
+ return !attributeIdToRecordMap.has(attributeId)
358
+ })
359
+
360
+ if (invalidAttributeAssociations.length > 0) {
361
+ const invalidAttributeAssociationIds = invalidAttributeAssociations
362
+ .map((association) => association.getId().getValue())
363
+ .join(', ')
364
+ throw new Error(
365
+ `Found ${invalidAttributeAssociations.length} ${attributeType} association record(s) referencing non-existent ${attributeType}s: ${invalidAttributeAssociationIds}. ` +
366
+ `Please clean up these m2m records.`
367
+ )
368
+ }
369
+ }
370
+
371
+ function routeAttributeTransform(
372
+ associationRecords: Record[],
373
+ attributes: Record[],
374
+ operationFilterId: string,
375
+ attributeType: string
376
+ ) {
377
+ const results = associationRecords
378
+ .filter((pm) => {
379
+ const operation = pm.get(`web_service_operation`)
380
+ const operationId = operation.asRecordId().getValue()
381
+ return operationId === operationFilterId
382
+ })
383
+ .map((pm) => {
384
+ const attribute = getAttributeRecord(pm, attributes, attributeType)!
385
+ return attribute
386
+ .transform(({ $ }) => ({
387
+ $id: $.val(NowIdShape.from(attribute)),
388
+ name: $,
389
+ required: $.toBoolean().def(false),
390
+ exampleValue: $.from('example_value').def(''),
391
+ shortDescription: $.from('short_description').def(''),
392
+ }))
393
+ .withAliasedKeys(attributeAliases)
394
+ })
395
+
396
+ return results
397
+ }
398
+
399
+ function versionsTransform(versions: Record[]) {
400
+ if (versions.length === 0) {
401
+ return undefined
402
+ }
403
+
404
+ return versions.map((v) =>
405
+ v
406
+ .transform(({ $ }) => ({
407
+ $id: $.val(NowIdShape.from(v)),
408
+ active: $.toBoolean().def(true),
409
+ deprecated: $.toBoolean().def(false),
410
+ isDefault: $.from('is_default').toBoolean().def(false),
411
+ shortDescription: $.from('short_description').def(''),
412
+ version: $.toNumber(),
413
+ }))
414
+ .withAliasedKeys(versionAliases)
415
+ )
416
+ }
417
+
418
+ export const RestApiPlugin = Plugin.create({
419
+ name: 'RestApiPlugin',
420
+ records: {
421
+ sys_ws_header_map: {
422
+ coalesce: ['web_service_operation', 'web_service_header'],
423
+ },
424
+ sys_ws_query_parameter_map: {
425
+ coalesce: ['web_service_operation', 'web_service_query_parameter'],
426
+ },
427
+ sys_ws_definition: {
428
+ relationships: {
429
+ sys_ws_operation: {
430
+ via: 'web_service_definition',
431
+ descendant: true,
432
+ relationships: {
433
+ sys_ws_header_map: {
434
+ via: 'web_service_operation',
435
+ descendant: true,
436
+ },
437
+ sys_ws_query_parameter_map: {
438
+ via: 'web_service_operation',
439
+ descendant: true,
440
+ },
441
+ },
442
+ },
443
+ sys_ws_version: {
444
+ via: 'web_service_definition',
445
+ descendant: true,
446
+ },
447
+ sys_ws_header: {
448
+ via: 'web_service_definition',
449
+ descendant: true,
450
+ },
451
+ sys_ws_query_parameter: {
452
+ via: 'web_service_definition',
453
+ descendant: true,
454
+ },
455
+ },
456
+ toShape(record, { descendants }) {
457
+ const versions = descendants.query('sys_ws_version')
458
+ const routes = descendants.query('sys_ws_operation')
459
+ const headers = descendants.query('sys_ws_header')
460
+ const parameters = descendants.query('sys_ws_query_parameter')
461
+ const headerRouteAssociations = descendants.query('sys_ws_header_map')
462
+ const paramRouteAssociations = descendants.query('sys_ws_query_parameter_map')
463
+
464
+ /**
465
+ * Special cases:
466
+ * Case 1: No m2m records exists for a header or parameter record. Can happen in following scenarios:
467
+ * - User has created a header or parameter record but these records are not associated with any routes on instance.
468
+ * - User has removed all the m2m associations on instance but not the actual header or parameter record.
469
+ * Solution: Throw error guiding user to do one of the following:
470
+ * - Associate the header or parameter record with a route
471
+ * - Delete the header or parameter record
472
+ *
473
+ * Case 2: Deleting a header record on instance wouldn't delete the m2m records which map those headers to a route.
474
+ * Solution: Throw error and request the user to cleanup the m2m records on instance.
475
+ */
476
+ validateAttributesAndAssociations(headers, headerRouteAssociations, 'header')
477
+ validateAttributesAndAssociations(parameters, paramRouteAssociations, 'query_parameter')
478
+
479
+ return {
480
+ success: true,
481
+ value: new CallExpressionShape({
482
+ source: record,
483
+ callee: 'RestApi',
484
+ args: [
485
+ record
486
+ .transform(({ $ }) => ({
487
+ $id: $.val(NowIdShape.from(record)),
488
+ name: $,
489
+ active: $.toBoolean().def(true),
490
+ consumes: $.def(DEFAULT_MEDIA_TYPE),
491
+ produces: $.def(DEFAULT_MEDIA_TYPE),
492
+ enforceAcl: $.from('enforce_acl')
493
+ .map((v) => splitAcls(v))
494
+ .def([DEFAULT_REST_ENFORCED_ACL]),
495
+ serviceId: $.from('service_id'),
496
+ shortDescription: $.from('short_description').def(''),
497
+ policy: $.from('sys_policy').def(''),
498
+ docLink: $.from('doc_link').def(''),
499
+ routes: $.val(
500
+ routes.map((r) =>
501
+ r
502
+ .transform(({ $ }) => ({
503
+ $id: $.val(NowIdShape.from(r)),
504
+ name: $,
505
+ active: $.toBoolean().def(true),
506
+ consumes: $,
507
+ method: $.from('http_method').def('GET'),
508
+ script: $.from('operation_script'),
509
+ produces: $,
510
+ path: $.from('relative_path').def('/'),
511
+ enforceAcl: $.val(splitAcls(r.get('enforce_acl'))).def([
512
+ DEFAULT_REST_ENFORCED_ACL,
513
+ ]),
514
+ authorization: $.from('requires_acl_authorization')
515
+ .toBoolean()
516
+ .def(true),
517
+ authentication: $.from('requires_authentication')
518
+ .toBoolean()
519
+ .def(true),
520
+ internalRole: $.from('requires_snc_internal_role')
521
+ .toBoolean()
522
+ .def(true),
523
+ shortDescription: $.from('short_description').def(''),
524
+ requestExample: $.from('request_example').def(''),
525
+ policy: $.from('sys_policy').def(''),
526
+ parameters: $.val(
527
+ routeAttributeTransform(
528
+ paramRouteAssociations,
529
+ parameters,
530
+ r.getId().getValue(),
531
+ 'query_parameter'
532
+ )
533
+ ).def([]),
534
+ headers: $.val(
535
+ routeAttributeTransform(
536
+ headerRouteAssociations,
537
+ headers,
538
+ r.getId().getValue(),
539
+ 'header'
540
+ )
541
+ ).def([]),
542
+ version: $.from('web_service_version').map((v) =>
543
+ getVersionNumber(v, versions)
544
+ ),
545
+ }))
546
+ .withAliasedKeys(routeAliases)
547
+ )
548
+ ).def([]),
549
+ versions: $.val(versionsTransform(versions)).def([]),
550
+ }))
551
+ .withAliasedKeys(restDefAliases),
552
+ ],
553
+ }),
554
+ }
555
+ },
556
+ },
557
+ },
558
+ shapes: [
559
+ {
560
+ shape: CallExpressionShape,
561
+ fileTypes: ['fluent'],
562
+ async toRecord(callExpression, { factory, config, diagnostics }) {
563
+ if (callExpression.getCallee() !== 'RestApi') {
564
+ return { success: false }
565
+ }
566
+
567
+ const restApi = callExpression.getArgument(0).asObject().withAliasedKeys(restDefAliases)
568
+ generateDeprecatedDiagnostics(restApi, diagnostics)
569
+
570
+ const scope = config.scope
571
+ const serviceId = restApi.get('serviceId')
572
+ const serviceIdRegex = /^[a-z0-9_]*[a-z0-9]$/
573
+
574
+ if (!serviceId.asString().getValue().match(serviceIdRegex)) {
575
+ diagnostics.error(
576
+ serviceId,
577
+ `Rest service_id must only contain lowercase letters, numbers, and underscores and end with a letter or number`
578
+ )
579
+ }
580
+
581
+ const versions = restApi.get('versions')?.ifArray()?.getElements() ?? []
582
+ versions.forEach((v) => {
583
+ v.asObject().withAliasedKeys(versionAliases)
584
+ generateDeprecatedDiagnostics(v.asObject(), diagnostics)
585
+ })
586
+ const defaultVersions = versions.filter(
587
+ (v) => v.asObject().get('isDefault').ifBoolean()?.getValue() ?? false
588
+ )
589
+ const defaultVersion =
590
+ defaultVersions.length === 1 ? defaultVersions[0]!.asObject().get('version').getValue() : -1
591
+
592
+ if (defaultVersions.length > 1) {
593
+ diagnostics.error(restApi.get('versions'), `Multiple versions cannot be set to default.`)
594
+ }
595
+
596
+ const enforceAcls = restApi.get('enforceAcl')
597
+ const restRecord = factory.createRecord({
598
+ source: callExpression,
599
+ table: 'sys_ws_definition',
600
+ explicitId: restApi.get('$id'),
601
+ properties: restApi.transform(({ $ }) => ({
602
+ name: $,
603
+ service_id: $.val(serviceId),
604
+ active: $.def(true),
605
+ base_uri: $.val(`/api/${scope}/${serviceId.getValue()}`),
606
+ short_description: $.from('shortDescription').def(''),
607
+ consumes: $.def(DEFAULT_MEDIA_TYPE),
608
+ consumes_customized: $.from('consumes').map((v) =>
609
+ v.isString() ? v.getValue() !== DEFAULT_MEDIA_TYPE : false
610
+ ),
611
+ default_version: $.val(
612
+ defaultVersion !== -1 ? `v${defaultVersion}` : 'No active default version'
613
+ ),
614
+ is_versioned: $.val(versions.length > 0 ? true : false),
615
+ namespace: $.val(scope),
616
+ doc_link: $.from('docLink').def(''),
617
+ produces: $.def(DEFAULT_MEDIA_TYPE),
618
+ produces_customized: $.from('produces').map((v) =>
619
+ v.isString() ? v.getValue() !== DEFAULT_MEDIA_TYPE : false
620
+ ),
621
+ sys_policy: $.from('policy').def(''),
622
+ enforce_acl: $.val(mergeAcls(enforceAcls)),
623
+ })),
624
+ })
625
+ const versionToVersionRecordMap = generateVersionRecords(
626
+ versions,
627
+ restApi,
628
+ restRecord,
629
+ defaultVersion as number,
630
+ factory,
631
+ diagnostics,
632
+ callExpression
633
+ )
634
+
635
+ const routes = restApi.get('routes')?.ifArray()?.getElements() ?? []
636
+ routes.forEach((r) => {
637
+ r.asObject().withAliasedKeys(routeAliases)
638
+ generateDeprecatedDiagnostics(r.asObject(), diagnostics)
639
+ })
640
+
641
+ const routeAndRouteAttrRecords = generateRouteAndRouteAttrRecords(
642
+ routes,
643
+ restRecord,
644
+ factory,
645
+ config,
646
+ diagnostics,
647
+ versionToVersionRecordMap,
648
+ callExpression
649
+ )
650
+
651
+ return {
652
+ success: true,
653
+ value: restRecord.with(...versionToVersionRecordMap.values(), ...routeAndRouteAttrRecords),
654
+ }
655
+ },
656
+ },
657
+ ],
658
+ })