canopycms 0.0.67-int.90 → 0.0.67

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 (539) hide show
  1. package/README.md +30 -3
  2. package/dist/ai/generate.js +1 -27
  3. package/dist/ai/handler.d.ts +0 -4
  4. package/dist/ai/handler.js +0 -11
  5. package/dist/ai/index.d.ts +1 -8
  6. package/dist/ai/index.js +1 -8
  7. package/dist/ai/json-to-markdown.js +15 -58
  8. package/dist/ai/resolve-branch.d.ts +2 -7
  9. package/dist/ai/resolve-branch.js +2 -8
  10. package/dist/ai/strip-mdx.d.ts +5 -13
  11. package/dist/ai/strip-mdx.js +5 -17
  12. package/dist/ai/to-plain-text.d.ts +10 -28
  13. package/dist/ai/to-plain-text.js +10 -28
  14. package/dist/ai/transform-components.d.ts +2 -4
  15. package/dist/ai/transform-components.js +8 -19
  16. package/dist/ai/types.d.ts +5 -10
  17. package/dist/api/admin-branch-health.d.ts +4 -12
  18. package/dist/api/admin-branch-health.js +26 -66
  19. package/dist/api/admin.d.ts +4 -12
  20. package/dist/api/admin.js +10 -26
  21. package/dist/api/assets.d.ts +0 -25
  22. package/dist/api/assets.js +50 -91
  23. package/dist/api/branch-merge.d.ts +1 -1
  24. package/dist/api/branch-merge.js +0 -2
  25. package/dist/api/branch-review.d.ts +0 -8
  26. package/dist/api/branch-review.js +0 -13
  27. package/dist/api/branch-status.d.ts +0 -3
  28. package/dist/api/branch-status.js +8 -33
  29. package/dist/api/branch-withdraw.d.ts +0 -1
  30. package/dist/api/branch-withdraw.js +6 -9
  31. package/dist/api/branch.d.ts +7 -12
  32. package/dist/api/branch.js +7 -44
  33. package/dist/api/client.d.ts +71 -224
  34. package/dist/api/client.js +82 -233
  35. package/dist/api/comments.d.ts +2 -4
  36. package/dist/api/comments.js +0 -17
  37. package/dist/api/content.d.ts +0 -6
  38. package/dist/api/content.js +66 -142
  39. package/dist/api/entries-constants.d.ts +5 -9
  40. package/dist/api/entries-constants.js +5 -9
  41. package/dist/api/entries.d.ts +8 -13
  42. package/dist/api/entries.js +20 -51
  43. package/dist/api/github-sync.d.ts +2 -4
  44. package/dist/api/github-sync.js +4 -8
  45. package/dist/api/groups.d.ts +3 -0
  46. package/dist/api/groups.js +8 -21
  47. package/dist/api/guards.d.ts +4 -16
  48. package/dist/api/guards.js +3 -22
  49. package/dist/api/index.d.ts +4 -4
  50. package/dist/api/permissions.d.ts +2 -0
  51. package/dist/api/permissions.js +18 -40
  52. package/dist/api/reference-options.d.ts +0 -1
  53. package/dist/api/reference-options.js +3 -11
  54. package/dist/api/request-body-hash.d.ts +12 -23
  55. package/dist/api/request-body-hash.js +12 -23
  56. package/dist/api/resolve-references.d.ts +0 -1
  57. package/dist/api/resolve-references.js +13 -28
  58. package/dist/api/route-builder.d.ts +3 -7
  59. package/dist/api/route-builder.js +1 -1
  60. package/dist/api/routes.d.ts +12 -0
  61. package/dist/api/routes.js +47 -0
  62. package/dist/api/schema.d.ts +23 -33
  63. package/dist/api/schema.js +20 -74
  64. package/dist/api/settings-helpers.js +4 -5
  65. package/dist/api/types.d.ts +0 -5
  66. package/dist/api/user.js +0 -5
  67. package/dist/api/validators.d.ts +14 -52
  68. package/dist/api/validators.js +14 -52
  69. package/dist/assets/asset-prefixes.d.ts +4 -8
  70. package/dist/assets/asset-prefixes.js +4 -8
  71. package/dist/assets/asset-src.d.ts +5 -22
  72. package/dist/assets/asset-src.js +5 -21
  73. package/dist/assets/factory.d.ts +1 -2
  74. package/dist/assets/factory.js +1 -2
  75. package/dist/assets/finalize.d.ts +3 -1
  76. package/dist/assets/finalize.js +3 -1
  77. package/dist/assets/index.d.ts +3 -3
  78. package/dist/assets/index.js +1 -1
  79. package/dist/assets/keys.d.ts +5 -3
  80. package/dist/assets/keys.js +6 -3
  81. package/dist/assets/pipeline.d.ts +3 -2
  82. package/dist/assets/pipeline.js +22 -56
  83. package/dist/assets/sharp-loader.d.ts +2 -10
  84. package/dist/assets/sharp-loader.js +2 -10
  85. package/dist/assets/store-local.d.ts +1 -2
  86. package/dist/assets/store-local.js +1 -2
  87. package/dist/assets/store-s3.d.ts +3 -4
  88. package/dist/assets/svg-sanitizer.d.ts +6 -14
  89. package/dist/assets/svg-sanitizer.js +6 -14
  90. package/dist/assets/transform-directives.d.ts +3 -4
  91. package/dist/assets/transform-directives.js +1 -1
  92. package/dist/assets/transform.d.ts +19 -30
  93. package/dist/assets/transform.js +18 -31
  94. package/dist/auth/cache.d.ts +2 -3
  95. package/dist/auth/cache.js +2 -3
  96. package/dist/auth/caching-auth-plugin.d.ts +11 -22
  97. package/dist/auth/caching-auth-plugin.js +12 -14
  98. package/dist/auth/context-helpers.d.ts +6 -20
  99. package/dist/auth/context-helpers.js +5 -17
  100. package/dist/auth/file-based-auth-cache.d.ts +10 -21
  101. package/dist/auth/file-based-auth-cache.js +23 -51
  102. package/dist/auth/plugin.d.ts +29 -61
  103. package/dist/auth/plugin.js +9 -13
  104. package/dist/auth/types.d.ts +11 -20
  105. package/dist/authorization/branch.d.ts +30 -49
  106. package/dist/authorization/branch.js +16 -42
  107. package/dist/authorization/content.d.ts +11 -40
  108. package/dist/authorization/content.js +13 -45
  109. package/dist/authorization/groups/index.d.ts +0 -3
  110. package/dist/authorization/groups/index.js +0 -3
  111. package/dist/authorization/groups/loader.d.ts +14 -28
  112. package/dist/authorization/groups/loader.js +14 -38
  113. package/dist/authorization/groups/schema.d.ts +0 -6
  114. package/dist/authorization/groups/schema.js +4 -7
  115. package/dist/authorization/helpers.d.ts +9 -28
  116. package/dist/authorization/helpers.js +9 -28
  117. package/dist/authorization/index.d.ts +3 -25
  118. package/dist/authorization/index.js +3 -35
  119. package/dist/authorization/path.d.ts +6 -13
  120. package/dist/authorization/path.js +8 -25
  121. package/dist/authorization/permissions/index.d.ts +0 -3
  122. package/dist/authorization/permissions/index.js +0 -3
  123. package/dist/authorization/permissions/loader.d.ts +14 -27
  124. package/dist/authorization/permissions/loader.js +14 -32
  125. package/dist/authorization/permissions/schema.d.ts +1 -6
  126. package/dist/authorization/permissions/schema.js +6 -13
  127. package/dist/authorization/protected-branch.d.ts +36 -65
  128. package/dist/authorization/protected-branch.js +29 -41
  129. package/dist/authorization/settings-file-store.d.ts +38 -81
  130. package/dist/authorization/settings-file-store.js +38 -79
  131. package/dist/authorization/types.d.ts +4 -26
  132. package/dist/authorization/types.js +0 -6
  133. package/dist/authorization/validation.d.ts +1 -23
  134. package/dist/authorization/validation.js +1 -24
  135. package/dist/branch-health.d.ts +39 -67
  136. package/dist/branch-health.js +27 -43
  137. package/dist/branch-metadata-file.d.ts +16 -32
  138. package/dist/branch-metadata-file.js +13 -26
  139. package/dist/branch-metadata.d.ts +49 -80
  140. package/dist/branch-metadata.js +57 -87
  141. package/dist/branch-registry.d.ts +26 -64
  142. package/dist/branch-registry.js +44 -93
  143. package/dist/branch-schema-cache.d.ts +34 -124
  144. package/dist/branch-schema-cache.js +49 -155
  145. package/dist/branch-workspace.d.ts +4 -4
  146. package/dist/branch-workspace.js +15 -19
  147. package/dist/build/generate-ai-content.d.ts +1 -0
  148. package/dist/build/generate-ai-content.js +12 -25
  149. package/dist/build-canopy.d.ts +17 -27
  150. package/dist/build-canopy.js +16 -23
  151. package/dist/build-mode.d.ts +25 -27
  152. package/dist/build-mode.js +25 -29
  153. package/dist/cli/cli.d.ts +15 -26
  154. package/dist/cli/cli.js +601 -978
  155. package/dist/cli/generate-ai-content.js +351 -628
  156. package/dist/cli/github-app-manifest.d.ts +84 -0
  157. package/dist/cli/github-app-manifest.js +161 -0
  158. package/dist/cli/init-github-app.d.ts +110 -444
  159. package/dist/cli/init-github-app.js +236 -773
  160. package/dist/cli/init.js +39 -80
  161. package/dist/cli/migrate.d.ts +13 -10
  162. package/dist/cli/migrate.js +22 -30
  163. package/dist/cli/project-detect.d.ts +17 -31
  164. package/dist/cli/project-detect.js +31 -42
  165. package/dist/cli/project-root.d.ts +4 -11
  166. package/dist/cli/project-root.js +4 -11
  167. package/dist/cli/prompt.d.ts +10 -0
  168. package/dist/cli/prompt.js +67 -0
  169. package/dist/cli/sync.d.ts +0 -8
  170. package/dist/cli/sync.js +8 -28
  171. package/dist/cli/template-files/middleware.ts.template +15 -29
  172. package/dist/cli/templates.d.ts +2 -12
  173. package/dist/cli/templates.js +4 -4
  174. package/dist/client.d.ts +1 -1
  175. package/dist/comment-store.d.ts +32 -53
  176. package/dist/comment-store.js +32 -52
  177. package/dist/config/flatten.d.ts +0 -3
  178. package/dist/config/flatten.js +2 -12
  179. package/dist/config/helpers.js +2 -2
  180. package/dist/config/index.d.ts +2 -2
  181. package/dist/config/index.js +1 -4
  182. package/dist/config/schemas/collection.d.ts +0 -8
  183. package/dist/config/schemas/collection.js +0 -10
  184. package/dist/config/schemas/config.d.ts +6 -78
  185. package/dist/config/schemas/config.js +38 -54
  186. package/dist/config/schemas/field.d.ts +2 -242
  187. package/dist/config/schemas/field.js +9 -20
  188. package/dist/config/schemas/media.js +1 -1
  189. package/dist/config/schemas/permissions.js +0 -2
  190. package/dist/config/schemas/url.d.ts +5 -6
  191. package/dist/config/schemas/url.js +5 -6
  192. package/dist/config/types.d.ts +45 -33
  193. package/dist/config/types.js +0 -1
  194. package/dist/config.d.ts +1 -8
  195. package/dist/config.js +1 -9
  196. package/dist/content-id-index.d.ts +76 -188
  197. package/dist/content-id-index.js +79 -230
  198. package/dist/content-index-generation.d.ts +27 -48
  199. package/dist/content-index-generation.js +35 -84
  200. package/dist/content-index-registry.d.ts +15 -24
  201. package/dist/content-index-registry.js +5 -9
  202. package/dist/content-listing.d.ts +64 -107
  203. package/dist/content-listing.js +68 -118
  204. package/dist/content-reader.d.ts +20 -29
  205. package/dist/content-reader.js +10 -18
  206. package/dist/content-store.d.ts +210 -336
  207. package/dist/content-store.js +413 -657
  208. package/dist/content-tree.d.ts +44 -86
  209. package/dist/content-tree.js +26 -54
  210. package/dist/context.d.ts +67 -94
  211. package/dist/context.js +53 -72
  212. package/dist/dev-content-watcher.d.ts +18 -18
  213. package/dist/dev-content-watcher.js +41 -44
  214. package/dist/editor/BranchManager.d.ts +3 -6
  215. package/dist/editor/BranchManager.js +24 -44
  216. package/dist/editor/CanopyEditor.js +5 -2
  217. package/dist/editor/CommentsPanel.js +0 -2
  218. package/dist/editor/Editor.js +19 -76
  219. package/dist/editor/EditorAuthGate.d.ts +27 -0
  220. package/dist/editor/EditorAuthGate.js +140 -0
  221. package/dist/editor/EntryNavigator.js +0 -20
  222. package/dist/editor/FormRenderer.d.ts +1 -2
  223. package/dist/editor/FormRenderer.js +8 -23
  224. package/dist/editor/admin/SystemHealthPanel.js +20 -37
  225. package/dist/editor/admin/useSystemHealth.d.ts +2 -3
  226. package/dist/editor/admin/useSystemHealth.js +10 -12
  227. package/dist/editor/client-reference-resolver.d.ts +2 -5
  228. package/dist/editor/client-reference-resolver.js +2 -19
  229. package/dist/editor/comments/BranchComments.js +0 -4
  230. package/dist/editor/comments/EntryComments.js +0 -4
  231. package/dist/editor/comments/FieldWrapper.js +0 -4
  232. package/dist/editor/comments/InlineCommentThread.js +0 -2
  233. package/dist/editor/comments/ThreadCarousel.d.ts +0 -58
  234. package/dist/editor/comments/ThreadCarousel.js +0 -12
  235. package/dist/editor/components/EditorFooter.d.ts +0 -8
  236. package/dist/editor/components/EditorFooter.js +0 -5
  237. package/dist/editor/components/EditorHeader.d.ts +0 -31
  238. package/dist/editor/components/EditorHeader.js +21 -71
  239. package/dist/editor/components/EditorSidebar.d.ts +0 -19
  240. package/dist/editor/components/EditorSidebar.js +0 -16
  241. package/dist/editor/components/EntryCreateModal.d.ts +4 -4
  242. package/dist/editor/components/EntryCreateModal.js +7 -22
  243. package/dist/editor/components/RenameEntryModal.js +0 -4
  244. package/dist/editor/components/UserBadge.js +0 -10
  245. package/dist/editor/components/index.js +0 -2
  246. package/dist/editor/context/ApiClientContext.d.ts +8 -7
  247. package/dist/editor/context/ApiClientContext.js +39 -11
  248. package/dist/editor/context/AssetContext.d.ts +7 -17
  249. package/dist/editor/context/AssetContext.js +7 -17
  250. package/dist/editor/context/EditorIdentityContext.d.ts +13 -0
  251. package/dist/editor/context/EditorIdentityContext.js +7 -0
  252. package/dist/editor/context/EditorStateContext.d.ts +10 -41
  253. package/dist/editor/context/EditorStateContext.js +7 -23
  254. package/dist/editor/context/SWRProvider.d.ts +3 -6
  255. package/dist/editor/context/index.d.ts +1 -20
  256. package/dist/editor/context/index.js +1 -20
  257. package/dist/editor/editor-utils.d.ts +8 -47
  258. package/dist/editor/editor-utils.js +19 -72
  259. package/dist/editor/fields/BlockField.d.ts +2 -2
  260. package/dist/editor/fields/BlockField.js +1 -2
  261. package/dist/editor/fields/CodeField.d.ts +0 -1
  262. package/dist/editor/fields/CodeField.js +0 -1
  263. package/dist/editor/fields/DateTimeField.d.ts +15 -22
  264. package/dist/editor/fields/DateTimeField.js +17 -26
  265. package/dist/editor/fields/ImageField.d.ts +2 -2
  266. package/dist/editor/fields/ImageField.js +8 -14
  267. package/dist/editor/fields/InlineGroupField.d.ts +0 -1
  268. package/dist/editor/fields/InlineGroupField.js +0 -1
  269. package/dist/editor/fields/MarkdownField.d.ts +0 -1
  270. package/dist/editor/fields/MarkdownField.js +6 -11
  271. package/dist/editor/fields/MdxImageDialog.d.ts +1 -1
  272. package/dist/editor/fields/MdxImageDialog.js +0 -1
  273. package/dist/editor/fields/NumberField.d.ts +9 -19
  274. package/dist/editor/fields/NumberField.js +11 -22
  275. package/dist/editor/fields/NumberListField.d.ts +7 -10
  276. package/dist/editor/fields/NumberListField.js +7 -10
  277. package/dist/editor/fields/ObjectField.d.ts +5 -8
  278. package/dist/editor/fields/ObjectField.js +0 -1
  279. package/dist/editor/fields/ReferenceField.d.ts +1 -1
  280. package/dist/editor/fields/ReferenceField.js +11 -16
  281. package/dist/editor/fields/SelectField.d.ts +2 -2
  282. package/dist/editor/fields/SelectField.js +0 -1
  283. package/dist/editor/fields/StringListField.d.ts +0 -4
  284. package/dist/editor/fields/StringListField.js +4 -9
  285. package/dist/editor/fields/TextField.d.ts +0 -1
  286. package/dist/editor/fields/TextField.js +0 -1
  287. package/dist/editor/fields/ToggleField.d.ts +0 -1
  288. package/dist/editor/fields/ToggleField.js +0 -1
  289. package/dist/editor/fields/entry-link/EntryLinkContext.js +2 -4
  290. package/dist/editor/fields/entry-link/InsertEntryLink.d.ts +0 -3
  291. package/dist/editor/fields/entry-link/InsertEntryLink.js +0 -4
  292. package/dist/editor/group-manager/ExternalGroupsTab.d.ts +0 -3
  293. package/dist/editor/group-manager/ExternalGroupsTab.js +0 -1
  294. package/dist/editor/group-manager/GroupCard.d.ts +0 -3
  295. package/dist/editor/group-manager/GroupForm.d.ts +0 -3
  296. package/dist/editor/group-manager/InternalGroupsTab.d.ts +0 -3
  297. package/dist/editor/group-manager/InternalGroupsTab.js +0 -2
  298. package/dist/editor/group-manager/MemberList.d.ts +0 -3
  299. package/dist/editor/group-manager/hooks/useExternalGroupSearch.d.ts +0 -3
  300. package/dist/editor/group-manager/hooks/useExternalGroupSearch.js +0 -3
  301. package/dist/editor/group-manager/hooks/useGroupState.d.ts +0 -3
  302. package/dist/editor/group-manager/hooks/useGroupState.js +0 -5
  303. package/dist/editor/group-manager/hooks/useUserSearch.d.ts +0 -3
  304. package/dist/editor/group-manager/hooks/useUserSearch.js +0 -3
  305. package/dist/editor/group-manager/index.d.ts +0 -6
  306. package/dist/editor/group-manager/index.js +0 -10
  307. package/dist/editor/group-manager/types.d.ts +2 -5
  308. package/dist/editor/group-manager/types.js +0 -3
  309. package/dist/editor/hooks/index.d.ts +6 -11
  310. package/dist/editor/hooks/index.js +6 -12
  311. package/dist/editor/hooks/useBranchActions.d.ts +0 -14
  312. package/dist/editor/hooks/useBranchActions.js +0 -22
  313. package/dist/editor/hooks/useBranchManager.d.ts +2 -48
  314. package/dist/editor/hooks/useBranchManager.js +4 -64
  315. package/dist/editor/hooks/useBranchesData.d.ts +7 -6
  316. package/dist/editor/hooks/useBranchesData.js +7 -6
  317. package/dist/editor/hooks/useCommentSystem.d.ts +0 -49
  318. package/dist/editor/hooks/useCommentSystem.js +1 -36
  319. package/dist/editor/hooks/useDraftManager.d.ts +2 -35
  320. package/dist/editor/hooks/useDraftManager.js +23 -64
  321. package/dist/editor/hooks/useEditorLayout.d.ts +0 -20
  322. package/dist/editor/hooks/useEditorLayout.js +0 -23
  323. package/dist/editor/hooks/useEntriesData.d.ts +1 -0
  324. package/dist/editor/hooks/useEntriesData.js +2 -3
  325. package/dist/editor/hooks/useEntryLinkResolution.d.ts +2 -2
  326. package/dist/editor/hooks/useEntryLinkResolution.js +2 -2
  327. package/dist/editor/hooks/useEntryManager.d.ts +2 -27
  328. package/dist/editor/hooks/useEntryManager.js +29 -78
  329. package/dist/editor/hooks/useGroupManager.d.ts +0 -21
  330. package/dist/editor/hooks/useGroupManager.js +0 -21
  331. package/dist/editor/hooks/usePermissionManager.d.ts +0 -20
  332. package/dist/editor/hooks/usePermissionManager.js +0 -20
  333. package/dist/editor/hooks/useReferenceResolution.d.ts +2 -33
  334. package/dist/editor/hooks/useReferenceResolution.js +1 -48
  335. package/dist/editor/hooks/useSchemaManager.d.ts +8 -27
  336. package/dist/editor/hooks/useSchemaManager.js +0 -19
  337. package/dist/editor/hooks/useUserContext.d.ts +2 -9
  338. package/dist/editor/hooks/useUserContext.js +10 -10
  339. package/dist/editor/hooks/useUserMetadata.d.ts +0 -2
  340. package/dist/editor/hooks/useUserMetadata.js +0 -3
  341. package/dist/editor/media/AssetCard.d.ts +0 -1
  342. package/dist/editor/media/AssetCard.js +1 -2
  343. package/dist/editor/media/CropStep.d.ts +0 -1
  344. package/dist/editor/media/CropStep.js +0 -1
  345. package/dist/editor/media/MediaLibrary.d.ts +1 -2
  346. package/dist/editor/media/MediaLibrary.js +1 -2
  347. package/dist/editor/media/MediaLibraryBody.d.ts +0 -1
  348. package/dist/editor/media/MediaLibraryBody.js +0 -1
  349. package/dist/editor/media/crop-math.d.ts +1 -1
  350. package/dist/editor/media/crop-math.js +1 -1
  351. package/dist/editor/permission-manager/GroupSelector.d.ts +0 -3
  352. package/dist/editor/permission-manager/PermissionEditor.d.ts +0 -4
  353. package/dist/editor/permission-manager/PermissionEditor.js +0 -1
  354. package/dist/editor/permission-manager/PermissionLevelBadge.d.ts +0 -7
  355. package/dist/editor/permission-manager/PermissionLevelBadge.js +0 -4
  356. package/dist/editor/permission-manager/PermissionTree.d.ts +0 -4
  357. package/dist/editor/permission-manager/UserSelector.d.ts +0 -3
  358. package/dist/editor/permission-manager/constants.d.ts +0 -3
  359. package/dist/editor/permission-manager/hooks/useGroupsAndUsers.d.ts +0 -3
  360. package/dist/editor/permission-manager/hooks/useGroupsAndUsers.js +0 -10
  361. package/dist/editor/permission-manager/hooks/usePermissionTree.d.ts +0 -14
  362. package/dist/editor/permission-manager/hooks/usePermissionTree.js +0 -11
  363. package/dist/editor/permission-manager/index.d.ts +0 -7
  364. package/dist/editor/permission-manager/index.js +0 -16
  365. package/dist/editor/permission-manager/types.d.ts +2 -12
  366. package/dist/editor/permission-manager/types.js +0 -3
  367. package/dist/editor/permission-manager/utils.d.ts +0 -28
  368. package/dist/editor/permission-manager/utils.js +9 -23
  369. package/dist/editor/preview-bridge.d.ts +5 -1
  370. package/dist/editor/preview-bridge.js +4 -4
  371. package/dist/editor/schema-editor/CollectionEditor.d.ts +0 -5
  372. package/dist/editor/schema-editor/CollectionEditor.js +9 -31
  373. package/dist/editor/schema-editor/EntryTypeEditor.d.ts +0 -6
  374. package/dist/editor/schema-editor/EntryTypeEditor.js +3 -24
  375. package/dist/editor/schema-editor/index.d.ts +0 -7
  376. package/dist/editor/schema-editor/index.js +0 -7
  377. package/dist/editor/utils/env.d.ts +3 -18
  378. package/dist/editor/utils/env.js +6 -25
  379. package/dist/entry-link-resolver.d.ts +13 -35
  380. package/dist/entry-link-resolver.js +20 -53
  381. package/dist/entry-schema-registry.d.ts +20 -60
  382. package/dist/entry-schema-registry.js +20 -69
  383. package/dist/entry-schema.d.ts +118 -223
  384. package/dist/entry-schema.js +46 -91
  385. package/dist/git-manager.d.ts +101 -200
  386. package/dist/git-manager.js +211 -384
  387. package/dist/github-service.d.ts +34 -75
  388. package/dist/github-service.js +37 -91
  389. package/dist/http/handler.d.ts +6 -37
  390. package/dist/http/handler.js +65 -120
  391. package/dist/http/router.d.ts +15 -32
  392. package/dist/http/router.js +34 -99
  393. package/dist/http/types.d.ts +15 -40
  394. package/dist/http/types.js +3 -7
  395. package/dist/id.d.ts +4 -10
  396. package/dist/id.js +4 -10
  397. package/dist/index.js +6 -9
  398. package/dist/operating-mode/client-safe-strategy.d.ts +7 -14
  399. package/dist/operating-mode/client-safe-strategy.js +8 -28
  400. package/dist/operating-mode/client-unsafe-strategy.d.ts +6 -16
  401. package/dist/operating-mode/client-unsafe-strategy.js +9 -34
  402. package/dist/operating-mode/client.d.ts +3 -10
  403. package/dist/operating-mode/client.js +3 -8
  404. package/dist/operating-mode/deployment-name-fixtures.d.ts +14 -18
  405. package/dist/operating-mode/deployment-name-fixtures.js +14 -18
  406. package/dist/operating-mode/deployment-name.d.ts +19 -29
  407. package/dist/operating-mode/deployment-name.js +29 -47
  408. package/dist/operating-mode/index.d.ts +4 -25
  409. package/dist/operating-mode/index.js +9 -31
  410. package/dist/operating-mode/mode-env.d.ts +32 -54
  411. package/dist/operating-mode/mode-env.js +36 -58
  412. package/dist/operating-mode/types.d.ts +24 -72
  413. package/dist/operating-mode/types.js +1 -7
  414. package/dist/paths/branch-name.d.ts +30 -40
  415. package/dist/paths/branch-name.js +30 -40
  416. package/dist/paths/branch.d.ts +4 -18
  417. package/dist/paths/branch.js +6 -22
  418. package/dist/paths/index.d.ts +2 -13
  419. package/dist/paths/index.js +3 -23
  420. package/dist/paths/normalize-server.d.ts +3 -15
  421. package/dist/paths/normalize-server.js +3 -15
  422. package/dist/paths/normalize.d.ts +13 -33
  423. package/dist/paths/normalize.js +13 -33
  424. package/dist/paths/resolve.d.ts +4 -17
  425. package/dist/paths/resolve.js +4 -22
  426. package/dist/paths/types.d.ts +12 -34
  427. package/dist/paths/types.js +5 -7
  428. package/dist/paths/validation.d.ts +22 -119
  429. package/dist/paths/validation.js +30 -148
  430. package/dist/reference-resolver.d.ts +0 -13
  431. package/dist/reference-resolver.js +0 -18
  432. package/dist/resolve-canopy-user.d.ts +16 -18
  433. package/dist/resolve-canopy-user.js +17 -26
  434. package/dist/resource-generation.d.ts +16 -25
  435. package/dist/resource-generation.js +34 -97
  436. package/dist/schema/meta-loader.d.ts +2 -14
  437. package/dist/schema/meta-loader.js +15 -64
  438. package/dist/schema/resolver.d.ts +1 -4
  439. package/dist/schema/resolver.js +1 -6
  440. package/dist/schema/schema-store-types.d.ts +0 -12
  441. package/dist/schema/schema-store.d.ts +61 -138
  442. package/dist/schema/schema-store.js +85 -282
  443. package/dist/schema/types.d.ts +0 -4
  444. package/dist/server.d.ts +62 -93
  445. package/dist/server.js +63 -94
  446. package/dist/services.d.ts +23 -47
  447. package/dist/services.js +55 -98
  448. package/dist/settings-workspace.d.ts +17 -30
  449. package/dist/settings-workspace.js +51 -81
  450. package/dist/static/index.d.ts +26 -52
  451. package/dist/static/index.js +33 -67
  452. package/dist/{worker/task-queue.d.ts → task-queue/cms-task-queue.d.ts} +7 -9
  453. package/dist/task-queue/cms-task-queue.js +13 -0
  454. package/dist/task-queue/task-queue-config.d.ts +3 -0
  455. package/dist/{worker → task-queue}/task-queue-config.js +1 -6
  456. package/dist/task-queue/task-queue.d.ts +16 -22
  457. package/dist/task-queue/task-queue.js +20 -44
  458. package/dist/task-queue/types.d.ts +0 -1
  459. package/dist/task-queue/worker-status.d.ts +35 -0
  460. package/dist/task-queue/worker-status.js +40 -0
  461. package/dist/types.d.ts +40 -51
  462. package/dist/url-collision.d.ts +26 -40
  463. package/dist/url-collision.js +47 -63
  464. package/dist/url-exclusivity-fixtures.d.ts +15 -20
  465. package/dist/url-exclusivity-fixtures.js +14 -19
  466. package/dist/url-path-resolver.d.ts +8 -16
  467. package/dist/url-path-resolver.js +19 -29
  468. package/dist/user.d.ts +8 -21
  469. package/dist/user.js +10 -19
  470. package/dist/utils/async-mutex.js +4 -6
  471. package/dist/utils/atomic-write.d.ts +2 -11
  472. package/dist/utils/atomic-write.js +2 -11
  473. package/dist/utils/body-field.d.ts +8 -15
  474. package/dist/utils/body-field.js +8 -15
  475. package/dist/utils/content-serialize.d.ts +18 -24
  476. package/dist/utils/content-serialize.js +109 -160
  477. package/dist/utils/content-write-lock.d.ts +51 -106
  478. package/dist/utils/content-write-lock.js +66 -111
  479. package/dist/utils/debug.d.ts +7 -23
  480. package/dist/utils/debug.js +7 -23
  481. package/dist/utils/entry-url.d.ts +11 -23
  482. package/dist/utils/entry-url.js +11 -26
  483. package/dist/utils/error.d.ts +25 -90
  484. package/dist/utils/error.js +60 -147
  485. package/dist/utils/flatten-group-fields.d.ts +5 -7
  486. package/dist/utils/flatten-group-fields.js +5 -7
  487. package/dist/utils/format.d.ts +1 -5
  488. package/dist/utils/format.js +1 -5
  489. package/dist/utils/fs.d.ts +3 -4
  490. package/dist/utils/fs.js +3 -4
  491. package/dist/utils/git.d.ts +52 -83
  492. package/dist/utils/git.js +79 -125
  493. package/dist/utils/logger.d.ts +35 -50
  494. package/dist/utils/logger.js +35 -52
  495. package/dist/utils/provisioning-lock.d.ts +23 -35
  496. package/dist/utils/provisioning-lock.js +49 -69
  497. package/dist/utils/sanitize-href.d.ts +5 -10
  498. package/dist/utils/sanitize-href.js +8 -18
  499. package/dist/utils/title-field.d.ts +17 -20
  500. package/dist/utils/title-field.js +18 -27
  501. package/dist/utils/typed-filename.d.ts +20 -48
  502. package/dist/utils/typed-filename.js +25 -61
  503. package/dist/utils/url-prefix.d.ts +3 -3
  504. package/dist/utils/url-prefix.js +3 -3
  505. package/dist/validation/block-structural-keys.d.ts +16 -31
  506. package/dist/validation/block-structural-keys.js +19 -29
  507. package/dist/validation/deletion-checker.d.ts +0 -34
  508. package/dist/validation/deletion-checker.js +1 -43
  509. package/dist/validation/entry-link-validator.d.ts +6 -13
  510. package/dist/validation/entry-link-validator.js +4 -13
  511. package/dist/validation/entry-type-reference-validator.d.ts +13 -18
  512. package/dist/validation/entry-type-reference-validator.js +13 -18
  513. package/dist/validation/entry-validator.d.ts +13 -25
  514. package/dist/validation/entry-validator.js +15 -32
  515. package/dist/validation/field-traversal.d.ts +3 -30
  516. package/dist/validation/field-traversal.js +1 -32
  517. package/dist/validation/reference-validator.d.ts +5 -24
  518. package/dist/validation/reference-validator.js +5 -30
  519. package/dist/worker/cms-worker.d.ts +172 -232
  520. package/dist/worker/cms-worker.js +241 -333
  521. package/dist/worker/git-sync.d.ts +32 -133
  522. package/dist/worker/git-sync.js +129 -191
  523. package/dist/worker/github-auth.d.ts +13 -19
  524. package/dist/worker/github-auth.js +13 -19
  525. package/dist/worker/history-rewrite.d.ts +53 -66
  526. package/dist/worker/history-rewrite.js +54 -60
  527. package/dist/worker/log.d.ts +24 -41
  528. package/dist/worker/log.js +25 -42
  529. package/dist/worker/rebase.d.ts +20 -110
  530. package/dist/worker/rebase.js +279 -354
  531. package/dist/worker/task-runner.d.ts +32 -66
  532. package/dist/worker/task-runner.js +126 -162
  533. package/dist/worker/worker-context.d.ts +41 -81
  534. package/package.json +4 -4
  535. package/dist/cli/template-files/middleware-clerk.ts.template +0 -37
  536. package/dist/worker/task-queue-config.d.ts +0 -8
  537. package/dist/worker/task-queue.js +0 -19
  538. package/dist/worker/worker-status.d.ts +0 -47
  539. package/dist/worker/worker-status.js +0 -52
