@servicenow/sdk-build-plugins 4.4.1 → 4.6.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 (337) hide show
  1. package/dist/acl-plugin.js +54 -4
  2. package/dist/acl-plugin.js.map +1 -1
  3. package/dist/applicability-plugin.js +2 -0
  4. package/dist/applicability-plugin.js.map +1 -1
  5. package/dist/application-menu-plugin.js +2 -0
  6. package/dist/application-menu-plugin.js.map +1 -1
  7. package/dist/arrow-function-plugin.d.ts +6 -1
  8. package/dist/arrow-function-plugin.js +105 -12
  9. package/dist/arrow-function-plugin.js.map +1 -1
  10. package/dist/atf/test-plugin.js +2 -0
  11. package/dist/atf/test-plugin.js.map +1 -1
  12. package/dist/basic-syntax-plugin.js +20 -0
  13. package/dist/basic-syntax-plugin.js.map +1 -1
  14. package/dist/call-expression-plugin.js +1 -0
  15. package/dist/call-expression-plugin.js.map +1 -1
  16. package/dist/claims-plugin.js +1 -0
  17. package/dist/claims-plugin.js.map +1 -1
  18. package/dist/client-script-plugin.js +1 -0
  19. package/dist/client-script-plugin.js.map +1 -1
  20. package/dist/column-plugin.js +4 -7
  21. package/dist/column-plugin.js.map +1 -1
  22. package/dist/cross-scope-privilege-plugin.js +1 -0
  23. package/dist/cross-scope-privilege-plugin.js.map +1 -1
  24. package/dist/dashboard/dashboard-plugin.js +2 -0
  25. package/dist/dashboard/dashboard-plugin.js.map +1 -1
  26. package/dist/data-plugin.js +1 -0
  27. package/dist/data-plugin.js.map +1 -1
  28. package/dist/email-notification-plugin.js +9 -13
  29. package/dist/email-notification-plugin.js.map +1 -1
  30. package/dist/flow/constants/flow-plugin-constants.d.ts +1 -1
  31. package/dist/flow/constants/flow-plugin-constants.js +1 -1
  32. package/dist/flow/constants/flow-plugin-constants.js.map +1 -1
  33. package/dist/flow/flow-logic/flow-logic-diagnostics.js +5 -5
  34. package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -1
  35. package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +82 -2
  36. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +48 -40
  37. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -1
  38. package/dist/flow/flow-logic/flow-logic-plugin.js +1 -0
  39. package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -1
  40. package/dist/flow/plugins/approval-rules-plugin.js +1 -0
  41. package/dist/flow/plugins/approval-rules-plugin.js.map +1 -1
  42. package/dist/flow/plugins/flow-action-definition-plugin.js +1232 -55
  43. package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -1
  44. package/dist/flow/plugins/flow-data-pill-plugin.js +6 -2
  45. package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -1
  46. package/dist/flow/plugins/flow-definition-plugin.js +23 -44
  47. package/dist/flow/plugins/flow-definition-plugin.js.map +1 -1
  48. package/dist/flow/plugins/flow-diagnostics-plugin.d.ts +2 -2
  49. package/dist/flow/plugins/flow-diagnostics-plugin.js +3 -2
  50. package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -1
  51. package/dist/flow/plugins/flow-instance-plugin.js +136 -34
  52. package/dist/flow/plugins/flow-instance-plugin.js.map +1 -1
  53. package/dist/flow/plugins/flow-trigger-instance-plugin.js +1 -0
  54. package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -1
  55. package/dist/flow/plugins/inline-script-plugin.js +1 -0
  56. package/dist/flow/plugins/inline-script-plugin.js.map +1 -1
  57. package/dist/flow/plugins/step-definition-plugin.js +4 -2
  58. package/dist/flow/plugins/step-definition-plugin.js.map +1 -1
  59. package/dist/flow/plugins/step-instance-plugin.d.ts +9 -1
  60. package/dist/flow/plugins/step-instance-plugin.js +649 -135
  61. package/dist/flow/plugins/step-instance-plugin.js.map +1 -1
  62. package/dist/flow/plugins/trigger-plugin.js +2 -0
  63. package/dist/flow/plugins/trigger-plugin.js.map +1 -1
  64. package/dist/flow/plugins/wfa-datapill-plugin.js +21 -5
  65. package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -1
  66. package/dist/flow/post-install.d.ts +2 -0
  67. package/dist/flow/post-install.js +59 -0
  68. package/dist/flow/post-install.js.map +1 -0
  69. package/dist/flow/utils/complex-object-resolver.js +4 -1
  70. package/dist/flow/utils/complex-object-resolver.js.map +1 -1
  71. package/dist/flow/utils/complex-objects.js +5 -3
  72. package/dist/flow/utils/complex-objects.js.map +1 -1
  73. package/dist/flow/utils/flow-constants.d.ts +90 -2
  74. package/dist/flow/utils/flow-constants.js +430 -7
  75. package/dist/flow/utils/flow-constants.js.map +1 -1
  76. package/dist/flow/utils/flow-io-to-record.d.ts +1 -1
  77. package/dist/flow/utils/flow-io-to-record.js +37 -16
  78. package/dist/flow/utils/flow-io-to-record.js.map +1 -1
  79. package/dist/flow/utils/flow-shapes.js +4 -0
  80. package/dist/flow/utils/flow-shapes.js.map +1 -1
  81. package/dist/flow/utils/flow-to-xml.d.ts +3 -2
  82. package/dist/flow/utils/flow-to-xml.js +3 -4
  83. package/dist/flow/utils/flow-to-xml.js.map +1 -1
  84. package/dist/flow/utils/label-cache-parser.d.ts +9 -2
  85. package/dist/flow/utils/label-cache-parser.js +32 -4
  86. package/dist/flow/utils/label-cache-parser.js.map +1 -1
  87. package/dist/flow/utils/label-cache-processor.d.ts +5 -0
  88. package/dist/flow/utils/label-cache-processor.js +14 -2
  89. package/dist/flow/utils/label-cache-processor.js.map +1 -1
  90. package/dist/flow/utils/pill-shape-helpers.d.ts +15 -0
  91. package/dist/flow/utils/pill-shape-helpers.js +35 -0
  92. package/dist/flow/utils/pill-shape-helpers.js.map +1 -0
  93. package/dist/flow/utils/pill-string-parser.js +1 -0
  94. package/dist/flow/utils/pill-string-parser.js.map +1 -1
  95. package/dist/flow/utils/schema-to-flow-object.d.ts +6 -1
  96. package/dist/flow/utils/schema-to-flow-object.js +131 -15
  97. package/dist/flow/utils/schema-to-flow-object.js.map +1 -1
  98. package/dist/flow/utils/service-catalog.js +5 -1
  99. package/dist/flow/utils/service-catalog.js.map +1 -1
  100. package/dist/flow/utils/utils.d.ts +1 -0
  101. package/dist/flow/utils/utils.js +6 -1
  102. package/dist/flow/utils/utils.js.map +1 -1
  103. package/dist/form-plugin.d.ts +2 -0
  104. package/dist/form-plugin.js +1132 -0
  105. package/dist/form-plugin.js.map +1 -0
  106. package/dist/html-import-plugin.js +1 -0
  107. package/dist/html-import-plugin.js.map +1 -1
  108. package/dist/import-sets-plugin.js +2 -0
  109. package/dist/import-sets-plugin.js.map +1 -1
  110. package/dist/inbound-email-action-plugin.d.ts +10 -0
  111. package/dist/inbound-email-action-plugin.js +128 -0
  112. package/dist/inbound-email-action-plugin.js.map +1 -0
  113. package/dist/index.d.ts +13 -0
  114. package/dist/index.js +17 -1
  115. package/dist/index.js.map +1 -1
  116. package/dist/instance-scan-plugin.d.ts +2 -0
  117. package/dist/instance-scan-plugin.js +293 -0
  118. package/dist/instance-scan-plugin.js.map +1 -0
  119. package/dist/json-plugin.js +1 -0
  120. package/dist/json-plugin.js.map +1 -1
  121. package/dist/list-plugin.js +1 -0
  122. package/dist/list-plugin.js.map +1 -1
  123. package/dist/now-attach-plugin.js +1 -0
  124. package/dist/now-attach-plugin.js.map +1 -1
  125. package/dist/now-config-plugin.js +659 -51
  126. package/dist/now-config-plugin.js.map +1 -1
  127. package/dist/now-id-plugin.js +1 -0
  128. package/dist/now-id-plugin.js.map +1 -1
  129. package/dist/now-include-plugin.js +1 -0
  130. package/dist/now-include-plugin.js.map +1 -1
  131. package/dist/now-ref-plugin.js +1 -0
  132. package/dist/now-ref-plugin.js.map +1 -1
  133. package/dist/now-unresolved-plugin.js +1 -0
  134. package/dist/now-unresolved-plugin.js.map +1 -1
  135. package/dist/package-json-plugin.js +1 -0
  136. package/dist/package-json-plugin.js.map +1 -1
  137. package/dist/property-plugin.js +3 -1
  138. package/dist/property-plugin.js.map +1 -1
  139. package/dist/record-plugin.d.ts +37 -0
  140. package/dist/record-plugin.js +47 -3
  141. package/dist/record-plugin.js.map +1 -1
  142. package/dist/repack/lint/Rules.d.ts +11 -2
  143. package/dist/repack/lint/Rules.js +160 -16
  144. package/dist/repack/lint/Rules.js.map +1 -1
  145. package/dist/repack/lint/index.d.ts +10 -5
  146. package/dist/repack/lint/index.js +76 -50
  147. package/dist/repack/lint/index.js.map +1 -1
  148. package/dist/rest-api-plugin.js +22 -1
  149. package/dist/rest-api-plugin.js.map +1 -1
  150. package/dist/role-plugin.js +1 -0
  151. package/dist/role-plugin.js.map +1 -1
  152. package/dist/schedule-script/index.d.ts +1 -0
  153. package/dist/schedule-script/index.js +18 -0
  154. package/dist/schedule-script/index.js.map +1 -0
  155. package/dist/schedule-script/scheduled-script-plugin.d.ts +2 -0
  156. package/dist/schedule-script/scheduled-script-plugin.js +556 -0
  157. package/dist/schedule-script/scheduled-script-plugin.js.map +1 -0
  158. package/dist/schedule-script/timeZoneConverter.d.ts +61 -0
  159. package/dist/schedule-script/timeZoneConverter.js +170 -0
  160. package/dist/schedule-script/timeZoneConverter.js.map +1 -0
  161. package/dist/script-action-plugin.js +2 -0
  162. package/dist/script-action-plugin.js.map +1 -1
  163. package/dist/script-include-plugin.js +2 -0
  164. package/dist/script-include-plugin.js.map +1 -1
  165. package/dist/server-module-plugin/index.js +13 -2
  166. package/dist/server-module-plugin/index.js.map +1 -1
  167. package/dist/service-catalog/catalog-clientscript-plugin.js +2 -0
  168. package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -1
  169. package/dist/service-catalog/catalog-item-plugin.js +2 -0
  170. package/dist/service-catalog/catalog-item-plugin.js.map +1 -1
  171. package/dist/service-catalog/catalog-ui-policy-plugin.js +2 -0
  172. package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -1
  173. package/dist/service-catalog/sc-record-producer-plugin.js +2 -0
  174. package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -1
  175. package/dist/service-catalog/service-catalog-base.d.ts +18 -18
  176. package/dist/service-catalog/service-catalog-base.js +22 -22
  177. package/dist/service-catalog/service-catalog-base.js.map +1 -1
  178. package/dist/service-catalog/service-catalog-diagnostics.d.ts +6 -0
  179. package/dist/service-catalog/service-catalog-diagnostics.js +20 -0
  180. package/dist/service-catalog/service-catalog-diagnostics.js.map +1 -1
  181. package/dist/service-catalog/shape-to-record.js +7 -2
  182. package/dist/service-catalog/shape-to-record.js.map +1 -1
  183. package/dist/service-catalog/variable-set-plugin.js +2 -0
  184. package/dist/service-catalog/variable-set-plugin.js.map +1 -1
  185. package/dist/service-portal/angular-provider-plugin.js +2 -0
  186. package/dist/service-portal/angular-provider-plugin.js.map +1 -1
  187. package/dist/service-portal/dependency-plugin.js +5 -31
  188. package/dist/service-portal/dependency-plugin.js.map +1 -1
  189. package/dist/service-portal/header-footer-plugin.d.ts +2 -0
  190. package/dist/service-portal/header-footer-plugin.js +50 -0
  191. package/dist/service-portal/header-footer-plugin.js.map +1 -0
  192. package/dist/service-portal/menu-plugin.d.ts +2 -0
  193. package/dist/service-portal/menu-plugin.js +334 -0
  194. package/dist/service-portal/menu-plugin.js.map +1 -0
  195. package/dist/service-portal/page-plugin.d.ts +2 -0
  196. package/dist/service-portal/page-plugin.js +681 -0
  197. package/dist/service-portal/page-plugin.js.map +1 -0
  198. package/dist/service-portal/page-route-map-plugin.d.ts +2 -0
  199. package/dist/service-portal/page-route-map-plugin.js +114 -0
  200. package/dist/service-portal/page-route-map-plugin.js.map +1 -0
  201. package/dist/service-portal/portal-plugin.d.ts +2 -0
  202. package/dist/service-portal/portal-plugin.js +309 -0
  203. package/dist/service-portal/portal-plugin.js.map +1 -0
  204. package/dist/service-portal/theme-plugin.d.ts +2 -0
  205. package/dist/service-portal/theme-plugin.js +112 -0
  206. package/dist/service-portal/theme-plugin.js.map +1 -0
  207. package/dist/service-portal/utils.d.ts +46 -0
  208. package/dist/service-portal/utils.js +331 -0
  209. package/dist/service-portal/utils.js.map +1 -0
  210. package/dist/service-portal/widget-plugin.js +10 -182
  211. package/dist/service-portal/widget-plugin.js.map +1 -1
  212. package/dist/sla-plugin.js +2 -0
  213. package/dist/sla-plugin.js.map +1 -1
  214. package/dist/static-content-plugin.js +5 -0
  215. package/dist/static-content-plugin.js.map +1 -1
  216. package/dist/table-plugin.js +191 -26
  217. package/dist/table-plugin.js.map +1 -1
  218. package/dist/ui-action-plugin.js +3 -4
  219. package/dist/ui-action-plugin.js.map +1 -1
  220. package/dist/ui-page-plugin.js +101 -21
  221. package/dist/ui-page-plugin.js.map +1 -1
  222. package/dist/ui-policy-plugin.js +1 -0
  223. package/dist/ui-policy-plugin.js.map +1 -1
  224. package/dist/user-preference-plugin.js +2 -0
  225. package/dist/user-preference-plugin.js.map +1 -1
  226. package/dist/utils.d.ts +20 -2
  227. package/dist/utils.js +34 -3
  228. package/dist/utils.js.map +1 -1
  229. package/dist/ux-list-menu-config-plugin.js +2 -0
  230. package/dist/ux-list-menu-config-plugin.js.map +1 -1
  231. package/dist/view-plugin.js +9 -3
  232. package/dist/view-plugin.js.map +1 -1
  233. package/dist/workspace-plugin.js +41 -36
  234. package/dist/workspace-plugin.js.map +1 -1
  235. package/package.json +11 -11
  236. package/src/_types/eslint-community-eslint-utils.d.ts +15 -0
  237. package/src/acl-plugin.ts +97 -8
  238. package/src/applicability-plugin.ts +2 -0
  239. package/src/application-menu-plugin.ts +2 -0
  240. package/src/arrow-function-plugin.ts +128 -13
  241. package/src/atf/test-plugin.ts +2 -0
  242. package/src/basic-syntax-plugin.ts +21 -0
  243. package/src/call-expression-plugin.ts +1 -0
  244. package/src/claims-plugin.ts +1 -0
  245. package/src/client-script-plugin.ts +2 -1
  246. package/src/column-plugin.ts +4 -8
  247. package/src/cross-scope-privilege-plugin.ts +2 -1
  248. package/src/dashboard/dashboard-plugin.ts +2 -0
  249. package/src/data-plugin.ts +1 -0
  250. package/src/email-notification-plugin.ts +3 -23
  251. package/src/flow/constants/flow-plugin-constants.ts +1 -1
  252. package/src/flow/flow-logic/flow-logic-diagnostics.ts +5 -6
  253. package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +47 -45
  254. package/src/flow/flow-logic/flow-logic-plugin.ts +1 -0
  255. package/src/flow/plugins/approval-rules-plugin.ts +1 -0
  256. package/src/flow/plugins/flow-action-definition-plugin.ts +1584 -62
  257. package/src/flow/plugins/flow-data-pill-plugin.ts +6 -2
  258. package/src/flow/plugins/flow-definition-plugin.ts +22 -51
  259. package/src/flow/plugins/flow-diagnostics-plugin.ts +3 -2
  260. package/src/flow/plugins/flow-instance-plugin.ts +201 -36
  261. package/src/flow/plugins/flow-trigger-instance-plugin.ts +1 -0
  262. package/src/flow/plugins/inline-script-plugin.ts +1 -0
  263. package/src/flow/plugins/step-definition-plugin.ts +4 -2
  264. package/src/flow/plugins/step-instance-plugin.ts +772 -155
  265. package/src/flow/plugins/trigger-plugin.ts +2 -0
  266. package/src/flow/plugins/wfa-datapill-plugin.ts +26 -5
  267. package/src/flow/post-install.ts +93 -0
  268. package/src/flow/utils/complex-object-resolver.ts +4 -1
  269. package/src/flow/utils/complex-objects.ts +11 -3
  270. package/src/flow/utils/flow-constants.ts +451 -6
  271. package/src/flow/utils/flow-io-to-record.ts +43 -17
  272. package/src/flow/utils/flow-shapes.ts +4 -0
  273. package/src/flow/utils/flow-to-xml.ts +4 -4
  274. package/src/flow/utils/label-cache-parser.ts +33 -4
  275. package/src/flow/utils/label-cache-processor.ts +14 -2
  276. package/src/flow/utils/pill-shape-helpers.ts +42 -0
  277. package/src/flow/utils/pill-string-parser.ts +1 -0
  278. package/src/flow/utils/schema-to-flow-object.ts +183 -15
  279. package/src/flow/utils/service-catalog.ts +5 -2
  280. package/src/flow/utils/utils.ts +12 -1
  281. package/src/form-plugin.ts +1409 -0
  282. package/src/html-import-plugin.ts +1 -0
  283. package/src/import-sets-plugin.ts +2 -0
  284. package/src/inbound-email-action-plugin.ts +145 -0
  285. package/src/index.ts +13 -0
  286. package/src/instance-scan-plugin.ts +313 -0
  287. package/src/json-plugin.ts +1 -0
  288. package/src/list-plugin.ts +2 -1
  289. package/src/now-attach-plugin.ts +1 -0
  290. package/src/now-config-plugin.ts +833 -53
  291. package/src/now-id-plugin.ts +1 -0
  292. package/src/now-include-plugin.ts +1 -0
  293. package/src/now-ref-plugin.ts +1 -0
  294. package/src/now-unresolved-plugin.ts +1 -0
  295. package/src/package-json-plugin.ts +1 -0
  296. package/src/property-plugin.ts +6 -1
  297. package/src/record-plugin.ts +56 -6
  298. package/src/repack/lint/Rules.ts +171 -22
  299. package/src/repack/lint/index.ts +80 -56
  300. package/src/rest-api-plugin.ts +28 -2
  301. package/src/role-plugin.ts +2 -1
  302. package/src/schedule-script/index.ts +1 -0
  303. package/src/schedule-script/scheduled-script-plugin.ts +690 -0
  304. package/src/schedule-script/timeZoneConverter.ts +188 -0
  305. package/src/script-action-plugin.ts +2 -0
  306. package/src/script-include-plugin.ts +2 -0
  307. package/src/server-module-plugin/index.ts +14 -2
  308. package/src/service-catalog/catalog-clientscript-plugin.ts +2 -0
  309. package/src/service-catalog/catalog-item-plugin.ts +2 -0
  310. package/src/service-catalog/catalog-ui-policy-plugin.ts +2 -0
  311. package/src/service-catalog/sc-record-producer-plugin.ts +2 -0
  312. package/src/service-catalog/service-catalog-base.ts +22 -22
  313. package/src/service-catalog/service-catalog-diagnostics.ts +30 -0
  314. package/src/service-catalog/shape-to-record.ts +8 -2
  315. package/src/service-catalog/variable-set-plugin.ts +2 -0
  316. package/src/service-portal/angular-provider-plugin.ts +2 -0
  317. package/src/service-portal/dependency-plugin.ts +6 -53
  318. package/src/service-portal/header-footer-plugin.ts +57 -0
  319. package/src/service-portal/menu-plugin.ts +413 -0
  320. package/src/service-portal/page-plugin.ts +805 -0
  321. package/src/service-portal/page-route-map-plugin.ts +124 -0
  322. package/src/service-portal/portal-plugin.ts +342 -0
  323. package/src/service-portal/theme-plugin.ts +135 -0
  324. package/src/service-portal/utils.ts +470 -0
  325. package/src/service-portal/widget-plugin.ts +18 -224
  326. package/src/sla-plugin.ts +2 -0
  327. package/src/static-content-plugin.ts +4 -0
  328. package/src/table-plugin.ts +228 -37
  329. package/src/ui-action-plugin.ts +3 -8
  330. package/src/ui-page-plugin.ts +110 -21
  331. package/src/ui-policy-plugin.ts +2 -1
  332. package/src/user-preference-plugin.ts +2 -0
  333. package/src/utils.ts +42 -2
  334. package/src/ux-list-menu-config-plugin.ts +2 -0
  335. package/src/view-plugin.ts +11 -4
  336. package/src/workspace-plugin.ts +45 -43
  337. package/src/_types/eslint-plugin-es-x.d.ts +0 -17
