@aglyn/aglyn 1.0.0-beta.220 → 1.0.0-beta.222

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 (358) hide show
  1. package/package.json +15 -11
  2. package/src/lib/app-utils/agent-openapi.js +1 -1
  3. package/src/lib/app-utils/agent-openapi.js.map +1 -1
  4. package/src/lib/app-utils/analytics-events.d.ts +3 -2
  5. package/src/lib/app-utils/analytics-events.js +3 -2
  6. package/src/lib/app-utils/analytics-events.js.map +1 -1
  7. package/src/lib/app-utils/api-plugins.d.ts +30 -0
  8. package/src/lib/app-utils/api-plugins.js +24 -1
  9. package/src/lib/app-utils/api-plugins.js.map +1 -1
  10. package/src/lib/app-utils/author-html.d.ts +1 -1
  11. package/src/lib/app-utils/author-html.js.map +1 -1
  12. package/src/lib/app-utils/bandwidth-cap.d.ts +12 -1
  13. package/src/lib/app-utils/bandwidth-cap.js +17 -1
  14. package/src/lib/app-utils/bandwidth-cap.js.map +1 -1
  15. package/src/lib/app-utils/compose-reusable-components.d.ts +19 -0
  16. package/src/lib/app-utils/compose-reusable-components.js +116 -26
  17. package/src/lib/app-utils/compose-reusable-components.js.map +1 -1
  18. package/src/lib/app-utils/console-routes.d.ts +4 -0
  19. package/src/lib/app-utils/console-routes.js +3 -0
  20. package/src/lib/app-utils/console-routes.js.map +1 -1
  21. package/src/lib/app-utils/contacts.d.ts +71 -0
  22. package/src/lib/app-utils/contacts.js +55 -0
  23. package/src/lib/app-utils/contacts.js.map +1 -1
  24. package/src/lib/app-utils/contexts.d.ts +1 -0
  25. package/src/lib/app-utils/contexts.js +1 -0
  26. package/src/lib/app-utils/contexts.js.map +1 -1
  27. package/src/lib/app-utils/crm-email-templates.js +21 -4
  28. package/src/lib/app-utils/crm-email-templates.js.map +1 -1
  29. package/src/lib/app-utils/crm-kinds.d.ts +2 -0
  30. package/src/lib/app-utils/crm-kinds.js +1 -0
  31. package/src/lib/app-utils/crm-kinds.js.map +1 -1
  32. package/src/lib/app-utils/crm.d.ts +1199 -67
  33. package/src/lib/app-utils/crm.js +1951 -310
  34. package/src/lib/app-utils/crm.js.map +1 -1
  35. package/src/lib/app-utils/csv-import.d.ts +10 -38
  36. package/src/lib/app-utils/csv-import.js +17 -42
  37. package/src/lib/app-utils/csv-import.js.map +1 -1
  38. package/src/lib/app-utils/csv.d.ts +32 -11
  39. package/src/lib/app-utils/csv.js +43 -5
  40. package/src/lib/app-utils/csv.js.map +1 -1
  41. package/src/lib/app-utils/default-site.d.ts +116 -0
  42. package/src/lib/app-utils/default-site.js +1024 -0
  43. package/src/lib/app-utils/default-site.js.map +1 -0
  44. package/src/lib/app-utils/docs-help.generated.d.ts +23 -23
  45. package/src/lib/app-utils/docs-help.generated.js +47 -10
  46. package/src/lib/app-utils/docs-help.generated.js.map +1 -1
  47. package/src/lib/app-utils/docs-index.generated.js +746 -151
  48. package/src/lib/app-utils/docs-index.generated.js.map +1 -1
  49. package/src/lib/app-utils/draft-placeholders.d.ts +76 -0
  50. package/src/lib/app-utils/draft-placeholders.js +115 -0
  51. package/src/lib/app-utils/draft-placeholders.js.map +1 -0
  52. package/src/lib/app-utils/entity-picker-context.d.ts +19 -15
  53. package/src/lib/app-utils/entity-picker-context.js +4 -4
  54. package/src/lib/app-utils/entity-picker-context.js.map +1 -1
  55. package/src/lib/app-utils/expand-repeatables.d.ts +66 -10
  56. package/src/lib/app-utils/expand-repeatables.js +88 -14
  57. package/src/lib/app-utils/expand-repeatables.js.map +1 -1
  58. package/src/lib/app-utils/forms.d.ts +33 -22
  59. package/src/lib/app-utils/forms.js +47 -28
  60. package/src/lib/app-utils/forms.js.map +1 -1
  61. package/src/lib/app-utils/full-use-cost.d.ts +277 -0
  62. package/src/lib/app-utils/full-use-cost.js +421 -0
  63. package/src/lib/app-utils/full-use-cost.js.map +1 -0
  64. package/src/lib/app-utils/health-report.js +33 -0
  65. package/src/lib/app-utils/health-report.js.map +1 -1
  66. package/src/lib/app-utils/leaving-notice.d.ts +96 -0
  67. package/src/lib/app-utils/leaving-notice.js +157 -0
  68. package/src/lib/app-utils/leaving-notice.js.map +1 -0
  69. package/src/lib/app-utils/llms-txt.d.ts +20 -0
  70. package/src/lib/app-utils/llms-txt.js +7 -1
  71. package/src/lib/app-utils/llms-txt.js.map +1 -1
  72. package/src/lib/app-utils/media-asset-facts.d.ts +16 -1
  73. package/src/lib/app-utils/media-asset-facts.js +40 -13
  74. package/src/lib/app-utils/media-asset-facts.js.map +1 -1
  75. package/src/lib/app-utils/media-bandwidth.d.ts +52 -0
  76. package/src/lib/app-utils/media-bandwidth.js +94 -0
  77. package/src/lib/app-utils/media-bandwidth.js.map +1 -0
  78. package/src/lib/app-utils/media-ref.d.ts +241 -33
  79. package/src/lib/app-utils/media-ref.js +324 -43
  80. package/src/lib/app-utils/media-ref.js.map +1 -1
  81. package/src/lib/app-utils/media-src.d.ts +8 -8
  82. package/src/lib/app-utils/media-src.js +27 -11
  83. package/src/lib/app-utils/media-src.js.map +1 -1
  84. package/src/lib/app-utils/media-takedown-reach.d.ts +4 -1
  85. package/src/lib/app-utils/media-takedown-reach.js +6 -3
  86. package/src/lib/app-utils/media-takedown-reach.js.map +1 -1
  87. package/src/lib/app-utils/notifications.d.ts +1 -1
  88. package/src/lib/app-utils/notifications.js +2 -0
  89. package/src/lib/app-utils/notifications.js.map +1 -1
  90. package/src/lib/app-utils/operator-alerts.js +17 -0
  91. package/src/lib/app-utils/operator-alerts.js.map +1 -1
  92. package/src/lib/app-utils/organizations.d.ts +51 -2
  93. package/src/lib/app-utils/organizations.js +56 -3
  94. package/src/lib/app-utils/organizations.js.map +1 -1
  95. package/src/lib/app-utils/page-record-sources.d.ts +87 -0
  96. package/src/lib/app-utils/page-record-sources.js +53 -0
  97. package/src/lib/app-utils/page-record-sources.js.map +1 -0
  98. package/src/lib/app-utils/paid-media-source.d.ts +3 -7
  99. package/src/lib/app-utils/paid-media-source.js +5 -19
  100. package/src/lib/app-utils/paid-media-source.js.map +1 -1
  101. package/src/lib/app-utils/person-erasure.d.ts +5 -2
  102. package/src/lib/app-utils/person-erasure.js.map +1 -1
  103. package/src/lib/app-utils/picklists.d.ts +187 -0
  104. package/src/lib/app-utils/picklists.js +320 -0
  105. package/src/lib/app-utils/picklists.js.map +1 -0
  106. package/src/lib/app-utils/plan-entitlements.d.ts +220 -50
  107. package/src/lib/app-utils/plan-entitlements.js +309 -115
  108. package/src/lib/app-utils/plan-entitlements.js.map +1 -1
  109. package/src/lib/app-utils/realm-host-surface.generated.js +2 -0
  110. package/src/lib/app-utils/realm-host-surface.generated.js.map +1 -1
  111. package/src/lib/app-utils/release-flags.d.ts +1 -1
  112. package/src/lib/app-utils/release-flags.js +11 -0
  113. package/src/lib/app-utils/release-flags.js.map +1 -1
  114. package/src/lib/app-utils/rendered-widths.d.ts +121 -0
  115. package/src/lib/app-utils/rendered-widths.js +211 -0
  116. package/src/lib/app-utils/rendered-widths.js.map +1 -0
  117. package/src/lib/app-utils/repeat-sources.d.ts +2 -1
  118. package/src/lib/app-utils/repeat-sources.js.map +1 -1
  119. package/src/lib/app-utils/screen-link-context-value.d.ts +7 -0
  120. package/src/lib/app-utils/screen-link-context-value.js.map +1 -1
  121. package/src/lib/app-utils/screen-link-context.js +14 -2
  122. package/src/lib/app-utils/screen-link-context.js.map +1 -1
  123. package/src/lib/app-utils/screen-route.d.ts +157 -36
  124. package/src/lib/app-utils/screen-route.js +191 -41
  125. package/src/lib/app-utils/screen-route.js.map +1 -1
  126. package/src/lib/app-utils/seo-audit.d.ts +11 -1
  127. package/src/lib/app-utils/seo-audit.js +33 -13
  128. package/src/lib/app-utils/seo-audit.js.map +1 -1
  129. package/src/lib/app-utils/seo-keywords.d.ts +11 -0
  130. package/src/lib/app-utils/seo-keywords.js +19 -5
  131. package/src/lib/app-utils/seo-keywords.js.map +1 -1
  132. package/src/lib/app-utils/seo-page-facts.d.ts +47 -4
  133. package/src/lib/app-utils/seo-page-facts.js +136 -31
  134. package/src/lib/app-utils/seo-page-facts.js.map +1 -1
  135. package/src/lib/app-utils/seo-site-scan.d.ts +42 -4
  136. package/src/lib/app-utils/seo-site-scan.js +113 -12
  137. package/src/lib/app-utils/seo-site-scan.js.map +1 -1
  138. package/src/lib/app-utils/server.d.ts +5 -4
  139. package/src/lib/app-utils/server.js +14 -5
  140. package/src/lib/app-utils/server.js.map +1 -1
  141. package/src/lib/app-utils/site-icon-set.d.ts +195 -0
  142. package/src/lib/app-utils/site-icon-set.js +351 -0
  143. package/src/lib/app-utils/site-icon-set.js.map +1 -0
  144. package/src/lib/app-utils/site-interactions.d.ts +101 -4
  145. package/src/lib/app-utils/site-interactions.js +120 -4
  146. package/src/lib/app-utils/site-interactions.js.map +1 -1
  147. package/src/lib/app-utils/starter-template-nodes.d.ts +7 -0
  148. package/src/lib/app-utils/starter-template-nodes.js +3 -0
  149. package/src/lib/app-utils/starter-template-nodes.js.map +1 -1
  150. package/src/lib/app-utils/starter-templates.d.ts +5 -19
  151. package/src/lib/app-utils/starter-templates.js +5 -49
  152. package/src/lib/app-utils/starter-templates.js.map +1 -1
  153. package/src/lib/app-utils/transfer-launcher-context.d.ts +136 -0
  154. package/src/lib/app-utils/transfer-launcher-context.js +23 -0
  155. package/src/lib/app-utils/transfer-launcher-context.js.map +1 -0
  156. package/src/lib/app-utils/transfer-resume-import.d.ts +39 -0
  157. package/src/lib/app-utils/transfer-resume-import.js +128 -0
  158. package/src/lib/app-utils/transfer-resume-import.js.map +1 -0
  159. package/src/lib/app-utils/upgrade-proposal.d.ts +66 -0
  160. package/src/lib/app-utils/upgrade-proposal.js +95 -0
  161. package/src/lib/app-utils/upgrade-proposal.js.map +1 -0
  162. package/src/lib/app-utils/utc-month.d.ts +33 -0
  163. package/src/lib/app-utils/utc-month.js +35 -0
  164. package/src/lib/app-utils/utc-month.js.map +1 -0
  165. package/src/lib/app-utils/visitor-record-ceiling.d.ts +4 -4
  166. package/src/lib/app-utils/visitor-record-ceiling.js +4 -4
  167. package/src/lib/app-utils/visitor-record-ceiling.js.map +1 -1
  168. package/src/lib/app-utils/wire-nodes.d.ts +39 -19
  169. package/src/lib/app-utils/wire-nodes.js +120 -34
  170. package/src/lib/app-utils/wire-nodes.js.map +1 -1
  171. package/src/lib/data-transfer/access.d.ts +74 -0
  172. package/src/lib/data-transfer/access.js +93 -0
  173. package/src/lib/data-transfer/access.js.map +1 -0
  174. package/src/lib/data-transfer/derive.d.ts +246 -0
  175. package/src/lib/data-transfer/derive.js +1007 -0
  176. package/src/lib/data-transfer/derive.js.map +1 -0
  177. package/src/lib/data-transfer/export-file.d.ts +46 -0
  178. package/src/lib/data-transfer/export-file.js +146 -0
  179. package/src/lib/data-transfer/export-file.js.map +1 -0
  180. package/src/lib/data-transfer/field-catalog.d.ts +134 -0
  181. package/src/lib/data-transfer/field-catalog.js +278 -0
  182. package/src/lib/data-transfer/field-catalog.js.map +1 -0
  183. package/src/lib/data-transfer/header-match.d.ts +129 -0
  184. package/src/lib/data-transfer/header-match.js +367 -0
  185. package/src/lib/data-transfer/header-match.js.map +1 -0
  186. package/src/lib/data-transfer/index.d.ts +34 -0
  187. package/src/lib/data-transfer/index.js +40 -0
  188. package/src/lib/data-transfer/index.js.map +1 -0
  189. package/src/lib/data-transfer/job.d.ts +190 -0
  190. package/src/lib/data-transfer/job.js +229 -0
  191. package/src/lib/data-transfer/job.js.map +1 -0
  192. package/src/lib/data-transfer/lookup.d.ts +45 -0
  193. package/src/lib/data-transfer/lookup.js +71 -0
  194. package/src/lib/data-transfer/lookup.js.map +1 -0
  195. package/src/lib/data-transfer/match.d.ts +99 -0
  196. package/src/lib/data-transfer/match.js +244 -0
  197. package/src/lib/data-transfer/match.js.map +1 -0
  198. package/src/lib/data-transfer/package-plan.d.ts +205 -0
  199. package/src/lib/data-transfer/package-plan.js +475 -0
  200. package/src/lib/data-transfer/package-plan.js.map +1 -0
  201. package/src/lib/data-transfer/package.d.ts +181 -0
  202. package/src/lib/data-transfer/package.js +426 -0
  203. package/src/lib/data-transfer/package.js.map +1 -0
  204. package/src/lib/data-transfer/picklist-map.d.ts +139 -0
  205. package/src/lib/data-transfer/picklist-map.js +271 -0
  206. package/src/lib/data-transfer/picklist-map.js.map +1 -0
  207. package/src/lib/data-transfer/plan.d.ts +176 -0
  208. package/src/lib/data-transfer/plan.js +451 -0
  209. package/src/lib/data-transfer/plan.js.map +1 -0
  210. package/src/lib/data-transfer/policy.d.ts +170 -0
  211. package/src/lib/data-transfer/policy.js +378 -0
  212. package/src/lib/data-transfer/policy.js.map +1 -0
  213. package/src/lib/data-transfer/resource.d.ts +211 -0
  214. package/src/lib/data-transfer/resource.js +241 -0
  215. package/src/lib/data-transfer/resource.js.map +1 -0
  216. package/src/lib/data-transfer/review.d.ts +70 -0
  217. package/src/lib/data-transfer/review.js +233 -0
  218. package/src/lib/data-transfer/review.js.map +1 -0
  219. package/src/lib/data-transfer/similarity.d.ts +40 -0
  220. package/src/lib/data-transfer/similarity.js +106 -0
  221. package/src/lib/data-transfer/similarity.js.map +1 -0
  222. package/src/lib/data-transfer/site-package.d.ts +365 -0
  223. package/src/lib/data-transfer/site-package.js +1077 -0
  224. package/src/lib/data-transfer/site-package.js.map +1 -0
  225. package/src/lib/data-transfer/source.d.ts +74 -0
  226. package/src/lib/data-transfer/source.js +293 -0
  227. package/src/lib/data-transfer/source.js.map +1 -0
  228. package/src/lib/data-transfer/transfer-api.d.ts +898 -0
  229. package/src/lib/data-transfer/transfer-api.js +107 -0
  230. package/src/lib/data-transfer/transfer-api.js.map +1 -0
  231. package/src/lib/foundation/definitions/org-billing.types.d.ts +31 -0
  232. package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
  233. package/src/lib/foundation/definitions/organization.types.d.ts +42 -1
  234. package/src/lib/foundation/definitions/organization.types.js.map +1 -1
  235. package/src/lib/foundation/definitions/platform.types.d.ts +6 -4
  236. package/src/lib/foundation/definitions/platform.types.js.map +1 -1
  237. package/src/lib/foundation/index.d.ts +1 -1
  238. package/src/lib/foundation/index.js.map +1 -1
  239. package/src/lib/plugin-manager/feature-plugins.d.ts +91 -2
  240. package/src/lib/plugin-manager/feature-plugins.js +48 -3
  241. package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
  242. package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +56 -0
  243. package/src/lib/plugin-manager/first-party-plugins.generated.js +1132 -27
  244. package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
  245. package/src/lib/plugin-manager/index.d.ts +0 -1
  246. package/src/lib/plugin-manager/index.js +0 -1
  247. package/src/lib/plugin-manager/index.js.map +1 -1
  248. package/src/lib/plugin-manager/interaction-recipes.d.ts +142 -0
  249. package/src/lib/plugin-manager/interaction-recipes.js +104 -0
  250. package/src/lib/plugin-manager/interaction-recipes.js.map +1 -0
  251. package/src/lib/plugin-manager/interaction-step-checks.d.ts +66 -0
  252. package/src/lib/plugin-manager/interaction-step-checks.js +86 -0
  253. package/src/lib/plugin-manager/interaction-step-checks.js.map +1 -0
  254. package/src/lib/plugin-manager/plugin-artifact-types.d.ts +235 -0
  255. package/src/lib/plugin-manager/plugin-artifact-types.js +99 -0
  256. package/src/lib/plugin-manager/plugin-artifact-types.js.map +1 -0
  257. package/src/lib/plugin-manager/plugin-contact-capture.d.ts +8 -0
  258. package/src/lib/plugin-manager/plugin-contact-capture.js.map +1 -1
  259. package/src/lib/plugin-manager/plugin-conversion-credit.d.ts +216 -0
  260. package/src/lib/plugin-manager/plugin-conversion-credit.js +91 -0
  261. package/src/lib/plugin-manager/plugin-conversion-credit.js.map +1 -0
  262. package/src/lib/plugin-manager/plugin-entity-pickers.d.ts +83 -0
  263. package/src/lib/plugin-manager/plugin-entity-pickers.js +87 -0
  264. package/src/lib/plugin-manager/plugin-entity-pickers.js.map +1 -0
  265. package/src/lib/plugin-manager/plugin-host-resources.d.ts +6 -0
  266. package/src/lib/plugin-manager/plugin-host-resources.js +6 -1
  267. package/src/lib/plugin-manager/plugin-host-resources.js.map +1 -1
  268. package/src/lib/plugin-manager/plugin-intake-gates.d.ts +75 -0
  269. package/src/lib/plugin-manager/plugin-intake-gates.js +49 -0
  270. package/src/lib/plugin-manager/plugin-intake-gates.js.map +1 -0
  271. package/src/lib/plugin-manager/plugin-jobs.d.ts +5 -5
  272. package/src/lib/plugin-manager/plugin-jobs.js +7 -7
  273. package/src/lib/plugin-manager/plugin-jobs.js.map +1 -1
  274. package/src/lib/plugin-manager/plugin-live-paths.d.ts +70 -0
  275. package/src/lib/plugin-manager/plugin-live-paths.js +66 -0
  276. package/src/lib/plugin-manager/plugin-live-paths.js.map +1 -0
  277. package/src/lib/plugin-manager/plugin-org-erasure.d.ts +3 -2
  278. package/src/lib/plugin-manager/plugin-org-erasure.js +30 -5
  279. package/src/lib/plugin-manager/plugin-org-erasure.js.map +1 -1
  280. package/src/lib/plugin-manager/plugin-person-erasure.d.ts +68 -9
  281. package/src/lib/plugin-manager/plugin-person-erasure.js +196 -51
  282. package/src/lib/plugin-manager/plugin-person-erasure.js.map +1 -1
  283. package/src/lib/plugin-manager/plugin-person-records.d.ts +275 -0
  284. package/src/lib/plugin-manager/plugin-person-records.js +107 -0
  285. package/src/lib/plugin-manager/plugin-person-records.js.map +1 -0
  286. package/src/lib/plugin-manager/plugin-record-counts.d.ts +76 -0
  287. package/src/lib/plugin-manager/plugin-record-counts.js +49 -0
  288. package/src/lib/plugin-manager/plugin-record-counts.js.map +1 -0
  289. package/src/lib/plugin-manager/plugin-record-email-state.d.ts +26 -0
  290. package/src/lib/plugin-manager/plugin-record-email-state.js +16 -0
  291. package/src/lib/plugin-manager/plugin-record-email-state.js.map +1 -1
  292. package/src/lib/plugin-manager/plugin-record-index.d.ts +10 -0
  293. package/src/lib/plugin-manager/plugin-record-index.js.map +1 -1
  294. package/src/lib/plugin-manager/plugin-record-lists.d.ts +86 -6
  295. package/src/lib/plugin-manager/plugin-record-lists.js +42 -5
  296. package/src/lib/plugin-manager/plugin-record-lists.js.map +1 -1
  297. package/src/lib/plugin-manager/plugin-record-origin.d.ts +79 -0
  298. package/src/lib/plugin-manager/plugin-record-origin.js +46 -0
  299. package/src/lib/plugin-manager/plugin-record-origin.js.map +1 -0
  300. package/src/lib/plugin-manager/plugin-record-pages.d.ts +37 -0
  301. package/src/lib/plugin-manager/plugin-record-pages.js +52 -0
  302. package/src/lib/plugin-manager/plugin-record-pages.js.map +1 -0
  303. package/src/lib/plugin-manager/plugin-record-timeline.d.ts +60 -0
  304. package/src/lib/plugin-manager/plugin-record-timeline.js +16 -0
  305. package/src/lib/plugin-manager/plugin-record-timeline.js.map +1 -1
  306. package/src/lib/plugin-manager/plugin-resource-drafts.d.ts +5 -5
  307. package/src/lib/plugin-manager/plugin-resource-drafts.js.map +1 -1
  308. package/src/lib/plugin-manager/plugin-revocations.d.ts +64 -0
  309. package/src/lib/plugin-manager/plugin-revocations.js +47 -0
  310. package/src/lib/plugin-manager/plugin-revocations.js.map +1 -0
  311. package/src/lib/plugin-manager/plugin-send-tallies.d.ts +69 -0
  312. package/src/lib/plugin-manager/plugin-send-tallies.js +45 -0
  313. package/src/lib/plugin-manager/plugin-send-tallies.js.map +1 -0
  314. package/src/lib/plugin-manager/plugin-server-steps.d.ts +170 -0
  315. package/src/lib/plugin-manager/plugin-server-steps.js +116 -0
  316. package/src/lib/plugin-manager/plugin-server-steps.js.map +1 -0
  317. package/src/lib/plugin-manager/plugin-site-bundle.d.ts +40 -0
  318. package/src/lib/plugin-manager/plugin-site-bundle.js +4 -0
  319. package/src/lib/plugin-manager/plugin-site-bundle.js.map +1 -1
  320. package/src/lib/plugin-manager/plugin-site-export.d.ts +57 -1
  321. package/src/lib/plugin-manager/plugin-site-export.js +23 -10
  322. package/src/lib/plugin-manager/plugin-site-export.js.map +1 -1
  323. package/src/lib/plugin-manager/plugin-sitemap-readers.d.ts +146 -0
  324. package/src/lib/plugin-manager/plugin-sitemap-readers.js +110 -0
  325. package/src/lib/plugin-manager/plugin-sitemap-readers.js.map +1 -0
  326. package/src/lib/plugin-manager/plugin-transfer-resources.d.ts +714 -0
  327. package/src/lib/plugin-manager/plugin-transfer-resources.js +443 -0
  328. package/src/lib/plugin-manager/plugin-transfer-resources.js.map +1 -0
  329. package/src/lib/plugin-manager/plugin-usage-axes.d.ts +54 -5
  330. package/src/lib/plugin-manager/plugin-usage-axes.js +11 -3
  331. package/src/lib/plugin-manager/plugin-usage-axes.js.map +1 -1
  332. package/src/lib/plugin-manager/plugin-user-erasure.js +9 -1
  333. package/src/lib/plugin-manager/plugin-user-erasure.js.map +1 -1
  334. package/src/lib/plugin-manager/plugin-visitor-doors.d.ts +104 -0
  335. package/src/lib/plugin-manager/plugin-visitor-doors.js +108 -0
  336. package/src/lib/plugin-manager/plugin-visitor-doors.js.map +1 -0
  337. package/src/lib/plugin-manager/realm-host-aglyn.generated.js +2 -0
  338. package/src/lib/plugin-manager/realm-host-aglyn.generated.js.map +1 -1
  339. package/src/lib/plugin-manager/repeat-rows.d.ts +5 -6
  340. package/src/lib/plugin-manager/repeat-rows.js.map +1 -1
  341. package/src/lib/app-utils/actions.d.ts +0 -310
  342. package/src/lib/app-utils/actions.js +0 -506
  343. package/src/lib/app-utils/actions.js.map +0 -1
  344. package/src/lib/app-utils/automation-placeholders.d.ts +0 -72
  345. package/src/lib/app-utils/automation-placeholders.js +0 -207
  346. package/src/lib/app-utils/automation-placeholders.js.map +0 -1
  347. package/src/lib/app-utils/dataset-models.d.ts +0 -339
  348. package/src/lib/app-utils/dataset-models.js +0 -722
  349. package/src/lib/app-utils/dataset-models.js.map +0 -1
  350. package/src/lib/app-utils/datasets.d.ts +0 -171
  351. package/src/lib/app-utils/datasets.js +0 -227
  352. package/src/lib/app-utils/datasets.js.map +0 -1
  353. package/src/lib/app-utils/form-abuse-ceiling.d.ts +0 -146
  354. package/src/lib/app-utils/form-abuse-ceiling.js +0 -158
  355. package/src/lib/app-utils/form-abuse-ceiling.js.map +0 -1
  356. package/src/lib/plugin-manager/order-fulfilment.d.ts +0 -142
  357. package/src/lib/plugin-manager/order-fulfilment.js +0 -104
  358. package/src/lib/plugin-manager/order-fulfilment.js.map +0 -1