@@ -3,16 +3,16 @@ export { PermanentTaskError, isPermanentTaskFailure } from './task-runner.js';
3
3
  export { workerLog, workerLogWarn, workerLogError, installWorkerLogger } from './log.js';
4
4
  export { normalizeGitHubAppPrivateKey, DEFAULT_GIT_TOKEN_MINT_TIMEOUT_MS, DEFAULT_GITHUB_TOKEN_REFRESH_MIN_INTERVAL_MS, type GitHubAppAuth, type GitHubAuthConfig, } from './github-auth.js';
5
5
  /**
6
- * Auth cache refresh function type.
7
- * Adopters provide their auth-plugin-specific implementation.
8
- * For Clerk: use refreshClerkCache from canopycms-auth-clerk/cache-writer.
6
+ * Auth cache refresh function type; adopters supply their auth-plugin-specific
7
+ * implementation (for Clerk, refreshClerkCache from
8
+ * canopycms-auth-clerk/cache-writer).
9
9
  */
10
10
  export type AuthCacheRefresher = () => Promise<void>;
11
11
  /**
12
12
  * `githubToken` / `githubAppAuth` / `gitTokenMintTimeoutMs` are declared
13
- * together in `GitHubAuthConfig` (./github-auth) because they are one
14
- * decision, resolved in one place. The token remains the documented default;
15
- * see that interface for the two shapes and why an App is optional.
13
+ * together in `GitHubAuthConfig` (./github-auth) because they are one decision,
14
+ * resolved in one place. The token is the documented default; see that
15
+ * interface for the two shapes and why an App is optional.
16
16
  */