@@ -0,0 +1,681 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SPPagePlugin = void 0;
7
+ const sdk_build_core_1 = require("@servicenow/sdk-build-core");
8
+ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
9
+ const utils_1 = require("../utils");
10
+ const utils_2 = require("./utils");
11
+ const default_placeholder_dimensions = `{
12
+ "mobile": {
13
+ "height": "250px",
14
+ "width": "100%"
15
+ },
16
+ "desktop": {
17
+ "height": "250px",
18
+ "width": "100%"
19
+ },
20
+ "tablet": {
21
+ "height": "250px",
22
+ "width": "100%"
23
+ }
24
+ }`;
25
+ const default_placeholder_template = `<!--
26
+ AngularJS template with configurable options.
27
+ Use the "options" object to control dynamic behavior.
28
+ Example: Display an element when max row count is 10:
29
+ <div ng-if="options.maxRowCount === 10"></div>
30
+ The "skeleton-container" class is used for loading placeholders.
31
+ -->
32
+ <div class="skeleton-container">
33
+ <!-- Header Skeleton -->
34
+ <div class="skeleton-box skeleton-header"></div>
35
+ <!-- Body Skeleton -->
36
+ <div class="skeleton-box skeleton-line"></div>
37
+ <div class="skeleton-box skeleton-line small"></div>
38
+ <div class="skeleton-box skeleton-line medium"></div>
39
+ </div>`;
40
+ const default_placeholder_script = `function evaluateConfig(options) { return {
41
+ "mobile": {
42
+ "height": "250px",
43
+ "width": "100%"
44
+ },
45
+ "desktop": {
46
+ "height": "250px",
47
+ "width": "100%"
48
+ },
49
+ "tablet": {
50
+ "height": "250px",
51
+ "width": "100%"
52
+ }
53
+ }; }`;
54
+ const defaultValues = {
55
+ container: {
56
+ width: 'container',
57
+ backgroundStyle: 'default',
58
+ subheader: false,
59
+ bootstrapAlt: false,
60
+ },
61
+ instance: {
62
+ active: true,
63
+ color: 'default',
64
+ size: 'md',
65
+ asyncLoadDeviceType: 'desktop,tablet,mobile',
66
+ },
67
+ column: {
68
+ size: 12,
69
+ },
70
+ page: {
71
+ category: 'custom',
72
+ useSeoScript: false,
73
+ shortDescription: '',
74
+ public: false,
75
+ draft: false,
76
+ omitWatcher: false,
77
+ internal: false,
78
+ },
79
+ };
80
+ /**
81
+ * Safely parse a size value from a Shape, handling non-numeric strings
82
+ * @param shape - The shape to extract the size from
83
+ * @param fieldName - The field name to extract (e.g., "size", "size_sm")
84
+ * @param defaultValue - Default value if parsing fails
85
+ * @returns Numeric size value or undefined
86
+ */
87
+ /**
88
+ * Sort an array of shapes by their order field
89
+ * @param shapes - Array of shapes to sort
90
+ * @returns Sorted array
91
+ */
92
+ function sortByOrder(shapes) {
93
+ return shapes.sort((a, b) => {
94
+ const aOrder = (0, utils_1.getFieldAsNumber)(a, 'order', 1);
95
+ const bOrder = (0, utils_1.getFieldAsNumber)(b, 'order', 1);
96
+ return (aOrder ?? 1) - (bOrder ?? 1);
97
+ });
98
+ }
99
+ /**
100
+ * Conditionally adds a property to an object if the value is not empty or undefined.
101
+ * Filters out undefined values, empty arrays, and empty strings to keep objects clean.
102
+ * @param obj - The target object to add the property to
103
+ * @param key - The property key to add
104
+ * @param value - The value to add (will be filtered if empty/undefined)
105
+ */
106
+ const addProperty = (obj, key, value, objectType) => {
107
+ if (value === undefined ||
108
+ (Array.isArray(value) && value.length === 0) ||
109
+ (typeof value === 'string' && value === '')) {
110
+ return;
111
+ }
112
+ // Check if value matches default for this object type
113
+ if (objectType && defaultValues[objectType] && defaultValues[objectType][key] === value) {
114
+ return;
115
+ }
116
+ obj[key] = value;
117
+ };
118
+ /**
119
+ * Creates a container object from a ServiceNow sp_container record Shape.
120
+ * Transforms database fields to Fluent API format and includes nested rows.
121
+ * @param container - The sp_container record Shape
122
+ * @param rows - Array of row objects that belong to this container
123
+ * @returns Formatted container object or undefined if container is empty
124
+ */
125
+ const getContainerObject = (container, rows) => {
126
+ if (!container || (0, isEmpty_1.default)(container)) {
127
+ return;
128
+ }
129
+ const name = container.get('name').ifString()?.getValue();
130
+ const width = container.get('width').ifString()?.getValue();
131
+ const backgroundStyle = container.get('background_style').ifString()?.getValue();
132
+ const backgroundColor = container.get('background_color').ifString()?.getValue();
133
+ const backgroundImage = container.get('background_image').ifString()?.getValue();
134
+ const cssClass = container.get('class_name').ifString()?.getValue();
135
+ const parentClass = container.get('container_class_name').ifString()?.getValue();
136
+ const subheader = container.get('subheader').toBoolean()?.getValue();
137
+ const bootstrapAlt = container.get('bootstrap_alt').toBoolean()?.getValue();
138
+ const semanticTag = container.get('semantic_tag').ifString()?.getValue();
139
+ const title = container.get('title').ifString()?.getValue();
140
+ const containerObject = {};
141
+ addProperty(containerObject, '$id', container.getId());
142
+ addProperty(containerObject, 'order', (0, utils_1.getFieldAsNumber)(container, 'order', 1));
143
+ addProperty(containerObject, 'name', name);
144
+ addProperty(containerObject, 'width', width, 'container');
145
+ addProperty(containerObject, 'backgroundStyle', backgroundStyle, 'container');
146
+ addProperty(containerObject, 'backgroundColor', backgroundColor, 'container');
147
+ addProperty(containerObject, 'backgroundImage', backgroundImage);
148
+ addProperty(containerObject, 'cssClass', cssClass);
149
+ addProperty(containerObject, 'parentClass', parentClass);
150
+ addProperty(containerObject, 'subheader', subheader, 'container');
151
+ addProperty(containerObject, 'bootstrapAlt', bootstrapAlt, 'container');
152
+ addProperty(containerObject, 'semanticTag', semanticTag);
153
+ addProperty(containerObject, 'title', title);
154
+ addProperty(containerObject, 'rows', rows);
155
+ return containerObject;
156
+ };
157
+ /**
158
+ * Creates a row object from a ServiceNow sp_row record Shape.
159
+ * Transforms database fields to Fluent API format and includes nested columns.
160
+ * @param row - The sp_row record Shape
161
+ * @param columns - Array of column objects that belong to this row
162
+ * @returns Formatted row object or undefined if row is empty
163
+ */
164
+ const getRowObject = (row, columns) => {
165
+ if (!row || (0, isEmpty_1.default)(row)) {
166
+ return;
167
+ }
168
+ const cssClass = row.get('class_name').ifString()?.getValue();
169
+ const semanticTag = row.get('semantic_tag').ifString()?.getValue();
170
+ const rowObject = {};
171
+ addProperty(rowObject, '$id', row.getId());
172
+ addProperty(rowObject, 'cssClass', cssClass);
173
+ addProperty(rowObject, 'semanticTag', semanticTag);
174
+ addProperty(rowObject, 'order', (0, utils_1.getFieldAsNumber)(row, 'order', 1));
175
+ addProperty(rowObject, 'columns', columns);
176
+ return rowObject;
177
+ };
178
+ /**
179
+ * Creates a column object from a ServiceNow sp_column record Shape.
180
+ * @param column - The sp_column record Shape
181
+ * @param instances - Array of instance objects that belong to this column
182
+ * @param nestedRows - Array of nested row objects within this column
183
+ * @returns Formatted column object or undefined if column is empty
184
+ */
185
+ const getColumnObject = (column, instances, nestedRows) => {
186
+ if (!column || (0, isEmpty_1.default)(column)) {
187
+ return;
188
+ }
189
+ const cssClass = column.get('class_name').ifString()?.getValue();
190
+ const semanticTag = column.get('semantic_tag').ifString()?.getValue();
191
+ const columnObject = {};
192
+ addProperty(columnObject, '$id', column.getId());
193
+ addProperty(columnObject, 'size', (0, utils_1.getFieldAsNumber)(column, 'size', 12), 'column');
194
+ addProperty(columnObject, 'sizeSm', (0, utils_1.getFieldAsNumber)(column, 'size_sm'));
195
+ addProperty(columnObject, 'sizeLg', (0, utils_1.getFieldAsNumber)(column, 'size_lg'));
196
+ addProperty(columnObject, 'sizeXs', (0, utils_1.getFieldAsNumber)(column, 'size_xs'));
197
+ addProperty(columnObject, 'cssClass', cssClass);
198
+ addProperty(columnObject, 'semanticTag', semanticTag);
199
+ addProperty(columnObject, 'order', (0, utils_1.getFieldAsNumber)(column, 'order', 1));
200
+ addProperty(columnObject, 'instances', instances);
201
+ addProperty(columnObject, 'nestedRows', nestedRows);
202
+ return columnObject;
203
+ };
204
+ /**
205
+ * Extracts and parses roles from a ServiceNow instance record.
206
+ * Converts comma-separated role string to an array of role names.
207
+ * @param instance - The sp_instance record Shape
208
+ * @returns Array of role names or undefined if no roles exist
209
+ */
210
+ const getRolesArray = (instance) => {
211
+ const rolesStr = instance.get('roles').ifString()?.getValue();
212
+ if (!rolesStr || rolesStr === '') {
213
+ return;
214
+ }
215
+ const rolesArray = rolesStr
216
+ .split(',')
217
+ .map((role) => role.trim())
218
+ .filter((role) => role !== '');
219
+ return rolesArray.length > 0 ? rolesArray : undefined;
220
+ };
221
+ /**
222
+ * Creates an instance object from a ServiceNow sp_instance record Shape.
223
+ * Transforms all instance properties from database format to Fluent API format,
224
+ * including widget references, styling, roles, and configuration.
225
+ * @param instance - The sp_instance record Shape
226
+ * @returns Formatted instance object or undefined if instance is empty
227
+ */
228
+ function getInstanceObject(instance) {
229
+ if (!instance || (0, isEmpty_1.default)(instance)) {
230
+ return;
231
+ }
232
+ const title = instance.get('title').ifString()?.getValue();
233
+ const id = instance.get('id').ifString()?.getValue();
234
+ const widget = instance.get('sp_widget').ifString()?.getValue();
235
+ const widgetParameters = instance.get('widget_parameters').ifString()?.getValue();
236
+ const css = instance.get('css').ifString()?.getValue();
237
+ const url = instance.get('url').ifString()?.getValue();
238
+ const glyph = instance.get('glyph').ifString()?.getValue();
239
+ const size = instance.get('size').ifString()?.getValue();
240
+ const color = instance.get('color').ifString()?.getValue();
241
+ const cssClass = instance.get('class_name').ifString()?.getValue();
242
+ const shortDescription = instance.get('short_description').ifString()?.getValue();
243
+ const active = instance.get('active').toBoolean()?.getValue();
244
+ const instanceObject = {};
245
+ addProperty(instanceObject, '$id', instance.getId());
246
+ addProperty(instanceObject, 'title', title);
247
+ addProperty(instanceObject, 'id', id);
248
+ addProperty(instanceObject, 'widget', widget);
249
+ addProperty(instanceObject, 'widgetParameters', widgetParameters);
250
+ addProperty(instanceObject, 'css', css);
251
+ addProperty(instanceObject, 'url', url);
252
+ addProperty(instanceObject, 'glyph', glyph);
253
+ addProperty(instanceObject, 'size', size, 'instance');
254
+ addProperty(instanceObject, 'color', color, 'instance');
255
+ addProperty(instanceObject, 'cssClass', cssClass);
256
+ addProperty(instanceObject, 'active', active, 'instance');
257
+ addProperty(instanceObject, 'order', (0, utils_1.getFieldAsNumber)(instance, 'order', 1));
258
+ addProperty(instanceObject, 'roles', getRolesArray(instance));
259
+ addProperty(instanceObject, 'shortDescription', shortDescription);
260
+ return instanceObject;
261
+ }
262
+ /**
263
+ * Recursively processes nested rows within a column
264
+ * @param columnRows - Rows that belong to the column
265
+ * @param allColumns - All available columns
266
+ * @param allInstances - All available instances
267
+ * @returns Array of processed SPRow objects with nested structure
268
+ */
269
+ function getNestedRows(columnRows, allRows, allColumns, allInstances) {
270
+ if (!columnRows || columnRows.length === 0) {
271
+ return [];
272
+ }
273
+ // Sort rows by order
274
+ const sortedRows = sortByOrder(columnRows);
275
+ return sortedRows
276
+ .map((row) => {
277
+ const rowId = row.getId();
278
+ // Get columns for this nested row
279
+ const rowColumns = sortByOrder(allColumns.filter((column) => column.get('sp_row').equals(rowId)));
280
+ const columns = rowColumns
281
+ .map((column) => {
282
+ const columnId = column.getId();
283
+ // Get instances for this column
284
+ const columnInstances = sortByOrder(allInstances.filter((instance) => instance.get('sp_column').equals(columnId)));
285
+ // Recursively get nested rows for this column
286
+ const nestedColumnRows = allRows.filter((row) => row.get('sp_column').equals(columnId));
287
+ const nestedRows = getNestedRows(nestedColumnRows, allRows, allColumns, allInstances);
288
+ const instances = columnInstances
289
+ .map((instance) => {
290
+ return getInstanceObject(instance);
291
+ })
292
+ .filter((instanceObject) => Boolean(instanceObject));
293
+ return getColumnObject(column, instances, nestedRows);
294
+ })
295
+ .filter((col) => Boolean(col));
296
+ const rowObj = getRowObject(row, columns);
297
+ return rowObj;
298
+ })
299
+ .filter((row) => Boolean(row));
300
+ }
301
+ /**
302
+ * Generates a container name from the container shape or creates a default name.
303
+ * Uses the explicit name if provided, otherwise generates a name based on page title and order.
304
+ * @param $ - The container shape object
305
+ * @param pageTitle - The title of the parent page
306
+ * @param index - The zero-based index of the container in the page
307
+ * @returns The container name string
308
+ */
309
+ const getContainerName = ($, pageTitle, index) => {
310
+ let name = $.get('name').ifString()?.getValue();
311
+ if (!name) {
312
+ const order = $.get('order').ifNumber()?.getValue() || index + 1;
313
+ name = `${pageTitle} - Container ${order}`;
314
+ }
315
+ return name;
316
+ };
317
+ /**
318
+ * Creates ServiceNow sp_container records from Fluent container shapes and their nested rows/columns/instances.
319
+ *
320
+ * @param containersArray - Array of Fluent container Shape objects to transform
321
+ * @param pageId - RecordId of the parent sp_page record that owns these containers
322
+ * @param pageTitle - Title of the parent page, used for generating default container names
323
+ * @param factory - Factory instance for creating ServiceNow records with proper relationships
324
+ * @returns Promise that resolves to an array of all created records (containers, rows, columns, instances)
325
+ */
326
+ const createContainerRecords = async (containersArray, pageId, pageTitle, factory) => {
327
+ const records = [];
328
+ for (let index = 0; index < containersArray.length; index++) {
329
+ const containerShape = containersArray[index];
330
+ if (containerShape?.isObject()) {
331
+ const container = containerShape.asObject();
332
+ const name = getContainerName(container, pageTitle, index);
333
+ const containerRecord = await factory.createRecord({
334
+ source: containerShape,
335
+ table: 'sp_container',
336
+ explicitId: container.get('$id'),
337
+ properties: container.transform(({ $ }) => ({
338
+ name: $.val(name),
339
+ sp_page: $.val(pageId),
340
+ width: $.from('width').def('container'),
341
+ background_style: $.from('backgroundStyle').def('default'),
342
+ background_color: $.from('backgroundColor').def(''),
343
+ background_image: $.from('backgroundImage').def(''),
344
+ class_name: $.from('cssClass').def(''),
345
+ container_class_name: $.from('parentClass').def(''),
346
+ subheader: $.from('subheader').def(false),
347
+ bootstrap_alt: $.from('bootstrapAlt').def(false),
348
+ semantic_tag: $.from('semanticTag').def(''),
349
+ title: $.from('title').def(''),
350
+ order: $.from('order').def(index + 1),
351
+ })),
352
+ });
353
+ records.push(containerRecord);
354
+ // Handle rows
355
+ const rows = container.get('rows').ifArray()?.getElements() || [];
356
+ const rowRecords = await createRowRecords(rows, containerRecord.getId(), factory, undefined);
357
+ records.push(...rowRecords);
358
+ }
359
+ }
360
+ return records;
361
+ };
362
+ /**
363
+ * Creates ServiceNow sp_row records from Fluent row shapes and their nested columns/instances.
364
+ *
365
+ * @param rowsArray - Array of Fluent row Shape objects to transform
366
+ * @param containerId - RecordId of the parent sp_container record that owns these rows
367
+ * @param factory - Factory instance for creating ServiceNow records with proper relationships
368
+ * @param columnId - RecordId of the parent sp_column record (for nested rows within columns)
369
+ * @returns Promise that resolves to an array of all created records (rows, columns, instances)
370
+ */
371
+ const createRowRecords = async (rowsArray, containerId, factory, columnId) => {
372
+ const records = [];
373
+ for (let index = 0; index < rowsArray.length; index++) {
374
+ const rowShape = rowsArray[index];
375
+ if (rowShape?.isObject()) {
376
+ const row = rowShape.asObject();
377
+ const rowRecord = await factory.createRecord({
378
+ source: rowShape,
379
+ table: 'sp_row',
380
+ explicitId: row.get('$id'),
381
+ properties: row.transform(({ $ }) => ({
382
+ sp_container: $.val(containerId),
383
+ class_name: $.from('cssClass').def(''),
384
+ semantic_tag: $.from('semanticTag').def(''),
385
+ order: $.from('order').def(index + 1),
386
+ sp_column: $.val(columnId),
387
+ })),
388
+ });
389
+ records.push(rowRecord);
390
+ // Handle columns
391
+ const columns = row.get('columns').ifArray()?.getElements() || [];
392
+ const columnRecords = await createColumnRecords(columns, rowRecord.getId(), factory);
393
+ records.push(...columnRecords);
394
+ }
395
+ }
396
+ return records;
397
+ };
398
+ /**
399
+ * Creates ServiceNow sp_column records from Fluent column shapes and their nested instances/rows.
400
+ *
401
+ * @param columnsArray - Array of Fluent column Shape objects to transform
402
+ * @param rowId - RecordId of the parent sp_row record that owns these columns
403
+ * @param factory - Factory instance for creating ServiceNow records with proper relationships
404
+ * @returns Promise that resolves to an array of all created records (columns, instances, nested rows)
405
+ */
406
+ async function createColumnRecords(columnsArray, rowId, factory) {
407
+ const records = [];
408
+ for (let index = 0; index < columnsArray.length; index++) {
409
+ const columnShape = columnsArray[index];
410
+ if (columnShape?.isObject()) {
411
+ const column = columnShape.asObject();
412
+ const columnRecord = await factory.createRecord({
413
+ source: columnShape,
414
+ table: 'sp_column',
415
+ explicitId: column.get('$id'),
416
+ properties: column.transform(({ $ }) => ({
417
+ sp_row: $.val(rowId),
418
+ size: $.from('size').def(12),
419
+ size_sm: $.from('sizeSm'),
420
+ size_lg: $.from('sizeLg'),
421
+ size_xs: $.from('sizeXs'),
422
+ class_name: $.from('cssClass').def(''),
423
+ semantic_tag: $.from('semanticTag').def(''),
424
+ order: $.from('order').def(index + 1),
425
+ })),
426
+ });
427
+ records.push(columnRecord);
428
+ // Handle instances
429
+ const instances = column.get('instances').ifArray()?.getElements() || [];
430
+ const nestedRows = column.get('nestedRows').ifArray()?.getElements() || [];
431
+ const nestedRowRecords = await createRowRecords(nestedRows, undefined, factory, columnRecord.getId());
432
+ records.push(...nestedRowRecords);
433
+ const instanceRecords = await createInstanceRecords(instances, columnRecord.getId(), factory);
434
+ records.push(...instanceRecords);
435
+ }
436
+ }
437
+ return records;
438
+ }
439
+ /**
440
+ * Creates ServiceNow sp_instance records from Fluent instance shapes.
441
+ *
442
+ * @param instancesArray - Array of Fluent instance Shape objects to transform
443
+ * @param columnId - RecordId of the parent sp_column record that owns these instances
444
+ * @param factory - Factory instance for creating ServiceNow records with proper relationships
445
+ * @returns Promise that resolves to an array of all created instance records
446
+ */
447
+ async function createInstanceRecords(instancesArray, columnId, factory) {
448
+ const records = [];
449
+ for (let index = 0; index < instancesArray.length; index++) {
450
+ const instanceShape = instancesArray[index];
451
+ if (instanceShape?.isObject()) {
452
+ const instance = instanceShape.asObject();
453
+ // Process roles if they exist as an array
454
+ const rolesString = (0, utils_2.getRolesString)(instance.get('roles'));
455
+ const instanceRecord = await factory.createRecord({
456
+ source: instanceShape,
457
+ table: 'sp_instance',
458
+ explicitId: instance.get('$id'),
459
+ properties: instance.transform(({ $ }) => ({
460
+ sp_column: $.val(columnId),
461
+ title: $.from('title').def(''),
462
+ id: $.from('id').def(''),
463
+ sp_widget: $.from('widget').map(utils_1.toReference).def(''),
464
+ widget_parameters: $.from('widgetParameters').def(''),
465
+ short_description: $.from('shortDescription').def(''),
466
+ css: $.from('css').def(''),
467
+ url: $.from('url').def(''),
468
+ glyph: $.from('glyph').def(''),
469
+ size: $.from('size').def('md'),
470
+ color: $.from('color').def('default'),
471
+ class_name: $.from('cssClass').def(''),
472
+ active: $.from('active').def(defaultValues.instance.active),
473
+ order: $.from('order').def(index + 1),
474
+ roles: $.val(rolesString).def(''),
475
+ async_load: $.from('asyncLoad').def(false),
476
+ async_load_trigger: $.from('asyncLoadTrigger').def('viewport'),
477
+ async_load_device_type: $.def(defaultValues.instance.asyncLoadDeviceType),
478
+ preserve_placeholder_size: $.def(false),
479
+ placeholder_dimensions: $.def(default_placeholder_dimensions),
480
+ advanced_placeholder_dimensions: $.def(false),
481
+ placeholder_dimensions_script: $.def(default_placeholder_script),
482
+ placeholder_template: $.def(default_placeholder_template),
483
+ })),
484
+ });
485
+ records.push(instanceRecord);
486
+ }
487
+ }
488
+ return records;
489
+ }
490
+ exports.SPPagePlugin = sdk_build_core_1.Plugin.create({
491
+ name: 'SPPagePlugin',
492
+ docs: [(0, utils_1.createSdkDocEntry)('SPPage', ['sp_page'])],
493
+ records: {
494
+ sp_page: {
495
+ coalesce: ['id'],
496
+ relationships: {
497
+ sp_container: {
498
+ via: 'sp_page',
499
+ descendant: true,
500
+ relationships: {
501
+ sp_row: {
502
+ via: 'sp_container',
503
+ descendant: true,
504
+ relationships: {
505
+ sp_column: {
506
+ via: 'sp_row',
507
+ descendant: true,
508
+ relationships: {
509
+ sp_instance: {
510
+ via: 'sp_column',
511
+ descendant: true,
512
+ },
513
+ sp_row: {
514
+ via: 'sp_column',
515
+ descendant: true,
516
+ },
517
+ },
518
+ },
519
+ },
520
+ },
521
+ },
522
+ },
523
+ },
524
+ toShape(record, { descendants }) {
525
+ // Build hierarchical structure from descendants in a single pass
526
+ // to avoid "node that was removed or forgotten" errors
527
+ // Get all descendants at once to avoid multiple queries
528
+ const allContainers = sortByOrder(descendants
529
+ .query('sp_container')
530
+ .filter((container) => container.get('sp_page').equals(record.getId())));
531
+ const allRows = descendants.query('sp_row');
532
+ const allColumns = descendants.query('sp_column');
533
+ const allInstances = descendants.query('sp_instance');
534
+ const containers = allContainers.map((container) => {
535
+ const containerId = container.getId();
536
+ // Get rows for this container
537
+ const containerRows = sortByOrder(allRows.filter((row) => row.get('sp_container').equals(containerId)));
538
+ const rows = containerRows
539
+ .map((row) => {
540
+ const rowId = row.getId();
541
+ // Get columns for this row
542
+ const rowColumns = sortByOrder(allColumns.filter((column) => column.get('sp_row').equals(rowId)));
543
+ const columns = rowColumns
544
+ .map((column) => {
545
+ const columnId = column.getId();
546
+ // Get instances for this column
547
+ const columnInstances = sortByOrder(allInstances.filter((instance) => instance.get('sp_column').equals(columnId)));
548
+ const columnRows = allRows.filter((row) => row.get('sp_column').equals(columnId));
549
+ const nestedRows = getNestedRows(columnRows, allRows, allColumns, allInstances);
550
+ const instances = columnInstances
551
+ .map((instance) => {
552
+ return getInstanceObject(instance);
553
+ })
554
+ .filter((instanceObject) => Boolean(instanceObject));
555
+ return getColumnObject(column, instances, nestedRows);
556
+ })
557
+ .filter((columnObject) => Boolean(columnObject));
558
+ return getRowObject(row, columns);
559
+ })
560
+ .filter((rowObject) => Boolean(rowObject));
561
+ return getContainerObject(container, rows);
562
+ });
563
+ // Process roles to check if they should be included
564
+ const rolesArray = getRolesArray(record);
565
+ return {
566
+ success: true,
567
+ value: new sdk_build_core_1.CallExpressionShape({
568
+ source: record,
569
+ callee: 'SPPage',
570
+ args: [
571
+ record.transform(({ $ }) => {
572
+ const pageObject = {
573
+ title: $,
574
+ category: $,
575
+ pageId: $.from('id').def(''),
576
+ draft: $.toBoolean().def(false),
577
+ internal: $.toBoolean().def(false),
578
+ omitWatcher: $.from('omit_watcher').toBoolean().def(false),
579
+ public: $.toBoolean().def(false),
580
+ useSeoScript: $.from('use_seo_script').toBoolean().def(false),
581
+ css: $.def(''),
582
+ shortDescription: $.from('short_description').def(''),
583
+ seoScript: $.from('seo_script').def(''),
584
+ dynamicTitleStructure: $.from('dynamic_title_structure').def(''),
585
+ humanReadableUrlStructure: $.from('human_readable_url_structure').def(''),
586
+ };
587
+ // Only add roles if they exist
588
+ if (rolesArray) {
589
+ pageObject['roles'] = $.val(rolesArray);
590
+ }
591
+ // Only add containers if they exist
592
+ if (containers.length > 0) {
593
+ pageObject['containers'] = $.val(containers);
594
+ }
595
+ return pageObject;
596
+ }),
597
+ ],
598
+ }),
599
+ };
600
+ },
601
+ },
602
+ },
603
+ shapes: [
604
+ {
605
+ shape: sdk_build_core_1.CallExpressionShape,
606
+ fileTypes: ['fluent'],
607
+ async toRecord(callExpression, { diagnostics, factory }) {
608
+ if (callExpression.getCallee() !== 'SPPage') {
609
+ return { success: false };
610
+ }
611
+ const page = callExpression.getArgument(0).asObject();
612
+ const containers = page.get('containers').ifArray()?.getElements() || [];
613
+ const useSeoScriptShape = page.get('useSeoScript');
614
+ const useSeoScript = useSeoScriptShape.ifBoolean()?.getValue() ?? false;
615
+ const seoScriptRef = (0, utils_1.toReference)(page.get('seoScript'));
616
+ const seoScript = typeof seoScriptRef === 'string' ? seoScriptRef : seoScriptRef.getValue();
617
+ if (useSeoScript && (!seoScript || seoScript.trim() === '')) {
618
+ diagnostics.error(useSeoScriptShape.getOriginalNode(), `Invalid SPPage configuration: when "useSeoScript" is true, "seoScript" must be added.`);
619
+ }
620
+ // Process roles if they exist as an array
621
+ const rolesString = (0, utils_2.getRolesString)(page.get('roles'));
622
+ const pageIdShape = page.get('pageId');
623
+ const pageId = pageIdShape.asString().getValue();
624
+ if (!pageId.trim()) {
625
+ diagnostics.error(pageIdShape.getOriginalNode(), 'Invalid SPPage configuration: "pageId" must be a non-empty string.');
626
+ }
627
+ const urlStructureShape = page.get('humanReadableUrlStructure');
628
+ const urlStructure = urlStructureShape.ifString()?.getValue();
629
+ if (urlStructure && urlStructure.length > 0) {
630
+ const delimiter = String(Math.floor(Math.random() * 100000));
631
+ const urlStrings = urlStructure
632
+ .replaceAll(/[/-]/g, delimiter)
633
+ .replaceAll('%', delimiter + '%')
634
+ .split(delimiter);
635
+ const nonVariables = [];
636
+ for (const segment of urlStrings) {
637
+ if (segment.length > 1 && segment.indexOf('%') === 0) {
638
+ continue;
639
+ }
640
+ nonVariables.push(segment);
641
+ }
642
+ if (!/^[a-zA-Z0-9/-]*$/.test(nonVariables.join(''))) {
643
+ diagnostics.error(urlStructureShape.getOriginalNode(), `Only alphanumeric characters, - and / are allowed in humanReadableUrlStructure.`);
644
+ }
645
+ if (urlStructure.indexOf('/') !== urlStructure.lastIndexOf('/')) {
646
+ diagnostics.error(urlStructureShape.getOriginalNode(), `No more than one "/" character is allowed in humanReadableUrlStructure.`);
647
+ }
648
+ }
649
+ const title = page.get('title').ifString()?.getValue() || pageId;
650
+ // Create the main page record
651
+ const pageRecord = await factory.createRecord({
652
+ source: callExpression,
653
+ table: 'sp_page',
654
+ properties: page.transform(({ $ }) => ({
655
+ id: $.from('pageId'),
656
+ title: $.val(title),
657
+ category: $.def('custom'),
658
+ css: $.def(''),
659
+ draft: $.def(false),
660
+ dynamic_title_structure: $.from('dynamicTitleStructure').def(''),
661
+ human_readable_url_structure: $.from('humanReadableUrlStructure').def(''),
662
+ internal: $.def(false),
663
+ omit_watcher: $.from('omitWatcher').def(false),
664
+ public: $.def(false),
665
+ roles: $.val(rolesString).def(''),
666
+ seo_script: $.from('seoScript').map(utils_1.toReference).def(''),
667
+ short_description: $.from('shortDescription').def(''),
668
+ use_seo_script: $.from('useSeoScript').def(false),
669
+ })),
670
+ });
671
+ // Create container, row, column, and instance records
672
+ const allRecords = await createContainerRecords(containers, pageRecord.getId(), title, factory);
673
+ return {
674
+ success: true,
675
+ value: pageRecord.with(...allRecords),
676
+ };
677
+ },
678
+ },
679
+ ],
680
+ });
681
+ //# sourceMappingURL=page-plugin.js.map