@@ -0,0 +1,1077 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
3
+ /**
4
+ * @license
5
+ * Copyright 2026 Aglyn LLC
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */ import { REUSABLE_INSTANCE_COMPONENT_ID } from "../app-utils/reusable-component-keys.js";
19
+ import { SCREEN_KIND_EMAIL } from "../app-utils/screen-route.js";
20
+ import { listPluginSiteExportCollections } from "../plugin-manager/plugin-site-export.js";
21
+ import { listDeclaredSiteBundleSections } from "../plugin-manager/plugin-site-bundle.js";
22
+ import { contentHash, keepBothSlug, matchPackageItems, packageDecisionsFor, packageDependencyClosure, packageItemKey, proposePackageDecision, readPackageManifest, TRANSFER_PACKAGE_FORMAT, TRANSFER_PACKAGE_VERSION } from "./package.js";
23
+ /** The singleton id of the site's settings item. */ export const SITE_SETTINGS_ITEM_ID = 'settings';
24
+ /** The singleton id of the site's theme item. */ export const SITE_THEME_ITEM_ID = 'theme';
25
+ /** The two kinds a site's screens are listed as. */ export const SITE_SCREEN_KINDS = [
26
+ 'page',
27
+ 'email'
28
+ ];
29
+ const SCREEN_REFS = SITE_SCREEN_KINDS;
30
+ /** The platform's own kinds, in the order an export lists them. */ export const PLATFORM_SITE_PACKAGE_KINDS = [
31
+ {
32
+ kind: 'settings',
33
+ label: 'Site settings',
34
+ source: 'platform',
35
+ bundleKey: 'host',
36
+ mergeable: true,
37
+ wordIds: true,
38
+ noCopies: true,
39
+ singletonId: SITE_SETTINGS_ITEM_ID,
40
+ references: [
41
+ {
42
+ field: 'notFoundScreenId',
43
+ kinds: SCREEN_REFS
44
+ },
45
+ {
46
+ field: 'errorScreens',
47
+ kinds: SCREEN_REFS,
48
+ each: 'values'
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ kind: 'theme',
54
+ label: 'Theme',
55
+ source: 'platform',
56
+ bundleKey: 'host',
57
+ mergeable: true,
58
+ wordIds: true,
59
+ noCopies: true,
60
+ singletonId: SITE_THEME_ITEM_ID
61
+ },
62
+ {
63
+ kind: 'page',
64
+ label: 'Pages',
65
+ source: 'platform',
66
+ bundleKey: 'screens',
67
+ slugField: 'slug',
68
+ nameField: 'displayName',
69
+ versioned: true,
70
+ references: [
71
+ {
72
+ field: 'layoutId',
73
+ kinds: [
74
+ 'layout'
75
+ ]
76
+ },
77
+ {
78
+ field: 'parentId',
79
+ kinds: SCREEN_REFS
80
+ },
81
+ {
82
+ field: 'localeVariants',
83
+ kinds: SCREEN_REFS,
84
+ each: 'values'
85
+ }
86
+ ]
87
+ },
88
+ {
89
+ kind: 'email',
90
+ label: 'Email designs',
91
+ source: 'platform',
92
+ bundleKey: 'screens',
93
+ slugField: 'slug',
94
+ nameField: 'displayName',
95
+ versioned: true,
96
+ references: [
97
+ {
98
+ field: 'layoutId',
99
+ kinds: [
100
+ 'layout'
101
+ ]
102
+ },
103
+ {
104
+ field: 'parentId',
105
+ kinds: SCREEN_REFS
106
+ }
107
+ ]
108
+ },
109
+ {
110
+ kind: 'emailTemplate',
111
+ label: 'Site emails',
112
+ source: 'platform',
113
+ bundleKey: 'emailTemplates',
114
+ versioned: true,
115
+ wordIds: true,
116
+ noCopies: true
117
+ },
118
+ {
119
+ kind: 'layout',
120
+ label: 'Layouts',
121
+ source: 'platform',
122
+ bundleKey: 'layouts',
123
+ nameField: 'displayName',
124
+ versioned: true,
125
+ references: [
126
+ {
127
+ field: 'layoutId',
128
+ kinds: [
129
+ 'layout'
130
+ ]
131
+ }
132
+ ]
133
+ },
134
+ {
135
+ kind: 'component',
136
+ label: 'Components',
137
+ source: 'platform',
138
+ bundleKey: 'components',
139
+ nameField: 'displayName'
140
+ },
141
+ {
142
+ kind: 'author',
143
+ label: 'Authors',
144
+ source: 'platform',
145
+ bundleKey: 'authors',
146
+ slugField: 'slug',
147
+ nameField: 'name'
148
+ },
149
+ {
150
+ kind: 'collection',
151
+ label: 'Collections',
152
+ source: 'platform',
153
+ bundleKey: 'collections',
154
+ slugField: 'slug',
155
+ nameField: 'displayName',
156
+ references: [
157
+ {
158
+ field: 'listScreenId',
159
+ kinds: SCREEN_REFS
160
+ },
161
+ {
162
+ field: 'entryScreenId',
163
+ kinds: SCREEN_REFS
164
+ },
165
+ {
166
+ field: 'templateScreenId',
167
+ kinds: SCREEN_REFS
168
+ }
169
+ ]
170
+ },
171
+ {
172
+ kind: 'mediaFolder',
173
+ label: 'Media folders (workspace library)',
174
+ source: 'platform',
175
+ bundleKey: 'mediaFolders',
176
+ references: [
177
+ {
178
+ field: 'parentId',
179
+ kinds: [
180
+ 'mediaFolder'
181
+ ]
182
+ }
183
+ ]
184
+ },
185
+ {
186
+ kind: 'media',
187
+ label: 'Media (workspace library)',
188
+ source: 'platform',
189
+ bundleKey: 'media',
190
+ keepsOwnId: true,
191
+ references: [
192
+ {
193
+ field: 'folderId',
194
+ kinds: [
195
+ 'mediaFolder'
196
+ ]
197
+ }
198
+ ]
199
+ },
200
+ {
201
+ kind: 'siteMediaFolder',
202
+ label: 'Media folders (site library)',
203
+ source: 'platform',
204
+ bundleKey: 'hostMediaFolders',
205
+ references: [
206
+ {
207
+ field: 'parentId',
208
+ kinds: [
209
+ 'siteMediaFolder'
210
+ ]
211
+ }
212
+ ]
213
+ },
214
+ {
215
+ kind: 'siteMedia',
216
+ label: 'Media (site library)',
217
+ source: 'platform',
218
+ bundleKey: 'hostMedia',
219
+ keepsOwnId: true,
220
+ references: [
221
+ {
222
+ field: 'folderId',
223
+ kinds: [
224
+ 'siteMediaFolder'
225
+ ]
226
+ }
227
+ ]
228
+ },
229
+ {
230
+ kind: 'savedTheme',
231
+ label: 'Saved themes',
232
+ source: 'platform',
233
+ bundleKey: 'themes',
234
+ nameField: 'name',
235
+ wordIds: true
236
+ }
237
+ ];
238
+ /**
239
+ * Every kind a site package carries: the platform's, then each host
240
+ * collection a plugin declares for the backup, then each backup section, in
241
+ * config order. Throws when two declare one kind — the generator refuses
242
+ * that, so it only fires for a hand-edited catalog.
243
+ */ export function listSitePackageKinds() {
244
+ const kinds = [
245
+ ...PLATFORM_SITE_PACKAGE_KINDS
246
+ ];
247
+ for (const declared of listPluginSiteExportCollections()){
248
+ var _pkg_references;
249
+ var _pkg_placements;
250
+ const pkg = declared.package;
251
+ kinds.push(_extends({
252
+ kind: pkg.kind,
253
+ label: pkg.label,
254
+ source: 'collection',
255
+ bundleKey: declared.collection
256
+ }, pkg.slugField ? {
257
+ slugField: pkg.slugField
258
+ } : {}, pkg.nameField ? {
259
+ nameField: pkg.nameField
260
+ } : {}, {
261
+ references: ((_pkg_references = pkg.references) != null ? _pkg_references : []).map((ref)=>({
262
+ field: ref.field,
263
+ kinds: [
264
+ ref.kind
265
+ ]
266
+ }))
267
+ }, pkg.bindingToken ? {
268
+ bindingToken: pkg.bindingToken
269
+ } : {}, ((_pkg_placements = pkg.placements) == null ? void 0 : _pkg_placements.length) ? {
270
+ placements: pkg.placements
271
+ } : {}));
272
+ }
273
+ for (const declared of listDeclaredSiteBundleSections()){
274
+ var _pkg_placements1;
275
+ const pkg = declared.package;
276
+ kinds.push(_extends({
277
+ kind: pkg.kind,
278
+ label: pkg.label,
279
+ source: 'section',
280
+ bundleKey: declared.key
281
+ }, pkg.slugField ? {
282
+ slugField: pkg.slugField
283
+ } : {}, pkg.nameField ? {
284
+ nameField: pkg.nameField
285
+ } : {}, ((_pkg_placements1 = pkg.placements) == null ? void 0 : _pkg_placements1.length) ? {
286
+ placements: pkg.placements
287
+ } : {}));
288
+ }
289
+ const seen = new Set();
290
+ for (const one of kinds){
291
+ if (seen.has(one.kind)) throw new Error(`site package kind "${one.kind}" is declared twice`);
292
+ seen.add(one.kind);
293
+ }
294
+ return kinds;
295
+ }
296
+ /** The kinds by name. */ export function sitePackageKindMap(kinds = listSitePackageKinds()) {
297
+ return new Map(kinds.map((one)=>[
298
+ one.kind,
299
+ one
300
+ ]));
301
+ }
302
+ /** The routing map's host field: screen id → address. */ export const SITE_ROUTING_MAP_FIELD = 'screens';
303
+ /**
304
+ * A plain object, from any realm: one whose prototype is some realm's
305
+ * `Object.prototype` (itself prototype-less) or `null`. A request body parsed
306
+ * by the platform's fetch is a plain object of the host realm, not the
307
+ * module's, so identity with this realm's `Object.prototype` is not the test.
308
+ * Class instances — a `Timestamp`, a `Buffer` — are not plain.
309
+ */ export function isPlainSiteObject(value) {
310
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
311
+ const proto = Object.getPrototypeOf(value);
312
+ return proto === null || Object.getPrototypeOf(proto) === null;
313
+ }
314
+ function asDoc(value) {
315
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
316
+ }
317
+ function pick(source, fields) {
318
+ const out = {};
319
+ for (const field of fields)if (source[field] !== undefined) out[field] = source[field];
320
+ return Object.keys(out).length ? out : null;
321
+ }
322
+ /** The kind a screen is listed as: an email design, or a page. */ export function screenPackageKind(screen) {
323
+ return screen['kind'] === SCREEN_KIND_EMAIL ? 'email' : 'page';
324
+ }
325
+ /**
326
+ * A v1 backup's documents as package items, in kind order. Each array is
327
+ * capped at the contract's limit for it; a document with no `$id` is not an
328
+ * item. A screen's address in the routing map travels with it as `route`;
329
+ * an address naming a screen the backup does not carry is not an item and
330
+ * is dropped.
331
+ */ export function siteBundleItems(bundle, contract, kinds = listSitePackageKinds()) {
332
+ const host = asDoc(bundle.host);
333
+ const routes = asDoc(host[SITE_ROUTING_MAP_FIELD]);
334
+ const items = [];
335
+ const arrays = new Map();
336
+ const array = (key)=>{
337
+ if (!arrays.has(key)) {
338
+ const raw = Array.isArray(bundle[key]) ? bundle[key] : [];
339
+ const limit = contract.limits[key];
340
+ arrays.set(key, (limit === undefined ? raw : raw.slice(0, limit)).map(asDoc));
341
+ }
342
+ return arrays.get(key);
343
+ };
344
+ for (const kind of kinds){
345
+ if (kind.singletonId) {
346
+ const fields = kind.kind === 'theme' ? contract.themeFields : kind.kind === 'settings' ? contract.settingsFields : [];
347
+ const content = pick(host, fields);
348
+ if (content) items.push({
349
+ kind: kind.kind,
350
+ id: kind.singletonId,
351
+ content
352
+ });
353
+ continue;
354
+ }
355
+ for (const doc of array(kind.bundleKey)){
356
+ const id = doc['$id'];
357
+ if (typeof id !== 'string' && typeof id !== 'number') continue;
358
+ if (kind.bundleKey === 'screens' && screenPackageKind(doc) !== kind.kind) continue;
359
+ const { $id: _id } = doc, rest = _object_without_properties_loose(doc, [
360
+ "$id"
361
+ ]);
362
+ const content = _extends({}, rest);
363
+ if (kind.bundleKey === 'screens') {
364
+ const route = routes[String(id)];
365
+ if (typeof route === 'string') content['route'] = route;
366
+ else delete content['route'];
367
+ }
368
+ items.push({
369
+ kind: kind.kind,
370
+ id: String(id),
371
+ content
372
+ });
373
+ }
374
+ }
375
+ return items;
376
+ }
377
+ /**
378
+ * Writes as the v1 shape the restore's writers read: each kind's documents
379
+ * under its array, with `$id` set to the id it is written under, and the
380
+ * site's own fields as one host patch.
381
+ */ export function siteWritesToBundle(writes, kinds = sitePackageKindMap()) {
382
+ const bundle = {};
383
+ const hostPatch = {};
384
+ const routes = {};
385
+ for (const write of writes){
386
+ var _bundle, _kind_bundleKey, _;
387
+ const kind = kinds.get(write.kind);
388
+ if (!kind) throw new Error(`site package kind "${write.kind}" is not one this site reads`);
389
+ if (kind.singletonId) {
390
+ Object.assign(hostPatch, write.content);
391
+ continue;
392
+ }
393
+ const _write_content = write.content, { route } = _write_content, rest = _object_without_properties_loose(_write_content, [
394
+ "route"
395
+ ]);
396
+ if (kind.bundleKey === 'screens' && typeof route === 'string') routes[write.targetId] = route;
397
+ ((_ = (_bundle = bundle)[_kind_bundleKey = kind.bundleKey]) != null ? _ : _bundle[_kind_bundleKey] = []).push(_extends({}, kind.bundleKey === 'screens' ? rest : write.content, {
398
+ $id: write.targetId
399
+ }));
400
+ }
401
+ if (Object.keys(routes).length) hostPatch[SITE_ROUTING_MAP_FIELD] = routes;
402
+ return {
403
+ bundle,
404
+ hostPatch
405
+ };
406
+ }
407
+ /*==========================================
408
+ * REFERENCES
409
+ *=========================================*/ /** Ids searched for inside text are at least this long, so a word is never one. */ export const SITE_REFERENCE_MIN_ID_LENGTH = 8;
410
+ const ID_TOKEN = /[A-Za-z0-9_-]+/g;
411
+ const VAR_TOKEN = /\{\{\s*var:([a-zA-Z0-9_-]{1,64})\s*\}\}/g;
412
+ const FN_TOKEN = /\{\{\s*fn:([a-zA-Z0-9_-]{1,64})(?: [a-zA-Z0-9_-]{1,64})*\s*\([^)]*\)\s*\}\}/g;
413
+ /** An index over items (the package's, and the site's when importing). */ export function siteReferenceIndex(items, kinds = sitePackageKindMap()) {
414
+ const byId = new Map();
415
+ for (const item of items){
416
+ var _byId_get;
417
+ const list = (_byId_get = byId.get(item.id)) != null ? _byId_get : [];
418
+ if (!list.includes(item.kind)) list.push(item.kind);
419
+ byId.set(item.id, list);
420
+ }
421
+ return {
422
+ kindsOf: (id)=>{
423
+ var _byId_get;
424
+ return (_byId_get = byId.get(id)) != null ? _byId_get : [];
425
+ },
426
+ searchable: (id)=>{
427
+ var _byId_get;
428
+ return id.length >= SITE_REFERENCE_MIN_ID_LENGTH && ((_byId_get = byId.get(id)) != null ? _byId_get : []).some((kind)=>{
429
+ var _kinds_get;
430
+ return !((_kinds_get = kinds.get(kind)) == null ? void 0 : _kinds_get.wordIds);
431
+ });
432
+ }
433
+ };
434
+ }
435
+ function eachString(value, visit, keys = true) {
436
+ if (typeof value === 'string') {
437
+ visit(value);
438
+ return;
439
+ }
440
+ if (Array.isArray(value)) {
441
+ for (const entry of value)eachString(entry, visit, keys);
442
+ return;
443
+ }
444
+ if (value && typeof value === 'object' && !ArrayBuffer.isView(value)) {
445
+ for (const [key, entry] of Object.entries(value)){
446
+ if (keys) visit(key);
447
+ eachString(entry, visit, keys);
448
+ }
449
+ }
450
+ }
451
+ /** The node maps an item's content holds: its own, and its published version's. */ function nodeMaps(content) {
452
+ const maps = [];
453
+ for (const holder of [
454
+ content,
455
+ asDoc(content['version'])
456
+ ]){
457
+ for (const key of [
458
+ 'nodes',
459
+ 'elements'
460
+ ]){
461
+ const nodes = holder[key];
462
+ if (nodes && typeof nodes === 'object' && !Array.isArray(nodes) && !ArrayBuffer.isView(nodes)) {
463
+ maps.push(nodes);
464
+ }
465
+ }
466
+ }
467
+ return maps;
468
+ }
469
+ /**
470
+ * The items one item depends on: its typed references (fields, node
471
+ * placements, binding tokens) whether or not the item they name is known,
472
+ * then every other known id its content names. Never itself.
473
+ */ export function siteItemDependencies(item, index, kinds = sitePackageKindMap(), sections = {}) {
474
+ var _ref;
475
+ const kind = kinds.get(item.kind);
476
+ const found = new Map();
477
+ const add = (depKind, id)=>{
478
+ if (typeof id !== 'string' || !id) return;
479
+ if (depKind === item.kind && id === item.id) return;
480
+ found.set(`${depKind}/${id}`, {
481
+ kind: depKind,
482
+ id
483
+ });
484
+ };
485
+ const typed = (candidates, id)=>{
486
+ var _candidates_find;
487
+ if (typeof id !== 'string' || !id) return;
488
+ const known = index.kindsOf(id);
489
+ add((_candidates_find = candidates.find((one)=>known.includes(one))) != null ? _candidates_find : candidates[0], id);
490
+ };
491
+ const content = item.content;
492
+ for (const ref of (_ref = kind == null ? void 0 : kind.references) != null ? _ref : []){
493
+ const value = content[ref.field];
494
+ if (ref.each === 'values') for (const entry of Object.values(asDoc(value)))typed(ref.kinds, entry);
495
+ else if (ref.each === 'items') for (const entry of Array.isArray(value) ? value : [])typed(ref.kinds, entry);
496
+ else typed(ref.kinds, value);
497
+ }
498
+ if (kind == null ? void 0 : kind.versioned) typed([
499
+ 'layout'
500
+ ], asDoc(content['version'])['layoutId']);
501
+ if (item.kind === 'collection') {
502
+ for (const entry of Array.isArray(content['entries']) ? content['entries'] : []){
503
+ typed([
504
+ 'author'
505
+ ], asDoc(entry)['authorId']);
506
+ }
507
+ }
508
+ const placements = [];
509
+ const tokenKinds = {};
510
+ for (const one of kinds.values()){
511
+ var _one_placements;
512
+ for (const placement of (_one_placements = one.placements) != null ? _one_placements : [])placements.push(_extends({
513
+ kind: one.kind
514
+ }, placement));
515
+ if (one.bindingToken) tokenKinds[one.bindingToken] = one.kind;
516
+ }
517
+ for (const nodes of nodeMaps(content)){
518
+ for (const node of Object.values(nodes)){
519
+ const shape = asDoc(node);
520
+ const props = asDoc(shape['props']);
521
+ if (shape['componentId'] === REUSABLE_INSTANCE_COMPONENT_ID) typed([
522
+ 'component'
523
+ ], props['refId']);
524
+ for (const placement of placements){
525
+ if (placement.componentId && placement.componentId !== shape['componentId']) continue;
526
+ typed([
527
+ placement.kind
528
+ ], props[placement.prop]);
529
+ }
530
+ }
531
+ }
532
+ eachString(content, (text)=>{
533
+ if (!text.includes('{{')) return;
534
+ if (tokenKinds['var']) for (const match of text.matchAll(VAR_TOKEN))typed([
535
+ tokenKinds['var']
536
+ ], match[1]);
537
+ if (tokenKinds['fn']) for (const match of text.matchAll(FN_TOKEN))typed([
538
+ tokenKinds['fn']
539
+ ], match[1]);
540
+ }, false);
541
+ const section = sections[item.kind];
542
+ if (section) {
543
+ for (const dep of section.dependencies(_extends({
544
+ $id: item.id
545
+ }, content)))add(dep.kind, dep.id);
546
+ }
547
+ eachString(content, (text)=>{
548
+ var _text_match;
549
+ for (const token of (_text_match = text.match(ID_TOKEN)) != null ? _text_match : []){
550
+ if (token === item.id || !index.searchable(token)) continue;
551
+ for (const known of index.kindsOf(token)){
552
+ var _kinds_get;
553
+ if (!found.has(`${known}/${token}`) && !((_kinds_get = kinds.get(known)) == null ? void 0 : _kinds_get.wordIds)) add(known, token);
554
+ }
555
+ }
556
+ });
557
+ return [
558
+ ...found.values()
559
+ ];
560
+ }
561
+ function remapString(text, ids) {
562
+ if (ids.has(text)) return ids.get(text);
563
+ let dropped = false;
564
+ const withoutTokens = text.replace(VAR_TOKEN, (whole, id)=>ids.has(id) ? ids.get(id) === null ? '' : whole.replace(id, ids.get(id)) : whole).replace(FN_TOKEN, (whole, id)=>ids.has(id) ? ids.get(id) === null ? '' : whole.replace(id, ids.get(id)) : whole);
565
+ const next = withoutTokens.replace(ID_TOKEN, (token)=>{
566
+ // Inside text only an id long enough never to be a word is moved; an
567
+ // exact value or a map key is moved whatever its length.
568
+ if (token.length < SITE_REFERENCE_MIN_ID_LENGTH || !ids.has(token)) return token;
569
+ const moved = ids.get(token);
570
+ if (moved === null) dropped = true;
571
+ return moved != null ? moved : token;
572
+ });
573
+ return dropped ? '' : next;
574
+ }
575
+ /**
576
+ * The value with every reference in `ids` moved: an exact id, a whole
577
+ * token inside a string, a map key. A dropped reference is `null` in a
578
+ * field, gone from a list or a map, gone as a binding token, and empties
579
+ * any other string it sat in. Unchanged parts keep their identity.
580
+ */ export function remapSiteReferences(value, ids) {
581
+ if (!ids.size) return value;
582
+ const walk = (current)=>{
583
+ if (typeof current === 'string') return remapString(current, ids);
584
+ if (Array.isArray(current)) {
585
+ let changed = false;
586
+ const next = [];
587
+ for (const entry of current){
588
+ const moved = walk(entry);
589
+ if (moved !== entry) changed = true;
590
+ if (moved === null && typeof entry === 'string') continue;
591
+ next.push(moved);
592
+ }
593
+ return changed ? next : current;
594
+ }
595
+ if (isPlainSiteObject(current)) {
596
+ let changed = false;
597
+ const next = {};
598
+ for (const [key, entry] of Object.entries(current)){
599
+ let target = key;
600
+ if (ids.has(key)) {
601
+ changed = true;
602
+ const moved = ids.get(key);
603
+ if (moved === null) continue;
604
+ target = moved;
605
+ }
606
+ const value = walk(entry);
607
+ if (value !== entry) changed = true;
608
+ next[target] = value;
609
+ }
610
+ return changed ? next : current;
611
+ }
612
+ return current;
613
+ };
614
+ return walk(value);
615
+ }
616
+ /** What an item is called on the import screen, and matched by. */ export function describeSiteItem(item, kinds = sitePackageKindMap()) {
617
+ var _ref, _ref1, _ref2, _ref3;
618
+ const kind = kinds.get(item.kind);
619
+ const text = (value)=>typeof value === 'string' && value.trim() ? value : undefined;
620
+ if (kind == null ? void 0 : kind.singletonId) return {
621
+ name: kind.label
622
+ };
623
+ const slug = (kind == null ? void 0 : kind.slugField) ? text(item.content[kind.slugField]) : undefined;
624
+ const name = (_ref = (_ref1 = (_ref2 = (_ref3 = (kind == null ? void 0 : kind.nameField) ? text(item.content[kind.nameField]) : undefined) != null ? _ref3 : text(item.content['displayName'])) != null ? _ref2 : text(item.content['name'])) != null ? _ref1 : text(item.content['title'])) != null ? _ref : text(item.content['fileName']);
625
+ return _extends({}, slug ? {
626
+ slug
627
+ } : {}, name ? {
628
+ name
629
+ } : {});
630
+ }
631
+ /**
632
+ * Builds a package from items: each hashed (by `hash`, or its content), named,
633
+ * and given its dependencies against `index` — the items themselves, and the
634
+ * site's own when an import is describing what it received.
635
+ */ export async function buildSitePackage(items, options = {}) {
636
+ var _options_kinds, _options_index, _options_hash;
637
+ const kinds = (_options_kinds = options.kinds) != null ? _options_kinds : sitePackageKindMap();
638
+ const index = (_options_index = options.index) != null ? _options_index : siteReferenceIndex(items, kinds);
639
+ const hash = (_options_hash = options.hash) != null ? _options_hash : (item)=>contentHash(item.content);
640
+ const manifestItems = [];
641
+ const contents = {};
642
+ for (const item of items){
643
+ const entry = _extends({
644
+ kind: item.kind,
645
+ $id: item.id
646
+ }, describeSiteItem(item, kinds), {
647
+ contentHash: await hash(item),
648
+ deps: siteItemDependencies(item, index, kinds, options.sections)
649
+ });
650
+ const key = packageItemKey(entry);
651
+ if (contents[key]) {
652
+ // Two documents under one id are one document on the site: the later
653
+ // one is what a v1 restore left standing, so it is what is kept.
654
+ const at = manifestItems.findIndex((one)=>packageItemKey(one) === key);
655
+ manifestItems.splice(at, 1);
656
+ }
657
+ manifestItems.push(entry);
658
+ contents[key] = item.content;
659
+ }
660
+ return {
661
+ manifest: _extends({
662
+ format: TRANSFER_PACKAGE_FORMAT,
663
+ version: TRANSFER_PACKAGE_VERSION,
664
+ items: manifestItems
665
+ }, options.createdAt !== undefined ? {
666
+ createdAt: options.createdAt
667
+ } : {}, options.source ? {
668
+ source: options.source
669
+ } : {}),
670
+ items: contents
671
+ };
672
+ }
673
+ /** The package's items, back as items. */ export function sitePackageItems(pkg) {
674
+ return pkg.manifest.items.map((entry)=>({
675
+ kind: entry.kind,
676
+ id: entry.$id,
677
+ content: asDoc(pkg.items[packageItemKey(entry)])
678
+ }));
679
+ }
680
+ /**
681
+ * The chosen items, and — with `includeDependencies` — everything they need
682
+ * inside the package, transitively. Keys are `<kind>/<id>`; an unknown key
683
+ * is ignored. The manifest keeps every item's full dependency list, so an
684
+ * import can say which ones the file does not carry.
685
+ */ export function selectSitePackage(pkg, keys, includeDependencies) {
686
+ const wanted = new Set(includeDependencies ? packageDependencyClosure(pkg.manifest.items, keys) : [
687
+ ...keys
688
+ ]);
689
+ const items = pkg.manifest.items.filter((entry)=>wanted.has(packageItemKey(entry)));
690
+ return {
691
+ manifest: _extends({}, pkg.manifest, {
692
+ items
693
+ }),
694
+ items: Object.fromEntries(items.map((entry)=>[
695
+ packageItemKey(entry),
696
+ pkg.items[packageItemKey(entry)]
697
+ ]))
698
+ };
699
+ }
700
+ /** The manifest without the content: the export picker's catalog. */ export function sitePackageCatalog(pkg) {
701
+ return pkg.manifest;
702
+ }
703
+ /**
704
+ * A v2 package from untrusted JSON: the manifest checked by the core, every
705
+ * listed item's content present and an object, and items of kinds this
706
+ * site does not read set aside (named in `unknownKinds`) rather than
707
+ * refusing the file — a package from a site with a plugin this one lacks
708
+ * still imports the rest.
709
+ */ export function readSitePackage(raw, kinds = sitePackageKindMap()) {
710
+ const file = asDoc(raw);
711
+ const read = readPackageManifest(file['manifest']);
712
+ if (read.ok === false) return {
713
+ ok: false,
714
+ problems: read.problems
715
+ };
716
+ const contents = asDoc(file['items']);
717
+ const problems = [];
718
+ const items = [];
719
+ const unknown = new Set();
720
+ for (const entry of read.manifest.items){
721
+ const key = packageItemKey(entry);
722
+ const content = contents[key];
723
+ if (!content || typeof content !== 'object' || Array.isArray(content)) {
724
+ problems.push(`${key} is listed and its content is missing.`);
725
+ continue;
726
+ }
727
+ if (!kinds.has(entry.kind)) {
728
+ unknown.add(entry.kind);
729
+ continue;
730
+ }
731
+ const kind = kinds.get(entry.kind);
732
+ if (kind.singletonId && entry.$id !== kind.singletonId) {
733
+ problems.push(`${key} is a ${entry.kind} item filed under an id other than "${kind.singletonId}".`);
734
+ continue;
735
+ }
736
+ // The manifest names the item; an `$id` inside its content is not a second say.
737
+ const { $id: _ignored } = content, rest = _object_without_properties_loose(content, [
738
+ "$id"
739
+ ]);
740
+ items.push({
741
+ kind: entry.kind,
742
+ id: entry.$id,
743
+ content: rest
744
+ });
745
+ }
746
+ if (problems.length) return {
747
+ ok: false,
748
+ problems
749
+ };
750
+ return {
751
+ ok: true,
752
+ items,
753
+ manifest: read.manifest,
754
+ unknownKinds: [
755
+ ...unknown
756
+ ]
757
+ };
758
+ }
759
+ /**
760
+ * Every incoming item against the site: matched by id, then slug, then name
761
+ * within its kind; `identical` when the hashes agree; `missingDependency`
762
+ * when it names an item neither side holds. Proposes create for new items
763
+ * and skip for everything else — replacing is never assumed.
764
+ */ export function planSitePackageImport(incoming, existing, kinds = sitePackageKindMap()) {
765
+ const matches = matchPackageItems(incoming.manifest, existing);
766
+ const counts = {
767
+ new: 0,
768
+ identical: 0,
769
+ differs: 0,
770
+ missingDependency: 0
771
+ };
772
+ const perKind = new Map();
773
+ const items = matches.map((match)=>{
774
+ var _perKind_get;
775
+ const kind = kinds.get(match.item.kind);
776
+ const proposed = proposePackageDecision(match);
777
+ counts[match.status] += 1;
778
+ perKind.set(match.item.kind, ((_perKind_get = perKind.get(match.item.kind)) != null ? _perKind_get : 0) + 1);
779
+ return _extends({
780
+ key: packageItemKey(match.item),
781
+ kind: match.item.kind,
782
+ id: match.item.$id
783
+ }, match.item.name ? {
784
+ name: match.item.name
785
+ } : {}, match.item.slug ? {
786
+ slug: match.item.slug
787
+ } : {}, {
788
+ status: match.status,
789
+ comparison: match.comparison
790
+ }, match.existing ? {
791
+ existing: _extends({
792
+ id: match.existing.id
793
+ }, match.existing.name ? {
794
+ name: match.existing.name
795
+ } : {}, match.existing.slug ? {
796
+ slug: match.existing.slug
797
+ } : {}),
798
+ matchedBy: match.matchedBy
799
+ } : {}, {
800
+ deps: match.item.deps,
801
+ missing: match.missing,
802
+ proposed: proposed.decision,
803
+ needsChoice: proposed.needsChoice,
804
+ choices: packageDecisionsFor(match, Boolean(kind == null ? void 0 : kind.mergeable)).filter(// A singleton or a catalog key has one place to be: a second copy
805
+ // has nowhere to go.
806
+ (choice)=>!((kind == null ? void 0 : kind.noCopies) && choice === 'keepBoth'))
807
+ });
808
+ });
809
+ return {
810
+ items,
811
+ counts,
812
+ kinds: [
813
+ ...perKind.entries()
814
+ ].map(([kind, count])=>{
815
+ var _ref;
816
+ var _kinds_get;
817
+ return {
818
+ kind,
819
+ label: (_ref = (_kinds_get = kinds.get(kind)) == null ? void 0 : _kinds_get.label) != null ? _ref : kind,
820
+ count
821
+ };
822
+ })
823
+ };
824
+ }
825
+ /** Why the decisions cannot be applied. */ export class SitePackageDecisionError extends Error {
826
+ constructor(problems){
827
+ super(problems.join(' ')), this.problems = problems;
828
+ this.name = 'SitePackageDecisionError';
829
+ }
830
+ }
831
+ /**
832
+ * Site fields filled from the incoming item only where the site holds
833
+ * none, at every depth of a plain object: the site's own value wins
834
+ * wherever it has one.
835
+ */ export function mergeSiteFields(existing, incoming) {
836
+ if (existing === undefined || existing === null) return incoming;
837
+ if (!isPlainSiteObject(existing) || !isPlainSiteObject(incoming)) return existing;
838
+ const out = _extends({}, existing);
839
+ for (const [key, value] of Object.entries(incoming))out[key] = mergeSiteFields(out[key], value);
840
+ return out;
841
+ }
842
+ /**
843
+ * The writes an import makes: which items are written, under which ids,
844
+ * with every reference moved — to an item kept beside an existing one, to
845
+ * the site item an incoming one was matched to, to an item the person
846
+ * mapped a missing dependency onto — and the references dropped.
847
+ */ export function resolveSitePackageImport(input) {
848
+ var _input_kinds, _input_decisions, _input_mergeChoices, _input_dependencyChoices;
849
+ const kinds = (_input_kinds = input.kinds) != null ? _input_kinds : sitePackageKindMap();
850
+ const problems = [];
851
+ const planByKey = new Map(input.plan.items.map((item)=>[
852
+ item.key,
853
+ item
854
+ ]));
855
+ const existingByKey = new Map(input.existing.map((item)=>[
856
+ `${item.kind}/${item.id}`,
857
+ item
858
+ ]));
859
+ const decided = new Map();
860
+ for (const item of input.plan.items){
861
+ let decision;
862
+ if (input.mode === 'restore') {
863
+ decision = existingByKey.has(item.key) ? 'replace' : 'create';
864
+ } else {
865
+ var _ref;
866
+ var _input_decisions1;
867
+ decision = (_ref = (_input_decisions1 = input.decisions) == null ? void 0 : _input_decisions1[item.key]) != null ? _ref : item.proposed;
868
+ if (!item.choices.includes(decision)) {
869
+ problems.push(`${item.key} cannot be "${decision}"; it may be ${item.choices.join(', ')}.`);
870
+ }
871
+ }
872
+ decided.set(item.key, decision);
873
+ }
874
+ for (const key of Object.keys((_input_decisions = input.decisions) != null ? _input_decisions : {})){
875
+ if (!planByKey.has(key)) problems.push(`${key} is not in the package.`);
876
+ }
877
+ for (const [key, choices] of Object.entries((_input_mergeChoices = input.mergeChoices) != null ? _input_mergeChoices : {})){
878
+ if (decided.get(key) !== 'merge') {
879
+ problems.push(`${key} is not merged, so its keys cannot be chosen.`);
880
+ continue;
881
+ }
882
+ for (const [field, choice] of Object.entries(choices != null ? choices : {})){
883
+ if (choice !== 'site' && choice !== 'package') {
884
+ problems.push(`${key} key "${field}" cannot take "${String(choice)}"; it may take site or package.`);
885
+ }
886
+ }
887
+ }
888
+ // A dependency the person asked to import from the package is created
889
+ // when it was new and set aside.
890
+ for (const [depKey, choice] of Object.entries((_input_dependencyChoices = input.dependencyChoices) != null ? _input_dependencyChoices : {})){
891
+ if (choice !== 'import') continue;
892
+ const dep = planByKey.get(depKey);
893
+ if (!dep) {
894
+ problems.push(`${depKey} is not in the package, so it cannot be imported from it.`);
895
+ continue;
896
+ }
897
+ if (decided.get(depKey) === 'skip') decided.set(depKey, dep.comparison === 'new' ? 'create' : 'replace');
898
+ }
899
+ if (problems.length) throw new SitePackageDecisionError(problems);
900
+ const takenSlugs = new Map();
901
+ const slugsOf = (kind)=>{
902
+ if (!takenSlugs.has(kind)) {
903
+ takenSlugs.set(kind, new Set([
904
+ ...input.existing.filter((one)=>one.kind === kind).map((one)=>one.slug),
905
+ ...input.plan.items.filter((one)=>one.kind === kind).map((one)=>one.slug)
906
+ ].filter((slug)=>Boolean(slug))));
907
+ }
908
+ return takenSlugs.get(kind);
909
+ };
910
+ // Where each incoming item lands, and so where references to it go.
911
+ const target = new Map();
912
+ const moved = {};
913
+ for (const item of input.plan.items){
914
+ const decision = decided.get(item.key);
915
+ let id = item.id;
916
+ if (decision === 'keepBoth') id = input.newId();
917
+ else if (item.existing && input.mode === 'decide') id = item.existing.id;
918
+ target.set(item.key, id);
919
+ if (id !== item.id) moved[item.key] = id;
920
+ }
921
+ // Every dependency that will exist nowhere after the import.
922
+ const written = new Set(input.plan.items.filter((item)=>decided.get(item.key) !== 'skip').map((item)=>item.key));
923
+ const onSite = new Set(existingByKey.keys());
924
+ const warnings = [];
925
+ // Moves by item key; the raw id map below is what content walks use.
926
+ const keyed = new Map();
927
+ for (const [key, id] of target){
928
+ const item = planByKey.get(key);
929
+ // A skipped item that matched nothing on the site leaves its references
930
+ // to the dependency step below.
931
+ if (decided.get(key) === 'skip' && !item.existing) continue;
932
+ if (id !== item.id) keyed.set(key, id);
933
+ }
934
+ for (const item of input.plan.items){
935
+ if (!written.has(item.key)) continue;
936
+ for (const dep of item.deps){
937
+ var _ref1;
938
+ var _planByKey_get, _input_dependencyChoices1;
939
+ const depKey = `${dep.kind}/${dep.id}`;
940
+ if (written.has(depKey) || onSite.has(depKey)) continue;
941
+ if ((_planByKey_get = planByKey.get(depKey)) == null ? void 0 : _planByKey_get.existing) continue;
942
+ const choice = (_ref1 = (_input_dependencyChoices1 = input.dependencyChoices) == null ? void 0 : _input_dependencyChoices1[depKey]) != null ? _ref1 : 'keep';
943
+ if (typeof choice === 'object') {
944
+ keyed.set(depKey, choice.mapTo);
945
+ warnings.push({
946
+ code: 'mappedReference',
947
+ item: item.key,
948
+ dependency: depKey,
949
+ message: `${item.key} pointed at ${depKey}, which this site does not hold; it now points at ${dep.kind}/${choice.mapTo}.`
950
+ });
951
+ } else if (choice === 'drop') {
952
+ keyed.set(depKey, null);
953
+ warnings.push({
954
+ code: 'droppedReference',
955
+ item: item.key,
956
+ dependency: depKey,
957
+ message: `${item.key} pointed at ${depKey}, which this site does not hold; the reference was removed.`
958
+ });
959
+ } else {
960
+ warnings.push({
961
+ code: 'danglingReference',
962
+ item: item.key,
963
+ dependency: depKey,
964
+ message: `${item.key} points at ${depKey}, which this site does not hold, and will until it does.`
965
+ });
966
+ }
967
+ }
968
+ }
969
+ // Ids that are words (a catalog key, `default`) are never moved through
970
+ // content: the word would be rewritten wherever it is written.
971
+ const idMap = new Map();
972
+ for (const [key, id] of keyed){
973
+ var _kinds_get;
974
+ const kindName = key.slice(0, key.indexOf('/'));
975
+ if ((_kinds_get = kinds.get(kindName)) == null ? void 0 : _kinds_get.wordIds) continue;
976
+ idMap.set(key.slice(key.indexOf('/') + 1), id);
977
+ }
978
+ const writes = [];
979
+ const skipped = [];
980
+ const contents = input.incoming.items;
981
+ for (const item of input.plan.items){
982
+ var _input_sections;
983
+ const decision = decided.get(item.key);
984
+ if (decision === 'skip') {
985
+ skipped.push(item.key);
986
+ continue;
987
+ }
988
+ const kind = kinds.get(item.kind);
989
+ const targetId = target.get(item.key);
990
+ let ids = idMap;
991
+ if ((kind == null ? void 0 : kind.keepsOwnId) && idMap.has(item.id)) {
992
+ ids = new Map(idMap);
993
+ ids.delete(item.id);
994
+ }
995
+ let content = remapSiteReferences(asDoc(contents[item.key]), ids);
996
+ const section = (_input_sections = input.sections) == null ? void 0 : _input_sections[item.kind];
997
+ if (section && keyed.size) {
998
+ const _section_remapIds = section.remapIds(_extends({
999
+ $id: item.id
1000
+ }, content), keyed), { $id: _id } = _section_remapIds, rest = _object_without_properties_loose(_section_remapIds, [
1001
+ "$id"
1002
+ ]);
1003
+ content = rest;
1004
+ }
1005
+ if (decision === 'keepBoth') {
1006
+ if ((kind == null ? void 0 : kind.slugField) && typeof content[kind.slugField] === 'string') {
1007
+ const slug = content[kind.slugField];
1008
+ const fresh = keepBothSlug(slug, slugsOf(item.kind));
1009
+ slugsOf(item.kind).add(fresh);
1010
+ content = _extends({}, content, {
1011
+ [kind.slugField]: fresh
1012
+ });
1013
+ if (typeof content['route'] === 'string') {
1014
+ content = _extends({}, content, {
1015
+ route: movedRoute(content['route'], slug, fresh)
1016
+ });
1017
+ if (content['route'] === null) delete content['route'];
1018
+ }
1019
+ } else if ((kind == null ? void 0 : kind.nameField) && typeof content[kind.nameField] === 'string') {
1020
+ content = _extends({}, content, {
1021
+ [kind.nameField]: `${content[kind.nameField]} (copy)`
1022
+ });
1023
+ }
1024
+ }
1025
+ let existingKey;
1026
+ if (decision === 'replace' || decision === 'merge') {
1027
+ existingKey = `${item.kind}/${targetId}`;
1028
+ }
1029
+ if (decision === 'merge') {
1030
+ var _ref2;
1031
+ var _existingByKey_get, _input_mergeChoices1;
1032
+ const current = asDoc((_existingByKey_get = existingByKey.get(existingKey)) == null ? void 0 : _existingByKey_get.content);
1033
+ const incomingContent = content;
1034
+ content = mergeSiteFields(current, incomingContent);
1035
+ for (const [field, choice] of Object.entries((_ref2 = (_input_mergeChoices1 = input.mergeChoices) == null ? void 0 : _input_mergeChoices1[item.key]) != null ? _ref2 : {})){
1036
+ const value = choice === 'package' ? incomingContent[field] : current[field];
1037
+ if (value === undefined) delete content[field];
1038
+ else content[field] = value;
1039
+ }
1040
+ }
1041
+ writes.push(_extends({
1042
+ key: item.key,
1043
+ kind: item.kind,
1044
+ sourceId: item.id,
1045
+ targetId,
1046
+ decision,
1047
+ content
1048
+ }, existingKey ? {
1049
+ existingKey
1050
+ } : {}));
1051
+ }
1052
+ return {
1053
+ writes,
1054
+ skipped,
1055
+ warnings,
1056
+ moved
1057
+ };
1058
+ }
1059
+ /**
1060
+ * A kept-both page's address: the original's with its last segment moved
1061
+ * to the copy's slug, or `null` — no address — when the original's address
1062
+ * does not end in its slug and so says nothing about where a copy goes.
1063
+ */ function movedRoute(route, slug, fresh) {
1064
+ const trim = (value)=>value.replace(/^\/+|\/+$/g, '');
1065
+ const from = trim(slug);
1066
+ const to = trim(fresh);
1067
+ const segments = route.split('/');
1068
+ if (!from || segments[segments.length - 1] !== from) return null;
1069
+ segments[segments.length - 1] = to;
1070
+ return segments.join('/');
1071
+ }
1072
+ /** Whether a package carries the format and version this module writes. */ export function isSitePackageFile(raw) {
1073
+ const manifest = asDoc(asDoc(raw)['manifest']);
1074
+ return manifest['format'] === TRANSFER_PACKAGE_FORMAT && manifest['version'] === TRANSFER_PACKAGE_VERSION;
1075
+ }
1076
+
1077
+ //# sourceMappingURL=site-package.js.map