17
17
  export interface CmsWorkerConfig extends GitHubAuthConfig {
18
18
  /** Path to workspace root on EFS (e.g., /mnt/efs/workspace) */
@@ -21,11 +21,7 @@ export interface CmsWorkerConfig extends GitHubAuthConfig {
21
21
  githubOwner: string;
22
22
  /** GitHub repo name (e.g., 'docs-site') */
23
23
  githubRepo: string;
24
- /**
25
- * Auth cache refresh callback. Called periodically to update the auth
26
- * metadata cache on EFS. Adopters provide their auth-plugin-specific
27
- * implementation (e.g., refreshClerkCache from canopycms-auth-clerk).
28
- */
24
+ /** Called periodically to update the auth metadata cache on EFS. */
29
25
  refreshAuthCache?: AuthCacheRefresher;
30
26
  /** Task queue poll interval in ms (default: 5000) */
31
27
  taskPollInterval?: number;
@@ -36,22 +32,20 @@ export interface CmsWorkerConfig extends GitHubAuthConfig {
36
32
  /** Base branch name (default: 'main') */
37
33
  baseBranch?: string;
38
34
  /**
39
- * Deployment name, used to compute THIS worker's own settings branch
40
- * (`canopycms-settings-{deploymentName}`, default: 'prod' — matches
41
- * ProdStrategy's mode default in operating-mode/client-unsafe-strategy.ts,
42
- * the only mode the worker runs in). Two deployments can share one GitHub
43
- * repo with distinct settings branches; this tells the worker which one it
44
- * owns, so it never pushes another deployment's settings branch (see
45
- * `pushSettingsBranches`).
35
+ * Names THIS worker's own settings branch
36
+ * (`canopycms-settings-{deploymentName}`, default 'prod' — ProdStrategy's
37
+ * mode default in operating-mode/client-unsafe-strategy.ts, the only mode the
38
+ * worker runs in). Two deployments can share one GitHub repo with distinct
39
+ * settings branches; this is what tells the worker which one it owns, so it
40
+ * never pushes another deployment's (see `pushSettingsBranches`).
46
41
  */
47
42
  deploymentName?: string;
48
43
  /**
49
- * Explicit settings branch name, taking precedence over `deploymentName`.
50
- * Mirrors the strategy's own precedence (`config.settingsBranch` short-circuits
51
- * `getSettingsBranchName` before `deploymentName` is consulted, see
52
- * operating-mode/client-unsafe-strategy.ts): an adopter who overrides
53
- * `settingsBranch` in canopycms.config.ts must set this too, or the worker
54
- * would own a branch name the Lambda never writes to.
44
+ * Explicit settings branch name, taking precedence over `deploymentName` and
45
+ * mirroring the strategy's own precedence (operating-mode/
46
+ * client-unsafe-strategy.ts). An adopter who overrides `settingsBranch` in
47
+ * canopycms.config.ts MUST set this too, or the worker owns a branch name the
48
+ * Lambda never writes to.
55
49
  */
56
50
  settingsBranch?: string;
57
51
  /** Max tasks to process per cycle (default: 10) */
@@ -63,23 +57,20 @@ export interface CmsWorkerConfig extends GitHubAuthConfig {
63
57
  /** Content root directory name relative to repo root (default: 'content') */
64
58
  contentRoot?: string;
65
59
  /**
66
- * Worker lock staleness TTL in ms (default: 60000, minimum 2000).
67
- * The holder refreshes the lock heartbeat at half this interval; a lock
68
- * whose heartbeat is older than this is considered abandoned and taken
69
- * over by the next worker to start.
60
+ * Worker lock staleness TTL in ms (default 60000, minimum 2000). The holder
61
+ * refreshes the heartbeat at half this interval; a lock whose heartbeat is
62
+ * older than this is abandoned and taken over by the next worker to start.
70
63
  */
71
64
  lockStaleMs?: number;
72
65
  }
73
66
  /**
74
- * CMS Worker daemon.
75
- * Handles operations that Lambda (with no internet) cannot perform:
76
- * - Processing queued tasks (push branches, create PRs)
77
- * - Syncing bare repo with GitHub
78
- * - Rebasing active branch workspaces
79
- * - Refreshing auth metadata cache (via pluggable callback)
67
+ * CMS Worker daemon: the operations Lambda, which has no internet, cannot
68
+ * perform -- draining the task queue, syncing the bare repo with GitHub,
69
+ * rebasing branch workspaces, and refreshing the auth metadata cache through a
70
+ * pluggable callback.
80
71
  *
81
- * Auth-agnostic: does not depend on any specific auth provider.
82
- * Cloud-agnostic: uses git/Octokit directly, no AWS SDK dependency.
72
+ * Auth-agnostic (no specific auth provider) and cloud-agnostic (git/Octokit
73
+ * directly, no AWS SDK dependency).
83
74
  */
84
75
  export declare class CmsWorker {
85
76
  private config;
@@ -105,40 +96,33 @@ export declare class CmsWorker {
105
96
  private githubAuth?;
106
97
  constructor(config: CmsWorkerConfig);
107
98
  /**
108
- * Lazily get (and initialize if necessary) this worker's self-reported
109
- * status object (PR-W1). Normally set once, up front, at the top of
110
- * start(). The lazy fallback here covers two cases: (1) something in
111
- * start() reaching a status-write point before that normal init runs
112
- * (defensive -- see start()'s catch), and (2) unit tests that exercise
113
- * syncGit()/processTaskQueue() directly without calling start() first.
99
+ * This worker's self-reported status object, initialized on first use.
100
+ * Normally set at the top of start(); the lazy fallback covers something in
101
+ * start() reaching a status-write point before that (see start()'s catch) and
102
+ * unit tests driving syncGit()/processTaskQueue() without calling start().
114
103
  */
115
104
  private ensureStatusReport;
116
105
  /**
117
106
  * Resolve this deployment's settings branch, throwing if the infra-stamped
118
107
  * deployment name is not a valid git ref component.
119
108
  *
120
- * Routed through the shared resolver, not a local `?? 'prod'`: it is the
109
+ * Routed through the shared resolver, not a local `?? 'prod'`: that is the
121
110
  * single definition of the env > config > mode-default precedence the Lambda
122
- * already follows, and the only place the resolved value is validated.
123
- * Without it the worker could silently own a different settings branch than
124
- * the Lambda writing to the same workspace -- and pushSettingsBranches would
125
- * then report the real branch as foreign and never push it.
126
- *
127
- * DEFERRED out of the constructor deliberately, and this is the whole point
128
- * of the method existing. Resolving there made the throw land during `new
129
- * CmsWorker(...)` (canopycms-cdk/worker/index.ts constructs before it calls
130
- * start()), which is BEFORE the only code that writes `lastFatalError` --
131
- * start()'s catch. The result was billed as "a loud startup exit" but was
132
- * nothing of the kind: with systemd `Type=simple` + `Restart=always` and no
133
- * cfn-signal, an invalid deployment name produced an invisible ~5s
134
- * crash-loop that `cdk deploy` reported as success while the admin panel
135
- * showed the worker as 'absent' with no fatal error to explain it. Resolving
136
- * inside start()'s try block instead means the same throw is recorded to
137
- * worker-status.json and surfaces in the admin panel.
138
- *
139
- * Lazy rather than start()-only so the value is still available to unit tests
140
- * that drive pushSettingsBranches() directly without calling start() -- the
141
- * same reason ensureStatusReport() above is shaped this way. Idempotent: the
111
+ * follows, and the only place the resolved value is validated. Without it the
112
+ * worker can silently own a different settings branch than the Lambda writing
113
+ * to the same workspace, and pushSettingsBranches then reports the real branch
114
+ * as foreign and never pushes it.
115
+ *
116
+ * DEFERRED out of the constructor deliberately, which is the whole point of
117
+ * the method existing: canopycms-cdk/worker/index.ts constructs the worker
118
+ * before calling start(), so a throw during `new CmsWorker(...)` lands BEFORE
119
+ * the only code that writes `lastFatalError` -- start()'s catch. Under
120
+ * systemd `Type=simple` + `Restart=always` with no cfn-signal, that is an
121
+ * invisible ~5s crash-loop that `cdk deploy` reports as success while the
122
+ * admin panel shows the worker 'absent' with no fatal error to explain it.
123
+ *
124
+ * Lazy rather than start()-only so unit tests driving pushSettingsBranches()
125
+ * still see the value, exactly as ensureStatusReport() above. Idempotent: the
142
126
  * resolver is pure, so a later call returns the identical string.
143
127
  */
144
128
  private ensureSettingsBranch;
@@ -146,15 +130,11 @@ export declare class CmsWorker {
146
130
  * Build the {@link WorkerContext} handed to the extracted clusters
147
131
  * (task-runner.ts, git-sync.ts, rebase.ts, history-rewrite.ts).
148
132
  *
149
- * Built FRESH on every call rather than once in the constructor, and the
150
- * instance-backed members are functions rather than copied values. Both
151
- * choices exist for the same reason: the test suite drives this class by
152
- * replacing `octokit` and `buildGitHubUrl` ON THE INSTANCE, by setting
153
- * `running` directly, and by subclassing to override the two rebase test
154
- * hooks. A context that captured any of those at construction time would hand
155
- * the extracted code the pre-test value -- which for `buildGitHubUrl` means a
156
- * test's push going to github.com for real instead of its local fixture repo.
157
- * See WorkerContext's doc comment for the full list.
133
+ * Built FRESH on every call, with instance-backed members as functions rather
134
+ * than copied values. See WorkerContext's INVARIANT: a context that captured
135
+ * any of them at construction time would hand the extracted code the pre-test
136
+ * value, which for `buildGitHubUrl` means a test's push going to github.com
137
+ * for real instead of its local fixture repo.
158
138
  */
159
139
  private ctx;
160
140
  start(): Promise<void>;
@@ -163,50 +143,45 @@ export declare class CmsWorker {
163
143
  * Acquire the cross-host worker lock (DEP-C2).
164
144
  *
165
145
  * The task queue is single-consumer (see task-queue/task-queue.ts): two
166
- * concurrent workers would double-process tasks (duplicate pushes, duplicate
167
- * PRs). The workspace lives on a shared filesystem (EFS), so mutual
168
- * exclusion must be sound ACROSS HOSTS — a PID liveness probe
169
- * (`process.kill(pid, 0)`) only means something on the holder's own machine
170
- * and must never participate in staleness decisions.
146
+ * concurrent workers would double-process tasks, duplicating pushes and PRs.
147
+ * The workspace lives on EFS, so mutual exclusion must be sound ACROSS HOSTS
148
+ * — a PID liveness probe (`process.kill(pid, 0)`) means something only on the
149
+ * holder's own machine and must NEVER participate in staleness decisions.
171
150
  *
172
151
  * proper-lockfile provides a heartbeat lease with no PID involved: the lock
173
152
  * is a directory created atomically (mkdir — atomic on NFS/EFS), the holder
174
- * refreshes its mtime every lockStaleMs/2, and the lock is considered
175
- * abandoned — and taken over — only when that heartbeat is older than
176
- * lockStaleMs. Liveness is judged purely by heartbeat freshness.
153
+ * refreshes its mtime every lockStaleMs/2, and the lock is abandoned, and
154
+ * taken over, only once that heartbeat is older than lockStaleMs.
177
155
  *
178
156
  * No acquire retries: a second worker exits immediately, matching daemon
179
- * semantics (the supervisor restarts it later). After a crash, the dead
180
- * holder's heartbeat expires within lockStaleMs and the next start succeeds.
157
+ * semantics. After a crash the dead holder's heartbeat expires within
158
+ * lockStaleMs and the next start succeeds.
181
159
  *
182
- * Staleness is judged by comparing the lock's mtime against the local
183
- * clock, so correct cross-host takeover assumes reasonable clock agreement
184
- * between hosts (e.g. NTP); with the default TTL, ordinary clock skew is
185
- * negligible, but a host with a badly wrong clock could misjudge liveness.
160
+ * Staleness compares the lock's mtime against the LOCAL clock, so correct
161
+ * cross-host takeover assumes reasonable clock agreement (NTP). Ordinary skew
162
+ * is negligible at the default TTL; a badly wrong clock misjudges liveness.
186
163
  */
187
164
  private acquireLock;
188
165
  private releaseLock;
189
166
  /**
190
- * Schedule a function to run repeatedly with setTimeout chaining.
191
- * The next invocation starts `interval` ms after the previous one completes,
192
- * preventing overlapping executions.
167
+ * Run `fn` repeatedly, the next invocation starting `interval` ms after the
168
+ * previous one COMPLETES. setTimeout chaining rather than setInterval, so
169
+ * executions cannot overlap when one runs longer than the interval.
193
170
  */
194
171
  private scheduleLoop;
195
172
  /**
196
173
  * Whether the bare repo at `gitDir` has a local `refs/heads/<baseBranch>`.
197
174
  *
198
- * Uses an explicit `--git-dir` invocation rather than `simpleGit({ baseDir
199
- * })` so this also works in sandboxed/CI git environments that set
200
- * `safe.bareRepository=explicit` (which refuses cwd-based discovery of
201
- * bare repos but expressly allows `--git-dir` — see
202
- * GitManager.bareRemoteHasBranch for the same pattern).
175
+ * Explicit `--git-dir` rather than `simpleGit({ baseDir })`, so this also
176
+ * works where `safe.bareRepository=explicit` refuses cwd-based discovery of
177
+ * bare repos but expressly allows `--git-dir` (same pattern as
178
+ * GitManager.bareRemoteHasBranch).
203
179
  *
204
- * Deliberately omits `--quiet`: simple-git only treats a task as failed
205
- * when the process both exits non-zero AND writes to stderr
206
- * (isTaskError), so a quiet, silent-on-failure `--verify` would leave a
207
- * missing branch indistinguishable from success. Without `--quiet`,
208
- * `rev-parse --verify` writes its "fatal: ..." to stderr on failure, which
209
- * is what makes simple-git reject the promise here.
180
+ * Deliberately omits `--quiet`: simple-git treats a task as failed only when
181
+ * the process exits non-zero AND writes to stderr, so a silent-on-failure
182
+ * `--verify` would leave a missing branch indistinguishable from success.
183
+ * Without `--quiet`, `rev-parse --verify` writes "fatal: ..." to stderr,
184
+ * which is what makes simple-git reject the promise here.
210
185
  */
211
186
  private verifyBaseBranchExists;
212
187
  /**
@@ -215,36 +190,31 @@ export declare class CmsWorker {
215
190
  *
216
191
  * `git clone https://x-access-token:<token>@github.com/...` records that URL
217
192
  * verbatim as `remote.origin.url`, and for `remote.git` that config lives on
218
- * shared EFS. The security model in docs/deploying-to-aws.md -- "If Lambda is
219
- * compromised, an attacker can read/write content on EFS but cannot push to
220
- * GitHub", "Secrets stay on the worker" -- is false while that string is
221
- * there: a compromised Lambda could read the token off EFS and, despite
222
- * having no egress of its own, exfiltrate it by writing it into branch
223
- * content the worker then pushes to GitHub.
193
+ * shared EFS. The security model in docs/deploying-to-aws.md -- a compromised
194
+ * Lambda can read/write EFS content but cannot push to GitHub, secrets stay
195
+ * on the worker -- is false while that string is there: the Lambda could read
196
+ * the token off EFS and, with no egress of its own, exfiltrate it by writing
197
+ * it into branch content the worker then pushes to GitHub.
224
198
  *
225
199
  * Nothing needs the remote: every push passes the URL explicitly as an
226
- * argument (see the `git.push(this.buildGitHubUrl(), ...)` call sites), and
227
- * `verifyBaseBranchExists` reads local refs.
200
+ * argument, and `verifyBaseBranchExists` reads local refs.
228
201
  *
229
202
  * VERIFIES rather than assuming: it re-reads the config and throws if the URL
230
- * survives, because the previous code's `.catch(() => {})` meant a failed
231
- * scrub was indistinguishable from a successful one.
203
+ * survives, so a failed scrub is never indistinguishable from a clean one.
232
204
  */
233
205
  private scrubPersistedRemote;
234
206
  /**
235
- * Ensure remote.git bare repo exists.
236
- * On first run, clone from GitHub as a bare repo.
207
+ * Ensure the remote.git bare repo exists, cloning it from GitHub on first
208
+ * run.
237
209
  *
238
210
  * Empty-remote guard: simple-git's bare clone of an EMPTY GitHub repo (no
239
- * commits, or a base branch that's never been pushed) exits 0 and produces
240
- * a refs-less bare repo — HEAD points at an unborn branch. `fs.stat`
241
- * cannot distinguish this from a healthy clone, so left unchecked it
242
- * silently poisons remote.git: every later branch operation (Lambda-side
243
- * clone provisioning, worker pushes) breaks, and the fs.stat short-circuit
244
- * means it never heals on its own. We verify the base branch exists right
245
- * after cloning and again on the already-exists fast path, since a
246
- * previous run could have left a poisoned remote.git behind before this
247
- * guard existed.
211
+ * commits, or a base branch never pushed) exits 0 and produces a refs-less
212
+ * bare repo whose HEAD points at an unborn branch. `fs.stat` cannot tell that
213
+ * from a healthy clone, so left unchecked it silently poisons remote.git —
214
+ * every later branch operation breaks and the fs.stat short-circuit means it
215
+ * never heals. The base branch is therefore verified right after cloning AND
216
+ * on the already-exists fast path, since a previous run can have left a
217
+ * poisoned remote.git behind.
248
218
  */
249
219
  private ensureRemoteGit;
250
220
  processTaskQueue(): Promise<void>;
@@ -256,47 +226,37 @@ export declare class CmsWorker {
256
226
  * Octokit client from it.
257
227
  *
258
228
  * DEFERRED out of the constructor deliberately, exactly as
259
- * `ensureSettingsBranch()` is, and for the same reason that method records:
229
+ * `ensureSettingsBranch()` is and for the reason that method records:
260
230
  * `resolveWorkerGitHubAuth` throws for a half-configured credential (both
261
- * set, neither set, an unusable mint timeout or refresh interval), and a throw during
262
- * `new CmsWorker(...)` lands BEFORE the only code that writes
263
- * `lastFatalError` — start()'s catch. The AWS entrypoint constructs the
264
- * worker and calls start() separately, and its `main().catch()` only logs
265
- * and exits, so a constructor throw is an invisible ~5s systemd crash-loop
266
- * that `cdk deploy` reports as success while the admin panel shows the
267
- * worker 'absent' with no fatal error to explain it. That is a shipped
268
- * regression this codebase has already paid for once (#198).
231
+ * set, neither set, an unusable mint timeout or refresh interval), and a
232
+ * throw during `new CmsWorker(...)` lands BEFORE the only code that writes
233
+ * `lastFatalError` — start()'s catch.
269
234
  *
270
235
  * Idempotent, and it does NOT replace an `octokit` a test has already
271
236
  * assigned onto the instance — see the field's comment.
272
237
  */
273
238
  private ensureGitHubAuth;
274
239
  /**
275
- * The Octokit client, built on first use.
276
- *
277
- * Every read goes through here rather than touching the field, because the
278
- * field is no longer populated by the constructor: a method reached without
279
- * start() would otherwise see `undefined`. `rebaseActiveBranches()` is
280
- * exactly that case — apps/test-app's e2e route calls it directly, and its
281
- * `pollMergeState` dispatch reads `ctx.octokit()`.
240
+ * The Octokit client, built on first use. Every read goes through here rather
241
+ * than touching the field, which the constructor does not populate: a method
242
+ * reached without start() would otherwise see `undefined`.
243
+ * `rebaseActiveBranches()` is exactly that case — apps/test-app's e2e route
244
+ * calls it directly, and its `pollMergeState` dispatch reads `ctx.octokit()`.
282
245
  */
283
246
  private octokitClient;
284
247
  /**
285
- * The single seam through which every git-over-HTTPS credential reaches a
286
- * git command. The only other consumer of the credential is Octokit, built
287
- * from the same resolution by `ensureGitHubAuth()` above.
248
+ * The single seam through which every git-over-HTTPS credential reaches a git
249
+ * command. The only other consumer is Octokit, built from the same resolution
250
+ * by `ensureGitHubAuth()` above.
288
251
  *
289
- * Async because the credential need not be a value the worker already
290
- * holds: under GitHub App auth `resolveGitToken` mints an installation
291
- * token, which lasts about an hour. Nothing may cache what this returns —
292
- * a URL built from an installation token goes stale with it. Resolving per
293
- * use is cheap: `@octokit/auth-app` answers from its own cache until the
294
- * token is near expiry, so the usual cost is a resolved microtask, and the
295
- * token path is a bare `async` return.
252
+ * Async because under GitHub App auth `resolveGitToken` mints an installation
253
+ * token lasting about an hour. NOTHING may cache what this returns — a URL
254
+ * built from an installation token goes stale with it — and resolving per use
255
+ * is cheap, since `@octokit/auth-app` answers from its own cache until the
256
+ * token is near expiry.
296
257
  *
297
258
  * A mint failure propagates AS THROWN, carrying the `.status` that
298
- * `isPermanentTaskFailure` (task-runner.ts:92) classifies on — see
299
- * github-auth.ts.
259
+ * `isPermanentTaskFailure` classifies on — see github-auth.ts.
300
260
  *
301
261
  * Do NOT add a parallel token accessor alongside it. Every instance-backed
302
262
  * WorkerContext member stays a function precisely so tests can replace it
@@ -307,53 +267,47 @@ export declare class CmsWorker {
307
267
  /**
308
268
  * Prove the GitHub App credential works before anything depends on it.
309
269
  *
310
- * Without this the first failure comes out of `ensureRemoteGit`'s bare
311
- * clone below, whose catch reads "the GitHub repository may be empty, or
312
- * the base branch may not exist" — which would send an operator holding a
313
- * bad private key to go looking for a repository problem that does not
314
- * exist. Called from start()'s try, so the failure is also recorded as
315
- * `lastFatalError` in worker-status.json and reaches the admin panel.
316
- *
317
- * No-op on the token path: a PAT is a literal, so there is nothing to
318
- * check that the first real request would not check anyway.
319
- *
320
- * FATAL UNLESS THE FAILURE POSITIVELY LOOKS TRANSIENT. Both halves of that
321
- * are load-bearing.
322
- *
323
- * Not always fatal, because the two credential paths must degrade alike: on
324
- * the token path a GitHub 502 during boot is absorbed (a warm `remote.git`
325
- * short-circuits `ensureRemoteGit`, and `Promise.allSettled` swallows the
326
- * initial `syncGit`), so the worker starts and its loops retry. Rethrowing
327
- * every error class would make the App path exit instead, and systemd
328
- * (Restart=always) would crash-loop it until GitHub recovered — each
329
- * iteration telling the operator to go and check their private key.
270
+ * Without this the first failure comes out of `ensureRemoteGit`'s bare clone
271
+ * below, whose catch blames the repository ("may be empty, or the base branch
272
+ * may not exist") and sends an operator holding a bad private key looking for
273
+ * a problem that does not exist. Called from start()'s try, so the failure is
274
+ * also recorded as `lastFatalError` and reaches the admin panel. No-op on the
275
+ * token path: a PAT is a literal, so the first real request checks everything
276
+ * this could.
277
+ *
278
+ * FATAL UNLESS THE FAILURE POSITIVELY LOOKS TRANSIENT. Both halves are
279
+ * load-bearing. Not always fatal, because the two credential paths must
280
+ * degrade alike: on the token path a GitHub 502 during boot is absorbed (a
281
+ * warm `remote.git` short-circuits `ensureRemoteGit`, `Promise.allSettled`
282
+ * swallows the initial `syncGit`) so the worker starts and its loops retry,
283
+ * while rethrowing every error class would make the App path exit and systemd
284
+ * crash-loop it until GitHub recovered — each iteration telling the operator
285
+ * to check their private key.
330
286
  *
331
287
  * But fail CLOSED, via `isTransientAuthFailure` rather than the inverse of
332
- * `isPermanentTaskFailure`. That classifier defaults an error with no HTTP
333
- * status to transient, which is right on the task path (bounded by
334
- * `maxRetries`) and wrong here (bounded by nothing): a key that never
335
- * reaches GitHub at all — the wrong key type, or one too mangled to sign
336
- * with — fails locally and status-lessly, so "default to transient" would
337
- * boot a worker with a dead credential, record no `lastFatalError`, and show
338
- * healthy in the admin panel while every task and every sync failed. See
339
- * isTransientAuthFailure in github-auth.ts.
288
+ * `isPermanentTaskFailure`: that classifier defaults a status-less error to
289
+ * transient, which is right on the task path (bounded by `maxRetries`) and
290
+ * wrong here (bounded by nothing). A key that never reaches GitHub at all —
291
+ * the wrong type, or too mangled to sign with — fails locally and
292
+ * status-lessly, so defaulting to transient would boot a worker with a dead
293
+ * credential, record no `lastFatalError`, and show healthy in the admin panel
294
+ * while every task and every sync failed.
340
295
  */
341
296
  private preflightGitHubAppAuth;
342
297
  /**
343
- * The workspace directory for a branch named by its GIT REF name -- the
344
- * form task payloads carry (`context.branch.name`), not the directory form.
298
+ * The workspace directory for a branch named by its GIT REF name -- the form
299
+ * task payloads carry (`context.branch.name`), not the directory form.
345
300
  *
346
301
  * These differ for any name outside `[A-Za-z0-9._-]`, `/` being the obvious
347
302
  * one: workspaces are provisioned under `sanitizeBranchName(...)` (see
348
303
  * paths/branch.ts's `resolveBranchPaths`), so `feature/x` lives in
349
- * `feature-x`. Joining the raw name instead silently addresses a directory
350
- * that does not exist -- which for the metadata writers below meant the
351
- * update was quietly dropped, and for the leased push meant the
352
- * history-rewrite marker read as absent and the push went out unleased,
353
- * wedging exactly the branch this workstream exists to unwedge.
304
+ * `feature-x`. Joining the RAW name instead silently addresses a directory
305
+ * that does not exist -- which drops the metadata writers' updates, and makes
306
+ * the leased push read the history-rewrite marker as absent and go out
307
+ * unleased, wedging the branch.
354
308
  *
355
- * `name` inside the metadata itself stays the raw ref name; only the path
356
- * is sanitized.
309
+ * `name` inside the metadata itself stays the raw ref name; only the path is
310
+ * sanitized.
357
311
  */
358
312
  private branchWorkspacePath;
359
313
  /**
@@ -362,19 +316,18 @@ export declare class CmsWorker {
362
316
  * `checkout --theirs` resolution loop overwrites them. No-op in production.
363
317
  *
364
318
  * A test subclass overrides this to land a real `ContentStore` write at
365
- * exactly the instant the rebase is mid-flight -- the window the old TOCTOU
366
- * comment above the dirty check wrongly called safe -- without any sleeps or
367
- * shell rendezvous. See the "Deterministic interleavings" testing pattern in
319
+ * exactly the instant the rebase is mid-flight, with no sleeps or shell
320
+ * rendezvous. See the "Deterministic interleavings" pattern in
368
321
  * docs/concurrency.md, and `ContentStore.afterPrePassForTesting()` for the
369
322
  * same idiom on the write side.
370
323
  */
371
324
  protected afterConflictDetectedForTesting(): Promise<void>;
372
325
  /**
373
- * Test seam, sibling of {@link afterConflictDetectedForTesting}: runs at the
326
+ * Test seam, sibling of {@link afterConflictDetectedForTesting}: runs the
374
327
  * instant a rebase round has succeeded, before the completion path (cache
375
- * invalidation, conflict metadata, [SYNC-H1] marker) executes. Exists so a
376
- * test can lose the content-write lock at exactly the point where bailing out
377
- * would strand a rewritten history.
328
+ * invalidation, conflict metadata, [SYNC-H1] marker) executes, so a test can
329
+ * lose the content-write lock at exactly the point where bailing out would
330
+ * strand a rewritten history.
378
331
  */
379
332
  protected afterRebaseCompletedForTesting(): Promise<void>;
380
333
  private rebaseActiveBranches;
@@ -384,10 +337,10 @@ export declare class CmsWorker {
384
337
  *
385
338
  * One of `refreshGitHubCredential`'s two call sites, and the one that works
386
339
  * when nobody is publishing: it fetches from GitHub every `gitSyncInterval`
387
- * (default 5 minutes) whether or not anyone is editing, so a credential that
388
- * has stopped working surfaces here even with no push queued for days.
340
+ * whether or not anyone is editing, so a credential that has stopped working
341
+ * surfaces here even with no push queued for days.
389
342
  *
390
- * The sync failure is what propagates to `scheduleLoop`'s catch.
343
+ * The SYNC failure is what propagates to `scheduleLoop`'s catch;
391
344
  * `refreshGitHubCredential` never throws, so nothing it does can replace it.
392
345
  */
393
346
  private syncGitWithCredentialRefresh;
@@ -397,42 +350,29 @@ export declare class CmsWorker {
397
350
  * **Two call sites, each covering what the other cannot.** The git-sync loop
398
351
  * (`syncGitWithCredentialRefresh`) notices a dead credential when nobody is
399
352
  * publishing. `processTaskQueue`'s per-task catch is what saves a publish: a
400
- * push task spends its retry budget on a 5s/10s/20s backoff
401
- * (task-queue/task-queue.ts), well inside one 5-minute sync interval, so with
402
- * the sync loop as the only trigger a publish that met a rotated token failed
403
- * permanently while the working one was already in the secret store.
404
- *
405
- * Every consumer reaches the credential through `ensureGitHubAuth()`, which
406
- * reads it per use — the sync fetch, `pushBranchToGitHub`,
407
- * `pushSettingsBranches`, `ensureRemoteGit`'s clone, and every Octokit call —
408
- * so a refresh from either site repairs all of them for their NEXT use, with
409
- * nothing to invalidate. It cannot rescue an attempt that has already failed,
410
- * so a task `isPermanentTaskFailure` fails fast is not saved; the task after
411
- * it is.
412
- *
413
- * NOT gated on the error looking auth-shaped, at either site. There is nothing
414
- * to classify on: a `git fetch` or `git push` rejected for a dead token throws
415
- * a plain simple-git error — exit 128, no HTTP `.status` — which
416
- * `isPermanentTaskFailure` reads as transient, so a gate keyed on it would
417
- * never fire. Two floors bound the cost instead: core's own
418
- * `refreshGitHubTokenMinIntervalMs` (default 60s, enforced by
419
- * `refreshCredential` in github-auth.ts), and whatever floor the provider
420
- * keeps — the AWS one reads at most once per five minutes and returns
421
- * `undefined` for an unchanged value (canopycms-cdk/worker/credential-refresh.ts).
422
- * On the GitHub App path the refresh is a no-op. Both call sites share both
423
- * floors, so a read issued by one throttles the other.
424
- *
425
- * **Never throws.** Both callers are already reporting a failure, and that
426
- * failure is the one that must reach the log.
427
- *
428
- * **Bounded by `taskTimeoutMs`**, because the task loop awaits it, and a read
429
- * that never settled would stop every publish queued behind it. An adopter's
430
- * provider may have no bound at all, and the AWS one, bounded as it is
431
- * (canopycms-cdk/worker/secrets.ts), can still take up to 87s for one
432
- * `getSecret` — longer than the 60s default here. A read that loses the race
433
- * is not cancelled, and
434
- * may still land later; `refreshCredential` discards a result older than one
435
- * it has already applied, so a late landing cannot put a stale token back.
353
+ * push task spends its retry budget on a 5s/10s/20s backoff, well inside one
354
+ * 5-minute sync interval, so with the sync loop as the only trigger a publish
355
+ * meeting a rotated token fails permanently while the working one is already
356
+ * in the secret store. Every consumer reaches the credential through
357
+ * `ensureGitHubAuth()`, which reads it per use, so a refresh from either site
358
+ * repairs all of them for their NEXT use — but not an attempt already failed.
359
+ *
360
+ * NOT gated on the error looking auth-shaped, at either site: a `git
361
+ * fetch`/`push` rejected for a dead token throws a plain simple-git error
362
+ * (exit 128, no HTTP `.status`) that `isPermanentTaskFailure` reads as
363
+ * transient, so a gate keyed on it would never fire. Two floors bound the
364
+ * cost instead — core's `refreshGitHubTokenMinIntervalMs` (default 60s,
365
+ * enforced by `refreshCredential` in github-auth.ts) and whatever floor the
366
+ * provider keeps (the AWS one reads at most once per five minutes) — and both
367
+ * call sites share both, so a read issued by one throttles the other. On the
368
+ * GitHub App path the refresh is a no-op.
369
+ *
370
+ * **Never throws**: both callers are already reporting the failure that must
371
+ * reach the log. **Bounded by `taskTimeoutMs`**, because the task loop awaits
372
+ * it and a read that never settled would stop every publish queued behind it
373
+ * (an adopter's provider may have no bound at all; the AWS one can take 87s
374
+ * for one `getSecret`). A losing read is not cancelled and may land later, but
375
+ * `refreshCredential` discards a result older than one already applied.
436
376
  */
437
377
  private refreshGitHubCredential;
438
378
  private pushSettingsBranches;