@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,70 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { type DeriveOptions, type FieldDerivation, type FieldProblem } from './derive';
18
+ import { type MatchKeySpec, type RowMatchOutcome } from './match';
19
+ import type { PlannedTransferRow, TransferPlanRow } from './plan';
20
+ import { type TransferPolicy, type TransferValuesComparator } from './policy';
21
+ import { type TransferField } from './resource';
22
+ import { type TransferAmbiguity, type TransferConflict, type TransferDateOrder, type TransferDerivationSummary, type TransferMatchReview } from './transfer-api';
23
+ /** The per-field derive options a person's date-order choices make. */
24
+ export declare function transferDateOrderOptions(dateOrders: Readonly<Record<string, TransferDateOrder>> | undefined): Record<string, DeriveOptions>;
25
+ /** One row as read: the raw cells by field, and what reading them did. */
26
+ export interface TransferReviewRow {
27
+ index: number;
28
+ /** Field id → the raw cell, from `mapTransferRow`. */
29
+ cells: Readonly<Record<string, unknown>>;
30
+ derivations?: readonly FieldDerivation[];
31
+ problems?: readonly FieldProblem[];
32
+ }
33
+ /**
34
+ * What reading each of `fields` did over every row: cells filled, read as
35
+ * they were, each derivation and problem counted with a few examples, and
36
+ * the dates that read either way round.
37
+ */
38
+ export declare function summarizeTransferDerivations(fields: readonly TransferField[], rows: readonly TransferReviewRow[], samples?: number): TransferDerivationSummary[];
39
+ /** A name for a row or a record: its first non-blank text value. */
40
+ export declare function transferRowLabel(values: Readonly<Record<string, unknown>> | null | undefined): string | undefined;
41
+ /** Every record id an outcome names. */
42
+ export declare function transferMatchedRecordIds(outcomes: readonly RowMatchOutcome[]): string[];
43
+ /**
44
+ * The rows against existing records: every outcome counted, and at most
45
+ * `perKind` rows of each outcome listed, each named from its own values.
46
+ */
47
+ export declare function transferMatchReview(keys: readonly MatchKeySpec[], outcomes: readonly RowMatchOutcome[], values: ReadonlyArray<Readonly<Record<string, unknown>>>, perKind?: number): TransferMatchReview;
48
+ export interface TransferConflictsInput {
49
+ fields: ReadonlyMap<string, TransferField>;
50
+ rows: readonly TransferPlanRow[];
51
+ matches: readonly RowMatchOutcome[];
52
+ /** Record id → what the record holds now. */
53
+ existing: ReadonlyMap<string, Readonly<Record<string, unknown>>>;
54
+ policy: TransferPolicy;
55
+ /** The resource's comparator, so the review and the dry run agree on what differs. */
56
+ valuesEqual?: TransferValuesComparator;
57
+ }
58
+ /**
59
+ * The matched rows whose non-blank file values differ from non-blank
60
+ * values the record holds, field by field, with what the policy makes of
61
+ * each now. A row the person pointed at a record (`policy.rows`) is
62
+ * compared with that record. `matches` are the outcomes the dry run plans
63
+ * with — the resource's own, when it matches rows itself — and `valuesEqual`
64
+ * the resource's comparator, so a value the resource folds is no conflict.
65
+ */
66
+ export declare function transferPlanConflicts(input: TransferConflictsInput): TransferConflict[];
67
+ /** The rows more than one record matched. */
68
+ export declare function transferAmbiguities(outcomes: readonly RowMatchOutcome[]): TransferAmbiguity[];
69
+ /** At most `perVerdict` planned rows of each verdict, in row order. */
70
+ export declare function transferPlanSample(rows: readonly PlannedTransferRow[], perVerdict?: number): PlannedTransferRow[];
@@ -0,0 +1,233 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ /*==========================================
18
+ * THE REVIEW — what the wizard shows the person about a whole file.
19
+ *
20
+ * The derivations counted per field, the rows against existing records, the
21
+ * conflicts a policy decides and the rows more than one record matched. The
22
+ * job engine computes them over the stored file and the kit's in-memory
23
+ * client over its own records, from these same functions, so a step reads
24
+ * the same in a spec as it does against the server.
25
+ *=========================================*/ import { deriveDate } from "./derive.js";
26
+ import { summarizeMatches } from "./match.js";
27
+ import { applyFieldPolicy, compareTransferValues, isBlankTransferValue, resolveFieldPolicy } from "./policy.js";
28
+ import { isTransferFieldWritable } from "./resource.js";
29
+ import { TRANSFER_MATCH_ROWS_PER_KIND, TRANSFER_PLAN_SAMPLE_PER_VERDICT, TRANSFER_REVIEW_SAMPLES } from "./transfer-api.js";
30
+ /** The per-field derive options a person's date-order choices make. */ export function transferDateOrderOptions(dateOrders) {
31
+ const options = {};
32
+ for (const [fieldId, order] of Object.entries(dateOrders != null ? dateOrders : {})){
33
+ if (order === 'mdy' || order === 'dmy') options[fieldId] = {
34
+ date: {
35
+ order
36
+ },
37
+ dateTime: {
38
+ order
39
+ }
40
+ };
41
+ }
42
+ return options;
43
+ }
44
+ /**
45
+ * What reading each of `fields` did over every row: cells filled, read as
46
+ * they were, each derivation and problem counted with a few examples, and
47
+ * the dates that read either way round.
48
+ */ export function summarizeTransferDerivations(fields, rows, samples = TRANSFER_REVIEW_SAMPLES) {
49
+ return fields.map((field)=>{
50
+ const summary = {
51
+ fieldId: field.id,
52
+ filled: 0,
53
+ unchanged: 0,
54
+ derivations: [],
55
+ problems: [],
56
+ ambiguousDates: 0
57
+ };
58
+ for (const row of rows){
59
+ var _row_derivations, _row_problems;
60
+ const raw = row.cells[field.id];
61
+ if (isBlankTransferValue(raw)) continue;
62
+ summary.filled += 1;
63
+ const own = ((_row_derivations = row.derivations) != null ? _row_derivations : []).filter((entry)=>entry.fieldId === field.id);
64
+ const problems = ((_row_problems = row.problems) != null ? _row_problems : []).filter((entry)=>entry.fieldId === field.id);
65
+ if (!own.length && !problems.length) summary.unchanged += 1;
66
+ for (const entry of own){
67
+ const tally = summary.derivations.find((count)=>count.kind === entry.kind);
68
+ if (tally) {
69
+ var _tally;
70
+ tally.count += 1;
71
+ (_tally = tally).flagged || (_tally.flagged = entry.flagged);
72
+ if (tally.samples.length < samples) tally.samples.push({
73
+ row: row.index,
74
+ from: entry.from,
75
+ to: entry.to
76
+ });
77
+ } else {
78
+ summary.derivations.push({
79
+ kind: entry.kind,
80
+ note: entry.note,
81
+ count: 1,
82
+ flagged: entry.flagged,
83
+ samples: [
84
+ {
85
+ row: row.index,
86
+ from: entry.from,
87
+ to: entry.to
88
+ }
89
+ ]
90
+ });
91
+ }
92
+ }
93
+ for (const entry of problems){
94
+ const tally = summary.problems.find((count)=>count.code === entry.code);
95
+ if (tally) {
96
+ tally.count += 1;
97
+ if (tally.samples.length < samples) tally.samples.push({
98
+ row: row.index,
99
+ raw: entry.raw
100
+ });
101
+ } else {
102
+ summary.problems.push({
103
+ code: entry.code,
104
+ message: entry.message,
105
+ count: 1,
106
+ samples: [
107
+ {
108
+ row: row.index,
109
+ raw: entry.raw
110
+ }
111
+ ]
112
+ });
113
+ }
114
+ }
115
+ // Ambiguity is a property of the cell, whatever order the person chose.
116
+ if ((field.type === 'date' || field.type === 'datetime') && deriveDate(raw).derivations.some((entry)=>entry.kind === 'ambiguousDate')) {
117
+ summary.ambiguousDates += 1;
118
+ }
119
+ }
120
+ return summary;
121
+ });
122
+ }
123
+ /** A name for a row or a record: its first non-blank text value. */ export function transferRowLabel(values) {
124
+ if (!values) return undefined;
125
+ const text = Object.values(values).find((value)=>typeof value === 'string' && value.trim());
126
+ return typeof text === 'string' ? text : undefined;
127
+ }
128
+ /** Every record id an outcome names. */ export function transferMatchedRecordIds(outcomes) {
129
+ const ids = new Set();
130
+ for (const outcome of outcomes){
131
+ if (outcome.kind === 'matched') ids.add(outcome.recordId);
132
+ if (outcome.kind === 'ambiguous') for (const id of outcome.recordIds)ids.add(id);
133
+ }
134
+ return [
135
+ ...ids
136
+ ];
137
+ }
138
+ /**
139
+ * The rows against existing records: every outcome counted, and at most
140
+ * `perKind` rows of each outcome listed, each named from its own values.
141
+ */ export function transferMatchReview(keys, outcomes, values, perKind = TRANSFER_MATCH_ROWS_PER_KIND) {
142
+ const listed = {
143
+ new: 0,
144
+ matched: 0,
145
+ ambiguous: 0,
146
+ duplicateInFile: 0
147
+ };
148
+ const rows = [];
149
+ outcomes.forEach((outcome, row)=>{
150
+ if (listed[outcome.kind] >= perKind) return;
151
+ listed[outcome.kind] += 1;
152
+ const label = transferRowLabel(values[row]);
153
+ rows.push(_extends({
154
+ row,
155
+ outcome
156
+ }, label ? {
157
+ label
158
+ } : {}));
159
+ });
160
+ return {
161
+ keys: [
162
+ ...keys
163
+ ],
164
+ summary: summarizeMatches(outcomes),
165
+ rows
166
+ };
167
+ }
168
+ /**
169
+ * The matched rows whose non-blank file values differ from non-blank
170
+ * values the record holds, field by field, with what the policy makes of
171
+ * each now. A row the person pointed at a record (`policy.rows`) is
172
+ * compared with that record. `matches` are the outcomes the dry run plans
173
+ * with — the resource's own, when it matches rows itself — and `valuesEqual`
174
+ * the resource's comparator, so a value the resource folds is no conflict.
175
+ */ export function transferPlanConflicts(input) {
176
+ const conflicts = [];
177
+ input.rows.forEach((row)=>{
178
+ var _input_policy_rows_row_index;
179
+ const outcome = input.matches[row.index];
180
+ const chosen = (_input_policy_rows_row_index = input.policy.rows[row.index]) == null ? void 0 : _input_policy_rows_row_index.recordId;
181
+ const recordId = chosen != null ? chosen : (outcome == null ? void 0 : outcome.kind) === 'matched' ? outcome.recordId : null;
182
+ if (!recordId) return;
183
+ const record = input.existing.get(recordId);
184
+ if (!record) return;
185
+ const fields = Object.entries(row.values).flatMap(([fieldId, incoming])=>{
186
+ const field = input.fields.get(fieldId);
187
+ if (!field || !isTransferFieldWritable(field)) return [];
188
+ const before = record[fieldId];
189
+ const equal = (a, b)=>compareTransferValues(field, a, b, input.valuesEqual);
190
+ if (isBlankTransferValue(incoming) || isBlankTransferValue(before) || equal(before, incoming)) return [];
191
+ const resolved = resolveFieldPolicy(input.policy, row.index, field);
192
+ return [
193
+ {
194
+ fieldId,
195
+ before,
196
+ incoming,
197
+ after: applyFieldPolicy(resolved, before, incoming, equal).after,
198
+ mode: resolved.mode,
199
+ source: resolved.source
200
+ }
201
+ ];
202
+ });
203
+ if (fields.length) conflicts.push({
204
+ row: row.index,
205
+ recordId,
206
+ fields
207
+ });
208
+ });
209
+ return conflicts;
210
+ }
211
+ /** The rows more than one record matched. */ export function transferAmbiguities(outcomes) {
212
+ return outcomes.flatMap((outcome, row)=>outcome.kind === 'ambiguous' ? [
213
+ {
214
+ row,
215
+ via: outcome.via,
216
+ recordIds: [
217
+ ...outcome.recordIds
218
+ ]
219
+ }
220
+ ] : []);
221
+ }
222
+ /** At most `perVerdict` planned rows of each verdict, in row order. */ export function transferPlanSample(rows, perVerdict = TRANSFER_PLAN_SAMPLE_PER_VERDICT) {
223
+ const taken = {};
224
+ return rows.filter((row)=>{
225
+ var _taken_row_verdict;
226
+ const count = (_taken_row_verdict = taken[row.verdict]) != null ? _taken_row_verdict : 0;
227
+ if (count >= perVerdict) return false;
228
+ taken[row.verdict] = count + 1;
229
+ return true;
230
+ });
231
+ }
232
+
233
+ //# sourceMappingURL=review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/data-transfer/review.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * THE REVIEW — what the wizard shows the person about a whole file.\n *\n * The derivations counted per field, the rows against existing records, the\n * conflicts a policy decides and the rows more than one record matched. The\n * job engine computes them over the stored file and the kit's in-memory\n * client over its own records, from these same functions, so a step reads\n * the same in a spec as it does against the server.\n *=========================================*/\n\nimport { deriveDate, type DeriveOptions, type FieldDerivation, type FieldProblem } from './derive'\nimport { summarizeMatches, type MatchKeySpec, type RowMatchOutcome } from './match'\nimport type { PlannedTransferRow, TransferPlanRow, TransferRowVerdict } from './plan'\nimport {\n applyFieldPolicy,\n compareTransferValues,\n isBlankTransferValue,\n resolveFieldPolicy,\n type TransferPolicy,\n type TransferValuesComparator,\n} from './policy'\nimport { isTransferFieldWritable, type TransferField } from './resource'\nimport {\n TRANSFER_MATCH_ROWS_PER_KIND,\n TRANSFER_PLAN_SAMPLE_PER_VERDICT,\n TRANSFER_REVIEW_SAMPLES,\n type TransferAmbiguity,\n type TransferConflict,\n type TransferDateOrder,\n type TransferDerivationSummary,\n type TransferMatchReview,\n} from './transfer-api'\n\n/** The per-field derive options a person's date-order choices make. */\nexport function transferDateOrderOptions(\n dateOrders: Readonly<Record<string, TransferDateOrder>> | undefined,\n): Record<string, DeriveOptions> {\n const options: Record<string, DeriveOptions> = {}\n for (const [fieldId, order] of Object.entries(dateOrders ?? {})) {\n if (order === 'mdy' || order === 'dmy') options[fieldId] = { date: { order }, dateTime: { order } }\n }\n return options\n}\n\n/** One row as read: the raw cells by field, and what reading them did. */\nexport interface TransferReviewRow {\n index: number\n /** Field id → the raw cell, from `mapTransferRow`. */\n cells: Readonly<Record<string, unknown>>\n derivations?: readonly FieldDerivation[]\n problems?: readonly FieldProblem[]\n}\n\n/**\n * What reading each of `fields` did over every row: cells filled, read as\n * they were, each derivation and problem counted with a few examples, and\n * the dates that read either way round.\n */\nexport function summarizeTransferDerivations(\n fields: readonly TransferField[],\n rows: readonly TransferReviewRow[],\n samples = TRANSFER_REVIEW_SAMPLES,\n): TransferDerivationSummary[] {\n return fields.map((field) => {\n const summary: TransferDerivationSummary = {\n fieldId: field.id,\n filled: 0,\n unchanged: 0,\n derivations: [],\n problems: [],\n ambiguousDates: 0,\n }\n for (const row of rows) {\n const raw = row.cells[field.id]\n if (isBlankTransferValue(raw)) continue\n summary.filled += 1\n const own = (row.derivations ?? []).filter((entry) => entry.fieldId === field.id)\n const problems = (row.problems ?? []).filter((entry) => entry.fieldId === field.id)\n if (!own.length && !problems.length) summary.unchanged += 1\n for (const entry of own) {\n const tally = summary.derivations.find((count) => count.kind === entry.kind)\n if (tally) {\n tally.count += 1\n tally.flagged ||= entry.flagged\n if (tally.samples.length < samples) tally.samples.push({ row: row.index, from: entry.from, to: entry.to })\n } else {\n summary.derivations.push({\n kind: entry.kind,\n note: entry.note,\n count: 1,\n flagged: entry.flagged,\n samples: [{ row: row.index, from: entry.from, to: entry.to }],\n })\n }\n }\n for (const entry of problems) {\n const tally = summary.problems.find((count) => count.code === entry.code)\n if (tally) {\n tally.count += 1\n if (tally.samples.length < samples) tally.samples.push({ row: row.index, raw: entry.raw })\n } else {\n summary.problems.push({\n code: entry.code,\n message: entry.message,\n count: 1,\n samples: [{ row: row.index, raw: entry.raw }],\n })\n }\n }\n // Ambiguity is a property of the cell, whatever order the person chose.\n if (\n (field.type === 'date' || field.type === 'datetime') &&\n deriveDate(raw).derivations.some((entry) => entry.kind === 'ambiguousDate')\n ) {\n summary.ambiguousDates += 1\n }\n }\n return summary\n })\n}\n\n/** A name for a row or a record: its first non-blank text value. */\nexport function transferRowLabel(values: Readonly<Record<string, unknown>> | null | undefined): string | undefined {\n if (!values) return undefined\n const text = Object.values(values).find((value) => typeof value === 'string' && value.trim())\n return typeof text === 'string' ? text : undefined\n}\n\n/** Every record id an outcome names. */\nexport function transferMatchedRecordIds(outcomes: readonly RowMatchOutcome[]): string[] {\n const ids = new Set<string>()\n for (const outcome of outcomes) {\n if (outcome.kind === 'matched') ids.add(outcome.recordId)\n if (outcome.kind === 'ambiguous') for (const id of outcome.recordIds) ids.add(id)\n }\n return [...ids]\n}\n\n/**\n * The rows against existing records: every outcome counted, and at most\n * `perKind` rows of each outcome listed, each named from its own values.\n */\nexport function transferMatchReview(\n keys: readonly MatchKeySpec[],\n outcomes: readonly RowMatchOutcome[],\n values: ReadonlyArray<Readonly<Record<string, unknown>>>,\n perKind = TRANSFER_MATCH_ROWS_PER_KIND,\n): TransferMatchReview {\n const listed: Record<RowMatchOutcome['kind'], number> = { new: 0, matched: 0, ambiguous: 0, duplicateInFile: 0 }\n const rows: TransferMatchReview['rows'] = []\n outcomes.forEach((outcome, row) => {\n if (listed[outcome.kind] >= perKind) return\n listed[outcome.kind] += 1\n const label = transferRowLabel(values[row])\n rows.push({ row, outcome, ...(label ? { label } : {}) })\n })\n return { keys: [...keys], summary: summarizeMatches(outcomes), rows }\n}\n\nexport interface TransferConflictsInput {\n fields: ReadonlyMap<string, TransferField>\n rows: readonly TransferPlanRow[]\n matches: readonly RowMatchOutcome[]\n /** Record id → what the record holds now. */\n existing: ReadonlyMap<string, Readonly<Record<string, unknown>>>\n policy: TransferPolicy\n /** The resource's comparator, so the review and the dry run agree on what differs. */\n valuesEqual?: TransferValuesComparator\n}\n\n/**\n * The matched rows whose non-blank file values differ from non-blank\n * values the record holds, field by field, with what the policy makes of\n * each now. A row the person pointed at a record (`policy.rows`) is\n * compared with that record. `matches` are the outcomes the dry run plans\n * with — the resource's own, when it matches rows itself — and `valuesEqual`\n * the resource's comparator, so a value the resource folds is no conflict.\n */\nexport function transferPlanConflicts(input: TransferConflictsInput): TransferConflict[] {\n const conflicts: TransferConflict[] = []\n input.rows.forEach((row) => {\n const outcome = input.matches[row.index]\n const chosen = input.policy.rows[row.index]?.recordId\n const recordId = chosen ?? (outcome?.kind === 'matched' ? outcome.recordId : null)\n if (!recordId) return\n const record = input.existing.get(recordId)\n if (!record) return\n const fields = Object.entries(row.values).flatMap(([fieldId, incoming]) => {\n const field = input.fields.get(fieldId)\n if (!field || !isTransferFieldWritable(field)) return []\n const before = record[fieldId]\n const equal = (a: unknown, b: unknown) => compareTransferValues(field, a, b, input.valuesEqual)\n if (isBlankTransferValue(incoming) || isBlankTransferValue(before) || equal(before, incoming)) return []\n const resolved = resolveFieldPolicy(input.policy, row.index, field)\n return [\n {\n fieldId,\n before,\n incoming,\n after: applyFieldPolicy(resolved, before, incoming, equal).after,\n mode: resolved.mode,\n source: resolved.source,\n },\n ]\n })\n if (fields.length) conflicts.push({ row: row.index, recordId, fields })\n })\n return conflicts\n}\n\n/** The rows more than one record matched. */\nexport function transferAmbiguities(outcomes: readonly RowMatchOutcome[]): TransferAmbiguity[] {\n return outcomes.flatMap((outcome, row) =>\n outcome.kind === 'ambiguous' ? [{ row, via: outcome.via, recordIds: [...outcome.recordIds] }] : [],\n )\n}\n\n/** At most `perVerdict` planned rows of each verdict, in row order. */\nexport function transferPlanSample(\n rows: readonly PlannedTransferRow[],\n perVerdict = TRANSFER_PLAN_SAMPLE_PER_VERDICT,\n): PlannedTransferRow[] {\n const taken: Partial<Record<TransferRowVerdict, number>> = {}\n return rows.filter((row) => {\n const count = taken[row.verdict] ?? 0\n if (count >= perVerdict) return false\n taken[row.verdict] = count + 1\n return true\n })\n}\n"],"names":["deriveDate","summarizeMatches","applyFieldPolicy","compareTransferValues","isBlankTransferValue","resolveFieldPolicy","isTransferFieldWritable","TRANSFER_MATCH_ROWS_PER_KIND","TRANSFER_PLAN_SAMPLE_PER_VERDICT","TRANSFER_REVIEW_SAMPLES","transferDateOrderOptions","dateOrders","options","fieldId","order","Object","entries","date","dateTime","summarizeTransferDerivations","fields","rows","samples","map","field","summary","id","filled","unchanged","derivations","problems","ambiguousDates","row","raw","cells","own","filter","entry","length","tally","find","count","kind","flagged","push","index","from","to","note","code","message","type","some","transferRowLabel","values","undefined","text","value","trim","transferMatchedRecordIds","outcomes","ids","Set","outcome","add","recordId","recordIds","transferMatchReview","keys","perKind","listed","new","matched","ambiguous","duplicateInFile","forEach","label","transferPlanConflicts","input","conflicts","matches","chosen","policy","record","existing","get","flatMap","incoming","before","equal","a","b","valuesEqual","resolved","after","mode","source","transferAmbiguities","via","transferPlanSample","perVerdict","taken","verdict"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;2CAQ2C,GAE3C,SAASA,UAAU,QAAqE,cAAU;AAClG,SAASC,gBAAgB,QAAiD,aAAS;AAEnF,SACEC,gBAAgB,EAChBC,qBAAqB,EACrBC,oBAAoB,EACpBC,kBAAkB,QAGb,cAAU;AACjB,SAASC,uBAAuB,QAA4B,gBAAY;AACxE,SACEC,4BAA4B,EAC5BC,gCAAgC,EAChCC,uBAAuB,QAMlB,oBAAgB;AAEvB,qEAAqE,GACrE,OAAO,SAASC,yBACdC,UAAmE;IAEnE,MAAMC,UAAyC,CAAC;IAChD,KAAK,MAAM,CAACC,SAASC,MAAM,IAAIC,OAAOC,OAAO,CAACL,qBAAAA,aAAc,CAAC,GAAI;QAC/D,IAAIG,UAAU,SAASA,UAAU,OAAOF,OAAO,CAACC,QAAQ,GAAG;YAAEI,MAAM;gBAAEH;YAAM;YAAGI,UAAU;gBAAEJ;YAAM;QAAE;IACpG;IACA,OAAOF;AACT;AAWA;;;;CAIC,GACD,OAAO,SAASO,6BACdC,MAAgC,EAChCC,IAAkC,EAClCC,UAAUb,uBAAuB;IAEjC,OAAOW,OAAOG,GAAG,CAAC,CAACC;QACjB,MAAMC,UAAqC;YACzCZ,SAASW,MAAME,EAAE;YACjBC,QAAQ;YACRC,WAAW;YACXC,aAAa,EAAE;YACfC,UAAU,EAAE;YACZC,gBAAgB;QAClB;QACA,KAAK,MAAMC,OAAOX,KAAM;gBAITW,kBACKA;YAJlB,MAAMC,MAAMD,IAAIE,KAAK,CAACV,MAAME,EAAE,CAAC;YAC/B,IAAItB,qBAAqB6B,MAAM;YAC/BR,QAAQE,MAAM,IAAI;YAClB,MAAM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Y,OAAO;QAChCC,KAAK,CAACrE,IAAIsE,OAAO,CAAC,GAAG7D,QAAQ;QAC7B,OAAO;IACT;AACF"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /** Letters without their accents, lowercased: `Café` and `cafe` fold together. */
18
+ export declare function foldText(value: unknown): string;
19
+ /**
20
+ * The Damerau–Levenshtein distance (optimal string alignment): the fewest
21
+ * insertions, deletions, substitutions and swaps of two neighbors that turn
22
+ * `a` into `b`. A swap counts once, so `emial` is one edit from `email`.
23
+ */
24
+ export declare function damerauLevenshtein(a: string, b: string): number;
25
+ /** 1 for identical strings, 0 for nothing in common, by edit distance over the longer length. */
26
+ export declare function editSimilarity(a: string, b: string): number;
27
+ /** The words of a string, folded: letters and digits only. */
28
+ export declare function similarityTokens(value: unknown): string[];
29
+ /**
30
+ * How much two strings share as sets of words, 0 to 1 (Dice coefficient).
31
+ * Two words count as the same when they are at most one edit apart and at
32
+ * least four letters long, so a typo inside a longer header still counts.
33
+ */
34
+ export declare function tokenSetSimilarity(a: unknown, b: unknown): number;
35
+ /**
36
+ * The one score the matchers rank by: the better of the token-set score and
37
+ * the edit score over the strings with their separators removed, so both a
38
+ * reordering and a typo can carry a match.
39
+ */
40
+ export declare function textSimilarity(a: unknown, b: unknown): number;
@@ -0,0 +1,106 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /*==========================================
17
+ * TEXT SIMILARITY — how alike two short strings are, from 0 to 1.
18
+ *
19
+ * Used to guess which field a header means and which picklist value an
20
+ * unknown cell was meant to be. Two measures, because they fail
21
+ * differently: an edit distance catches typos (`Emial`), a token set
22
+ * catches reordering and extra words (`Phone (mobile)` vs `Mobile phone`).
23
+ *=========================================*/ /** Letters without their accents, lowercased: `Café` and `cafe` fold together. */ export function foldText(value) {
24
+ return String(value != null ? value : '').normalize('NFKD').replace(/[\u0300-\u036f]/g, '').toLowerCase();
25
+ }
26
+ /**
27
+ * The Damerau–Levenshtein distance (optimal string alignment): the fewest
28
+ * insertions, deletions, substitutions and swaps of two neighbors that turn
29
+ * `a` into `b`. A swap counts once, so `emial` is one edit from `email`.
30
+ */ export function damerauLevenshtein(a, b) {
31
+ if (a === b) return 0;
32
+ if (!a.length) return b.length;
33
+ if (!b.length) return a.length;
34
+ const rows = a.length + 1;
35
+ const cols = b.length + 1;
36
+ const d = Array.from({
37
+ length: rows
38
+ }, ()=>new Array(cols).fill(0));
39
+ const at = (i, j)=>{
40
+ var _ref;
41
+ var _d_i;
42
+ return (_ref = (_d_i = d[i]) == null ? void 0 : _d_i[j]) != null ? _ref : 0;
43
+ };
44
+ for(let i = 0; i < rows; i += 1)d[i][0] = i;
45
+ for(let j = 0; j < cols; j += 1)d[0][j] = j;
46
+ for(let i = 1; i < rows; i += 1){
47
+ for(let j = 1; j < cols; j += 1){
48
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
49
+ let best = Math.min(at(i - 1, j) + 1, at(i, j - 1) + 1, at(i - 1, j - 1) + cost);
50
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
51
+ best = Math.min(best, at(i - 2, j - 2) + 1);
52
+ }
53
+ ;
54
+ d[i][j] = best;
55
+ }
56
+ }
57
+ return at(a.length, b.length);
58
+ }
59
+ /** 1 for identical strings, 0 for nothing in common, by edit distance over the longer length. */ export function editSimilarity(a, b) {
60
+ const longest = Math.max(a.length, b.length);
61
+ if (!longest) return 1;
62
+ return 1 - damerauLevenshtein(a, b) / longest;
63
+ }
64
+ /** The words of a string, folded: letters and digits only. */ export function similarityTokens(value) {
65
+ return foldText(value).split(/[^a-z0-9]+/).filter(Boolean);
66
+ }
67
+ /**
68
+ * How much two strings share as sets of words, 0 to 1 (Dice coefficient).
69
+ * Two words count as the same when they are at most one edit apart and at
70
+ * least four letters long, so a typo inside a longer header still counts.
71
+ */ export function tokenSetSimilarity(a, b) {
72
+ const left = [
73
+ ...new Set(similarityTokens(a))
74
+ ];
75
+ const right = [
76
+ ...new Set(similarityTokens(b))
77
+ ];
78
+ if (!left.length && !right.length) return 1;
79
+ if (!left.length || !right.length) return 0;
80
+ const unused = [
81
+ ...right
82
+ ];
83
+ let shared = 0;
84
+ for (const token of left){
85
+ let found = unused.indexOf(token);
86
+ if (found < 0 && token.length >= 4) {
87
+ found = unused.findIndex((other)=>other.length >= 4 && damerauLevenshtein(token, other) <= 1);
88
+ }
89
+ if (found >= 0) {
90
+ shared += 1;
91
+ unused.splice(found, 1);
92
+ }
93
+ }
94
+ return 2 * shared / (left.length + right.length);
95
+ }
96
+ /**
97
+ * The one score the matchers rank by: the better of the token-set score and
98
+ * the edit score over the strings with their separators removed, so both a
99
+ * reordering and a typo can carry a match.
100
+ */ export function textSimilarity(a, b) {
101
+ const compactA = similarityTokens(a).join('');
102
+ const compactB = similarityTokens(b).join('');
103
+ return Math.max(tokenSetSimilarity(a, b), editSimilarity(compactA, compactB));
104
+ }
105
+
106
+ //# sourceMappingURL=similarity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/data-transfer/similarity.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * TEXT SIMILARITY — how alike two short strings are, from 0 to 1.\n *\n * Used to guess which field a header means and which picklist value an\n * unknown cell was meant to be. Two measures, because they fail\n * differently: an edit distance catches typos (`Emial`), a token set\n * catches reordering and extra words (`Phone (mobile)` vs `Mobile phone`).\n *=========================================*/\n\n/** Letters without their accents, lowercased: `Café` and `cafe` fold together. */\nexport function foldText(value: unknown): string {\n return String(value ?? '')\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase()\n}\n\n/**\n * The Damerau–Levenshtein distance (optimal string alignment): the fewest\n * insertions, deletions, substitutions and swaps of two neighbors that turn\n * `a` into `b`. A swap counts once, so `emial` is one edit from `email`.\n */\nexport function damerauLevenshtein(a: string, b: string): number {\n if (a === b) return 0\n if (!a.length) return b.length\n if (!b.length) return a.length\n const rows = a.length + 1\n const cols = b.length + 1\n const d: number[][] = Array.from({ length: rows }, () => new Array<number>(cols).fill(0))\n const at = (i: number, j: number): number => d[i]?.[j] ?? 0\n for (let i = 0; i < rows; i += 1) (d[i] as number[])[0] = i\n for (let j = 0; j < cols; j += 1) (d[0] as number[])[j] = j\n for (let i = 1; i < rows; i += 1) {\n for (let j = 1; j < cols; j += 1) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1\n let best = Math.min(at(i - 1, j) + 1, at(i, j - 1) + 1, at(i - 1, j - 1) + cost)\n if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {\n best = Math.min(best, at(i - 2, j - 2) + 1)\n }\n ;(d[i] as number[])[j] = best\n }\n }\n return at(a.length, b.length)\n}\n\n/** 1 for identical strings, 0 for nothing in common, by edit distance over the longer length. */\nexport function editSimilarity(a: string, b: string): number {\n const longest = Math.max(a.length, b.length)\n if (!longest) return 1\n return 1 - damerauLevenshtein(a, b) / longest\n}\n\n/** The words of a string, folded: letters and digits only. */\nexport function similarityTokens(value: unknown): string[] {\n return foldText(value)\n .split(/[^a-z0-9]+/)\n .filter(Boolean)\n}\n\n/**\n * How much two strings share as sets of words, 0 to 1 (Dice coefficient).\n * Two words count as the same when they are at most one edit apart and at\n * least four letters long, so a typo inside a longer header still counts.\n */\nexport function tokenSetSimilarity(a: unknown, b: unknown): number {\n const left = [...new Set(similarityTokens(a))]\n const right = [...new Set(similarityTokens(b))]\n if (!left.length && !right.length) return 1\n if (!left.length || !right.length) return 0\n const unused = [...right]\n let shared = 0\n for (const token of left) {\n let found = unused.indexOf(token)\n if (found < 0 && token.length >= 4) {\n found = unused.findIndex(\n (other) => other.length >= 4 && damerauLevenshtein(token, other) <= 1,\n )\n }\n if (found >= 0) {\n shared += 1\n unused.splice(found, 1)\n }\n }\n return (2 * shared) / (left.length + right.length)\n}\n\n/**\n * The one score the matchers rank by: the better of the token-set score and\n * the edit score over the strings with their separators removed, so both a\n * reordering and a typo can carry a match.\n */\nexport function textSimilarity(a: unknown, b: unknown): number {\n const compactA = similarityTokens(a).join('')\n const compactB = similarityTokens(b).join('')\n return Math.max(tokenSetSimilarity(a, b), editSimilarity(compactA, compactB))\n}\n"],"names":["foldText","value","String","normalize","replace","toLowerCase","damerauLevenshtein","a","b","length","rows","cols","d","Array","from","fill","at","i","j","cost","best","Math","min","editSimilarity","longest","max","similarityTokens","split","filter","Boolean","tokenSetSimilarity","left","Set","right","unused","shared","token","found","indexOf","findIndex","other","splice","textSimilarity","compactA","join","compact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