canopycms 0.0.68-int.98 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2131 -0
- package/README.md +47 -63
- package/dist/ai/generate.d.ts +5 -0
- package/dist/ai/generate.js +244 -115
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/json-to-markdown.d.ts +21 -1
- package/dist/ai/json-to-markdown.js +120 -57
- package/dist/ai/references.d.ts +72 -0
- package/dist/ai/references.js +223 -0
- package/dist/ai/resolve-branch.js +9 -2
- package/dist/ai/to-plain-text.d.ts +17 -8
- package/dist/ai/to-plain-text.js +18 -15
- package/dist/ai/types.d.ts +84 -3
- package/dist/api/admin-branch-health.d.ts +24 -1
- package/dist/api/admin-branch-health.js +52 -20
- package/dist/api/admin.d.ts +23 -5
- package/dist/api/admin.js +36 -1
- package/dist/api/assets.js +88 -78
- package/dist/api/branch-create-window.d.ts +12 -0
- package/dist/api/branch-create-window.js +13 -0
- package/dist/api/branch-merge.d.ts +1 -1
- package/dist/api/branch-merge.js +1 -1
- package/dist/api/branch-review.d.ts +3 -3
- package/dist/api/branch-review.js +16 -7
- package/dist/api/branch-status.d.ts +16 -6
- package/dist/api/branch-status.js +57 -12
- package/dist/api/branch-withdraw.d.ts +2 -2
- package/dist/api/branch-withdraw.js +8 -3
- package/dist/api/branch.d.ts +25 -12
- package/dist/api/branch.js +164 -103
- package/dist/api/client.d.ts +78 -58
- package/dist/api/client.js +150 -117
- package/dist/api/comments.d.ts +12 -3
- package/dist/api/comments.js +118 -9
- package/dist/api/content.d.ts +9 -9
- package/dist/api/content.js +131 -22
- package/dist/api/entries-constants.d.ts +14 -3
- package/dist/api/entries-constants.js +14 -3
- package/dist/api/entries.d.ts +40 -2
- package/dist/api/entries.js +102 -6
- package/dist/api/github-sync.d.ts +19 -0
- package/dist/api/github-sync.js +50 -3
- package/dist/api/groups.d.ts +4 -4
- package/dist/api/groups.js +2 -1
- package/dist/api/guards.js +23 -3
- package/dist/api/index.d.ts +3 -1
- package/dist/api/index.js +1 -0
- package/dist/api/permissions.d.ts +21 -2
- package/dist/api/permissions.js +50 -3
- package/dist/api/request-deadline.d.ts +59 -0
- package/dist/api/request-deadline.js +73 -0
- package/dist/api/resolve-references.js +8 -7
- package/dist/api/route-builder.d.ts +14 -0
- package/dist/api/route-builder.js +14 -1
- package/dist/api/schema.d.ts +11 -9
- package/dist/api/schema.js +2 -0
- package/dist/api/settings-helpers.d.ts +5 -1
- package/dist/api/settings-helpers.js +10 -2
- package/dist/api/types.d.ts +18 -0
- package/dist/api/users-constants.d.ts +6 -0
- package/dist/api/users-constants.js +6 -0
- package/dist/assets/asset-url.d.ts +28 -16
- package/dist/assets/asset-url.js +51 -25
- package/dist/assets/finalize.js +3 -0
- package/dist/assets/index.d.ts +1 -1
- package/dist/assets/materialize.d.ts +153 -0
- package/dist/assets/materialize.js +402 -0
- package/dist/assets/store-local.d.ts +19 -5
- package/dist/assets/store-local.js +69 -10
- package/dist/assets/store-s3.d.ts +38 -7
- package/dist/assets/store-s3.js +128 -22
- package/dist/assets/transform-directives.d.ts +52 -13
- package/dist/assets/transform-directives.js +87 -27
- package/dist/assets/transform.d.ts +3 -3
- package/dist/assets/transform.js +13 -8
- package/dist/assets/types.d.ts +31 -4
- package/dist/auth/cache.d.ts +1 -1
- package/dist/auth/cache.js +1 -1
- package/dist/auth/caching-auth-plugin.d.ts +2 -0
- package/dist/auth/caching-auth-plugin.js +12 -2
- package/dist/auth/file-based-auth-cache.d.ts +8 -0
- package/dist/auth/file-based-auth-cache.js +18 -8
- package/dist/auth/person-name.d.ts +5 -0
- package/dist/auth/person-name.js +8 -0
- package/dist/auth/plugin.d.ts +10 -1
- package/dist/auth/types.d.ts +2 -0
- package/dist/auth/user-metadata-lookup.d.ts +21 -0
- package/dist/auth/user-metadata-lookup.js +116 -0
- package/dist/authorization/branch.d.ts +1 -1
- package/dist/authorization/branch.js +12 -13
- package/dist/authorization/groups/schema.d.ts +4 -4
- package/dist/authorization/helpers.d.ts +8 -0
- package/dist/authorization/helpers.js +8 -0
- package/dist/authorization/index.d.ts +1 -1
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/protected-branch.d.ts +5 -4
- package/dist/authorization/protected-branch.js +7 -5
- package/dist/branch-health.d.ts +35 -8
- package/dist/branch-health.js +54 -18
- package/dist/branch-metadata-error.d.ts +27 -0
- package/dist/branch-metadata-error.js +23 -0
- package/dist/branch-metadata-file.d.ts +205 -24
- package/dist/branch-metadata-file.js +126 -25
- package/dist/branch-metadata.d.ts +45 -6
- package/dist/branch-metadata.js +142 -50
- package/dist/branch-provisioning.d.ts +167 -0
- package/dist/branch-provisioning.js +501 -0
- package/dist/branch-registry.d.ts +8 -0
- package/dist/branch-registry.js +61 -9
- package/dist/branch-schema-cache.d.ts +29 -12
- package/dist/branch-schema-cache.js +64 -21
- package/dist/branch-sparse.d.ts +23 -0
- package/dist/branch-sparse.js +118 -0
- package/dist/branch-workspace.d.ts +42 -3
- package/dist/branch-workspace.js +239 -100
- package/dist/build/asset-refs.d.ts +94 -0
- package/dist/build/asset-refs.js +267 -0
- package/dist/build/generate-ai-content.js +5 -0
- package/dist/build/inline-flight.d.ts +37 -0
- package/dist/build/inline-flight.js +142 -0
- package/dist/cli/asset-refs.d.ts +52 -0
- package/dist/cli/asset-refs.js +194 -0
- package/dist/cli/cli.d.ts +15 -1
- package/dist/cli/cli.js +8543 -3193
- package/dist/cli/configured-asset-store.d.ts +12 -0
- package/dist/cli/configured-asset-store.js +46 -0
- package/dist/cli/generate-ai-content.js +4244 -1072
- package/dist/cli/init.js +217 -126
- package/dist/cli/project-detect.d.ts +2 -0
- package/dist/cli/project-detect.js +2 -0
- package/dist/cli/template-files/Dockerfile.cms.template +13 -5
- package/dist/cli/template-files/cms-stack.ts.template +16 -13
- package/dist/client.d.ts +1 -2
- package/dist/client.js +1 -2
- package/dist/comment-store.d.ts +25 -0
- package/dist/comment-store.js +43 -8
- package/dist/config/flatten.js +2 -0
- package/dist/config/helpers.js +2 -2
- package/dist/config/index.d.ts +1 -1
- package/dist/config/schemas/config.d.ts +12 -29
- package/dist/config/schemas/config.js +9 -12
- package/dist/config/schemas/field.d.ts +3 -0
- package/dist/config/schemas/field.js +58 -4
- package/dist/config/schemas/media.d.ts +4 -13
- package/dist/config/schemas/media.js +5 -8
- package/dist/config/schemas/url.d.ts +2 -20
- package/dist/config/schemas/url.js +2 -25
- package/dist/config/types.d.ts +116 -22
- package/dist/config/types.js +3 -9
- package/dist/config/validation.d.ts +25 -4
- package/dist/config/validation.js +116 -3
- package/dist/content-id-index.js +2 -2
- package/dist/content-index-generation.d.ts +1 -1
- package/dist/content-index-generation.js +1 -1
- package/dist/content-listing.d.ts +10 -1
- package/dist/content-listing.js +22 -5
- package/dist/content-reader.d.ts +9 -0
- package/dist/content-reader.js +16 -11
- package/dist/content-store.d.ts +75 -12
- package/dist/content-store.js +249 -86
- package/dist/content-tree.js +2 -2
- package/dist/context.js +5 -2
- package/dist/dangling-reference-log.d.ts +17 -0
- package/dist/dangling-reference-log.js +29 -0
- package/dist/dev-content-watcher.d.ts +1 -1
- package/dist/dev-content-watcher.js +1 -1
- package/dist/editor/BranchManager.d.ts +23 -7
- package/dist/editor/BranchManager.js +119 -54
- package/dist/editor/CanopyEditor.d.ts +1 -1
- package/dist/editor/CanopyEditor.js +1 -2
- package/dist/editor/CommentsPanel.d.ts +14 -0
- package/dist/editor/CommentsPanel.js +68 -43
- package/dist/editor/Editor.d.ts +11 -5
- package/dist/editor/Editor.js +891 -218
- package/dist/editor/EditorAuthGate.d.ts +7 -1
- package/dist/editor/EditorAuthGate.js +41 -9
- package/dist/editor/EntryNavigator.d.ts +22 -0
- package/dist/editor/EntryNavigator.js +353 -105
- package/dist/editor/FormHeader.d.ts +25 -0
- package/dist/editor/FormHeader.js +82 -0
- package/dist/editor/FormRenderer.d.ts +27 -3
- package/dist/editor/FormRenderer.js +171 -76
- package/dist/editor/PreviewFrame.d.ts +40 -0
- package/dist/editor/PreviewFrame.js +215 -0
- package/dist/editor/PreviewPane.d.ts +47 -0
- package/dist/editor/PreviewPane.js +147 -0
- package/dist/editor/PreviewToolbarTools.d.ts +22 -0
- package/dist/editor/PreviewToolbarTools.js +73 -0
- package/dist/editor/admin/SystemHealthPanel.d.ts +2 -1
- package/dist/editor/admin/SystemHealthPanel.js +163 -33
- package/dist/editor/admin/useSystemHealth.d.ts +18 -0
- package/dist/editor/admin/useSystemHealth.js +70 -1
- package/dist/editor/branch-status.d.ts +17 -0
- package/dist/editor/branch-status.js +29 -0
- package/dist/editor/canopy-path.d.ts +9 -6
- package/dist/editor/canopy-path.js +8 -11
- package/dist/editor/client-reference-resolver.d.ts +43 -16
- package/dist/editor/client-reference-resolver.js +155 -64
- package/dist/editor/comments/BranchComments.d.ts +1 -1
- package/dist/editor/comments/BranchComments.js +2 -2
- package/dist/editor/comments/CloseRefusedNotice.d.ts +4 -0
- package/dist/editor/comments/CloseRefusedNotice.js +7 -0
- package/dist/editor/comments/CommentThreadsPopover.d.ts +47 -0
- package/dist/editor/comments/CommentThreadsPopover.js +274 -0
- package/dist/editor/comments/CommentWriteAlert.d.ts +11 -0
- package/dist/editor/comments/CommentWriteAlert.js +13 -0
- package/dist/editor/comments/EntryComments.d.ts +10 -4
- package/dist/editor/comments/EntryComments.js +14 -17
- package/dist/editor/comments/FieldWrapper.d.ts +18 -4
- package/dist/editor/comments/FieldWrapper.js +62 -28
- package/dist/editor/comments/InlineCommentThread.d.ts +9 -2
- package/dist/editor/comments/InlineCommentThread.js +11 -47
- package/dist/editor/comments/ThreadCarousel.d.ts +1 -1
- package/dist/editor/comments/ThreadCarousel.js +18 -21
- package/dist/editor/comments/ThreadReplyControls.d.ts +28 -0
- package/dist/editor/comments/ThreadReplyControls.js +92 -0
- package/dist/editor/comments/field-comment-context.d.ts +14 -0
- package/dist/editor/comments/field-comment-context.js +14 -0
- package/dist/editor/comments/form-comments.d.ts +48 -0
- package/dist/editor/comments/form-comments.js +178 -0
- package/dist/editor/comments/item-anchor-copy.d.ts +6 -0
- package/dist/editor/comments/item-anchor-copy.js +6 -0
- package/dist/editor/comments/move-focus-if-unmoved.d.ts +6 -0
- package/dist/editor/comments/move-focus-if-unmoved.js +11 -0
- package/dist/editor/comments/popover-placement.d.ts +18 -0
- package/dist/editor/comments/popover-placement.js +58 -0
- package/dist/editor/comments/use-tracked-writes.d.ts +16 -0
- package/dist/editor/comments/use-tracked-writes.js +53 -0
- package/dist/editor/components/BranchAccessList.d.ts +15 -0
- package/dist/editor/components/BranchAccessList.js +52 -0
- package/dist/editor/components/BranchLockBanner.d.ts +22 -0
- package/dist/editor/components/BranchLockBanner.js +39 -0
- package/dist/editor/components/BranchPill.d.ts +32 -0
- package/dist/editor/components/BranchPill.js +33 -0
- package/dist/editor/components/BranchesDrawer.d.ts +11 -0
- package/dist/editor/components/BranchesDrawer.js +5 -0
- package/dist/editor/components/ConfirmDeleteModal.d.ts +6 -1
- package/dist/editor/components/ConfirmDeleteModal.js +3 -2
- package/dist/editor/components/DestructiveMenuItem.d.ts +7 -0
- package/dist/editor/components/DestructiveMenuItem.js +8 -0
- package/dist/editor/components/EditorCrashScreen.d.ts +17 -0
- package/dist/editor/components/EditorCrashScreen.js +22 -0
- package/dist/editor/components/EditorErrorBoundary.d.ts +38 -0
- package/dist/editor/components/EditorErrorBoundary.js +40 -0
- package/dist/editor/components/EditorHeader.d.ts +56 -106
- package/dist/editor/components/EditorHeader.js +130 -131
- package/dist/editor/components/EditorRail.d.ts +49 -0
- package/dist/editor/components/EditorRail.js +65 -0
- package/dist/editor/components/EntryBreadcrumb.d.ts +33 -0
- package/dist/editor/components/EntryBreadcrumb.js +56 -0
- package/dist/editor/components/EntryCreateModal.d.ts +12 -7
- package/dist/editor/components/EntryCreateModal.js +51 -57
- package/dist/editor/components/NoEditPermissionNotice.d.ts +6 -5
- package/dist/editor/components/NoEditPermissionNotice.js +5 -4
- package/dist/editor/components/QuickOpenPalette.d.ts +22 -0
- package/dist/editor/components/QuickOpenPalette.js +66 -0
- package/dist/editor/components/ReadOnlyDraftNotice.d.ts +11 -0
- package/dist/editor/components/ReadOnlyDraftNotice.js +12 -0
- package/dist/editor/components/ReasonedMenuItem.d.ts +15 -0
- package/dist/editor/components/ReasonedMenuItem.js +15 -0
- package/dist/editor/components/ReferencedByList.d.ts +11 -0
- package/dist/editor/components/ReferencedByList.js +28 -0
- package/dist/editor/components/RelativeTime.d.ts +10 -0
- package/dist/editor/components/RelativeTime.js +10 -0
- package/dist/editor/components/RenameEntryModal.d.ts +9 -1
- package/dist/editor/components/RenameEntryModal.js +19 -31
- package/dist/editor/components/RetryToastMessage.d.ts +9 -0
- package/dist/editor/components/RetryToastMessage.js +6 -0
- package/dist/editor/components/SaveAllResult.d.ts +25 -0
- package/dist/editor/components/SaveAllResult.js +86 -0
- package/dist/editor/components/SaveSplitButton.d.ts +30 -0
- package/dist/editor/components/SaveSplitButton.js +108 -0
- package/dist/editor/components/StagedChangesDrawer.d.ts +39 -0
- package/dist/editor/components/StagedChangesDrawer.js +92 -0
- package/dist/editor/components/UnavailableEntryNotice.d.ts +6 -0
- package/dist/editor/components/UnavailableEntryNotice.js +9 -0
- package/dist/editor/components/UnavailableTypeMessage.d.ts +6 -0
- package/dist/editor/components/UnavailableTypeMessage.js +9 -0
- package/dist/editor/components/UndoToastMessage.d.ts +18 -0
- package/dist/editor/components/UndoToastMessage.js +10 -0
- package/dist/editor/components/UserBadge.d.ts +2 -5
- package/dist/editor/components/UserBadge.js +62 -33
- package/dist/editor/components/ValidationSummary.d.ts +14 -0
- package/dist/editor/components/ValidationSummary.js +24 -0
- package/dist/editor/components/index.d.ts +2 -2
- package/dist/editor/components/index.js +2 -2
- package/dist/editor/context/ApiClientContext.d.ts +8 -2
- package/dist/editor/context/ApiClientContext.js +19 -8
- package/dist/editor/context/AssetContext.d.ts +13 -35
- package/dist/editor/context/AssetContext.js +12 -31
- package/dist/editor/context/EditorStateContext.d.ts +4 -4
- package/dist/editor/context/EditorStateContext.js +4 -4
- package/dist/editor/context/SWRProvider.d.ts +3 -3
- package/dist/editor/context/SiteMdxAllowContext.d.ts +4 -0
- package/dist/editor/context/SiteMdxAllowContext.js +7 -0
- package/dist/editor/context/index.d.ts +2 -1
- package/dist/editor/context/index.js +2 -1
- package/dist/editor/contrast.d.ts +19 -0
- package/dist/editor/contrast.js +41 -0
- package/dist/editor/copy.d.ts +18 -0
- package/dist/editor/copy.js +18 -0
- package/dist/editor/editor-config.js +16 -0
- package/dist/editor/editor-utils.d.ts +34 -8
- package/dist/editor/editor-utils.js +42 -20
- package/dist/editor/entry-search.d.ts +20 -0
- package/dist/editor/entry-search.js +34 -0
- package/dist/editor/field-breadcrumb.d.ts +12 -0
- package/dist/editor/field-breadcrumb.js +85 -0
- package/dist/editor/field-props.d.ts +86 -0
- package/dist/editor/field-props.js +27 -0
- package/dist/editor/field-target.d.ts +30 -0
- package/dist/editor/field-target.js +77 -0
- package/dist/editor/fields/BlockField.d.ts +12 -0
- package/dist/editor/fields/BlockField.js +89 -73
- package/dist/editor/fields/CodeField.d.ts +2 -0
- package/dist/editor/fields/CodeField.js +6 -2
- package/dist/editor/fields/DateTimeField.d.ts +4 -29
- package/dist/editor/fields/DateTimeField.js +79 -41
- package/dist/editor/fields/ExpandAllButton.d.ts +6 -0
- package/dist/editor/fields/ExpandAllButton.js +4 -0
- package/dist/editor/fields/FieldCrashFallback.d.ts +17 -0
- package/dist/editor/fields/FieldCrashFallback.js +30 -0
- package/dist/editor/fields/FieldLabel.d.ts +37 -0
- package/dist/editor/fields/FieldLabel.js +19 -0
- package/dist/editor/fields/ImageField.d.ts +4 -0
- package/dist/editor/fields/ImageField.js +29 -14
- package/dist/editor/fields/InlineGroupField.js +4 -3
- package/dist/editor/fields/ItemList.d.ts +42 -0
- package/dist/editor/fields/ItemList.js +130 -0
- package/dist/editor/fields/MarkdownField.d.ts +32 -0
- package/dist/editor/fields/MarkdownField.js +223 -46
- package/dist/editor/fields/MdxImageDialog.js +1 -1
- package/dist/editor/fields/NumberField.d.ts +2 -0
- package/dist/editor/fields/NumberField.js +8 -5
- package/dist/editor/fields/NumberListField.d.ts +2 -0
- package/dist/editor/fields/NumberListField.js +19 -16
- package/dist/editor/fields/ObjectField.d.ts +2 -7
- package/dist/editor/fields/ObjectField.js +15 -5
- package/dist/editor/fields/ObjectListField.d.ts +29 -0
- package/dist/editor/fields/ObjectListField.js +57 -0
- package/dist/editor/fields/ReferenceField.d.ts +2 -0
- package/dist/editor/fields/ReferenceField.js +34 -9
- package/dist/editor/fields/SelectField.d.ts +2 -0
- package/dist/editor/fields/SelectField.js +11 -2
- package/dist/editor/fields/StringListField.d.ts +4 -1
- package/dist/editor/fields/StringListField.js +22 -8
- package/dist/editor/fields/TextField.d.ts +2 -0
- package/dist/editor/fields/TextField.js +6 -2
- package/dist/editor/fields/ToggleField.d.ts +2 -0
- package/dist/editor/fields/ToggleField.js +8 -3
- package/dist/editor/fields/entry-link/InsertEntryLink.d.ts +1 -1
- package/dist/editor/fields/entry-link/InsertEntryLink.js +1 -1
- package/dist/editor/fields/form-expansion.d.ts +9 -0
- package/dist/editor/fields/form-expansion.js +2 -0
- package/dist/editor/fields/item-expansion.d.ts +15 -0
- package/dist/editor/fields/item-expansion.js +60 -0
- package/dist/editor/fields/list-item-keys.d.ts +8 -0
- package/dist/editor/fields/list-item-keys.js +50 -0
- package/dist/editor/fields/list-item-title.d.ts +20 -0
- package/dist/editor/fields/list-item-title.js +85 -0
- package/dist/editor/fields/markdown-export-options.d.ts +2 -0
- package/dist/editor/fields/markdown-export-options.js +8 -0
- package/dist/editor/fields/markdown-fidelity-visitors.d.ts +11 -0
- package/dist/editor/fields/markdown-fidelity-visitors.js +160 -0
- package/dist/editor/fields/mdx-jsx-support.d.ts +5 -1
- package/dist/editor/fields/mdx-jsx-support.js +157 -69
- package/dist/editor/fields/rich-text-failures.d.ts +5 -0
- package/dist/editor/fields/rich-text-failures.js +26 -0
- package/dist/editor/fields/toolbar-wrap.d.ts +7 -0
- package/dist/editor/fields/toolbar-wrap.js +35 -0
- package/dist/editor/form-outline.d.ts +13 -0
- package/dist/editor/form-outline.js +70 -0
- package/dist/editor/group-manager/GroupCard.d.ts +4 -1
- package/dist/editor/group-manager/GroupCard.js +12 -3
- package/dist/editor/group-manager/GroupForm.js +1 -1
- package/dist/editor/group-manager/InternalGroupsTab.d.ts +2 -1
- package/dist/editor/group-manager/InternalGroupsTab.js +4 -4
- package/dist/editor/group-manager/MemberList.d.ts +2 -1
- package/dist/editor/group-manager/MemberList.js +15 -4
- package/dist/editor/group-manager/hooks/useGroupState.d.ts +5 -0
- package/dist/editor/group-manager/hooks/useGroupState.js +30 -7
- package/dist/editor/group-manager/index.js +34 -5
- package/dist/editor/group-manager/types.d.ts +5 -2
- package/dist/editor/hooks/create-branch-request.d.ts +20 -0
- package/dist/editor/hooks/create-branch-request.js +54 -0
- package/dist/editor/hooks/save-all.d.ts +68 -0
- package/dist/editor/hooks/save-all.js +61 -0
- package/dist/editor/hooks/useBranchActions.d.ts +11 -1
- package/dist/editor/hooks/useBranchActions.js +42 -19
- package/dist/editor/hooks/useBranchManager.d.ts +21 -0
- package/dist/editor/hooks/useBranchManager.js +321 -125
- package/dist/editor/hooks/useBranchesData.d.ts +8 -4
- package/dist/editor/hooks/useBranchesData.js +9 -5
- package/dist/editor/hooks/useCommentSystem.d.ts +14 -2
- package/dist/editor/hooks/useCommentSystem.js +79 -55
- package/dist/editor/hooks/useCommentsData.d.ts +11 -7
- package/dist/editor/hooks/useCommentsData.js +20 -19
- package/dist/editor/hooks/useDraftManager.d.ts +77 -3
- package/dist/editor/hooks/useDraftManager.js +887 -94
- package/dist/editor/hooks/useEditorLayout.d.ts +53 -7
- package/dist/editor/hooks/useEditorLayout.js +98 -20
- package/dist/editor/hooks/useEntriesData.d.ts +2 -1
- package/dist/editor/hooks/useEntriesData.js +18 -4
- package/dist/editor/hooks/useEntryManager.d.ts +41 -2
- package/dist/editor/hooks/useEntryManager.js +227 -41
- package/dist/editor/hooks/useGroupManager.js +13 -16
- package/dist/editor/hooks/usePermissionManager.js +14 -6
- package/dist/editor/hooks/usePreviewMarks.d.ts +21 -0
- package/dist/editor/hooks/usePreviewMarks.js +33 -0
- package/dist/editor/hooks/useReferenceResolution.d.ts +10 -3
- package/dist/editor/hooks/useReferenceResolution.js +34 -177
- package/dist/editor/hooks/useSchemaManager.d.ts +25 -6
- package/dist/editor/hooks/useSchemaManager.js +97 -39
- package/dist/editor/hooks/useUserMetadata.d.ts +14 -4
- package/dist/editor/hooks/useUserMetadata.js +76 -47
- package/dist/editor/hooks/user-metadata-batcher.d.ts +8 -0
- package/dist/editor/hooks/user-metadata-batcher.js +33 -0
- package/dist/editor/media/AssetCard.d.ts +6 -7
- package/dist/editor/media/AssetCard.js +24 -31
- package/dist/editor/media/AssetListRow.d.ts +16 -0
- package/dist/editor/media/AssetListRow.js +41 -0
- package/dist/editor/media/CropStep.js +6 -1
- package/dist/editor/media/MediaLibrary.d.ts +4 -3
- package/dist/editor/media/MediaLibrary.js +11 -4
- package/dist/editor/media/MediaLibraryBody.d.ts +3 -3
- package/dist/editor/media/MediaLibraryBody.js +195 -80
- package/dist/editor/media/MediaLibrarySkeleton.d.ts +6 -0
- package/dist/editor/media/MediaLibrarySkeleton.js +14 -0
- package/dist/editor/media/crop-math.d.ts +3 -4
- package/dist/editor/media/crop-math.js +11 -22
- package/dist/editor/media/editor-image-src.d.ts +8 -0
- package/dist/editor/media/editor-image-src.js +10 -0
- package/dist/editor/media/format-bytes.d.ts +2 -0
- package/dist/editor/media/format-bytes.js +23 -0
- package/dist/editor/media/media-library-prefs.d.ts +23 -0
- package/dist/editor/media/media-library-prefs.js +49 -0
- package/dist/editor/media/media-library-view.d.ts +34 -0
- package/dist/editor/media/media-library-view.js +40 -0
- package/dist/editor/media/useAssetLibrary.d.ts +30 -0
- package/dist/editor/media/useAssetLibrary.js +126 -0
- package/dist/editor/media/useStableAssetOrder.d.ts +11 -0
- package/dist/editor/media/useStableAssetOrder.js +37 -0
- package/dist/editor/media/useThumbnailFailure.d.ts +6 -0
- package/dist/editor/media/useThumbnailFailure.js +16 -0
- package/dist/editor/permission-manager/GroupSelector.js +2 -2
- package/dist/editor/permission-manager/PermissionEditor.d.ts +1 -1
- package/dist/editor/permission-manager/PermissionEditor.js +15 -4
- package/dist/editor/permission-manager/PermissionLevelBadge.js +1 -1
- package/dist/editor/permission-manager/PermissionTree.d.ts +1 -1
- package/dist/editor/permission-manager/UserSelector.d.ts +1 -1
- package/dist/editor/permission-manager/UserSelector.js +3 -3
- package/dist/editor/permission-manager/index.js +12 -3
- package/dist/editor/permission-manager/types.d.ts +5 -2
- package/dist/editor/platform.d.ts +3 -0
- package/dist/editor/platform.js +9 -0
- package/dist/editor/preview-asset-base.d.ts +9 -0
- package/dist/editor/preview-asset-base.js +17 -0
- package/dist/editor/preview-bridge.d.ts +51 -27
- package/dist/editor/preview-bridge.js +103 -144
- package/dist/editor/preview-marks.d.ts +15 -0
- package/dist/editor/preview-marks.js +74 -0
- package/dist/editor/preview-path.d.ts +12 -0
- package/dist/editor/preview-path.js +45 -1
- package/dist/editor/preview-scale.d.ts +27 -0
- package/dist/editor/preview-scale.js +34 -0
- package/dist/editor/raw-asset-base.d.ts +5 -0
- package/dist/editor/raw-asset-base.js +14 -0
- package/dist/editor/relative-time.d.ts +4 -4
- package/dist/editor/relative-time.js +16 -8
- package/dist/editor/schema-editor/CollectionEditor.d.ts +20 -3
- package/dist/editor/schema-editor/CollectionEditor.js +361 -62
- package/dist/editor/schema-editor/EntryTypeEditor.d.ts +5 -1
- package/dist/editor/schema-editor/EntryTypeEditor.js +11 -6
- package/dist/editor/schema-editor/collection-draft.d.ts +22 -0
- package/dist/editor/schema-editor/collection-draft.js +40 -0
- package/dist/editor/schema-editor/index.d.ts +1 -1
- package/dist/editor/schema-label.d.ts +10 -0
- package/dist/editor/schema-label.js +17 -0
- package/dist/editor/settings-conflict.d.ts +5 -0
- package/dist/editor/settings-conflict.js +8 -0
- package/dist/editor/shell/ActivityRail.d.ts +37 -0
- package/dist/editor/shell/ActivityRail.js +91 -0
- package/dist/editor/shell/EditorShell.d.ts +17 -0
- package/dist/editor/shell/EditorShell.js +31 -0
- package/dist/editor/shell/PaneLayout.d.ts +28 -0
- package/dist/editor/shell/PaneLayout.js +116 -0
- package/dist/editor/shell/SidePanelHost.d.ts +35 -0
- package/dist/editor/shell/SidePanelHost.js +184 -0
- package/dist/editor/shell/TopBar.d.ts +12 -0
- package/dist/editor/shell/TopBar.js +14 -0
- package/dist/editor/shell/host-chrome.d.ts +16 -0
- package/dist/editor/shell/host-chrome.js +69 -0
- package/dist/editor/slug.d.ts +16 -0
- package/dist/editor/slug.js +43 -0
- package/dist/editor/theme.d.ts +2 -1
- package/dist/editor/theme.js +314 -13
- package/dist/editor/unanswered.d.ts +17 -0
- package/dist/editor/unanswered.js +26 -0
- package/dist/editor/unavailable-entry-type.d.ts +20 -0
- package/dist/editor/unavailable-entry-type.js +28 -0
- package/dist/editor/undo-removal.d.ts +57 -0
- package/dist/editor/undo-removal.js +163 -0
- package/dist/editor/user-display.d.ts +4 -0
- package/dist/editor/user-display.js +5 -0
- package/dist/editor/utils/confirm-modal.d.ts +8 -0
- package/dist/editor/utils/confirm-modal.js +12 -0
- package/dist/editor/utils/editor-errors.d.ts +19 -0
- package/dist/editor/utils/editor-errors.js +32 -0
- package/dist/editor/utils/focus-return.d.ts +56 -0
- package/dist/editor/utils/focus-return.js +106 -0
- package/dist/entry-link-resolver.d.ts +11 -1
- package/dist/entry-link-resolver.js +65 -5
- package/dist/entry-schema-registry.d.ts +3 -3
- package/dist/entry-schema-registry.js +7 -4
- package/dist/entry-schema.d.ts +49 -3
- package/dist/entry-schema.js +18 -0
- package/dist/git-manager.d.ts +172 -10
- package/dist/git-manager.js +449 -107
- package/dist/github-service.d.ts +39 -2
- package/dist/github-service.js +101 -7
- package/dist/http/handler.js +74 -9
- package/dist/http/types.d.ts +2 -0
- package/dist/http/worker-not-ready.d.ts +9 -4
- package/dist/http/worker-not-ready.js +59 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/item-keys.d.ts +46 -0
- package/dist/item-keys.js +235 -0
- package/dist/operating-mode/editor-mode-check.d.ts +15 -0
- package/dist/operating-mode/editor-mode-check.js +24 -0
- package/dist/operating-mode/mode-env.d.ts +13 -14
- package/dist/operating-mode/mode-env.js +13 -14
- package/dist/operating-mode/types.d.ts +2 -2
- package/dist/paths/branch.d.ts +0 -1
- package/dist/paths/branch.js +1 -8
- package/dist/paths/index.d.ts +1 -1
- package/dist/paths/index.js +1 -1
- package/dist/paths/validation.js +0 -2
- package/dist/preview.d.ts +8 -0
- package/dist/preview.js +7 -0
- package/dist/reference-resolver.js +1 -0
- package/dist/resolve-canopy-user.d.ts +1 -1
- package/dist/resolve-canopy-user.js +1 -1
- package/dist/schema/meta-loader.d.ts +18 -8
- package/dist/schema/meta-loader.js +42 -9
- package/dist/schema/registry-fingerprint.d.ts +14 -0
- package/dist/schema/registry-fingerprint.js +63 -0
- package/dist/schema/resolver.d.ts +7 -4
- package/dist/schema/resolver.js +7 -6
- package/dist/schema/schema-store.d.ts +7 -10
- package/dist/schema/schema-store.js +13 -11
- package/dist/schema/schema-unavailable-error.d.ts +11 -0
- package/dist/schema/schema-unavailable-error.js +15 -0
- package/dist/schema/types.d.ts +22 -0
- package/dist/schema-registry-record.d.ts +35 -0
- package/dist/schema-registry-record.js +134 -0
- package/dist/server.d.ts +79 -9
- package/dist/server.js +62 -8
- package/dist/services.d.ts +33 -5
- package/dist/services.js +155 -37
- package/dist/settings-workspace.d.ts +23 -3
- package/dist/settings-workspace.js +159 -45
- package/dist/stamp-on-publish.d.ts +36 -0
- package/dist/stamp-on-publish.js +71 -0
- package/dist/static/index.d.ts +58 -5
- package/dist/static/index.js +133 -3
- package/dist/static/seo.d.ts +5 -5
- package/dist/static/seo.js +5 -5
- package/dist/submission-attribution.d.ts +8 -0
- package/dist/submission-attribution.js +22 -0
- package/dist/system-users.d.ts +12 -0
- package/dist/system-users.js +12 -0
- package/dist/task-queue/cms-task-queue.d.ts +1 -1
- package/dist/task-queue/cms-task-queue.js +1 -1
- package/dist/task-queue/index.d.ts +1 -1
- package/dist/task-queue/index.js +1 -1
- package/dist/task-queue/task-queue.d.ts +6 -0
- package/dist/task-queue/task-queue.js +29 -0
- package/dist/task-queue/worker-status.d.ts +35 -9
- package/dist/task-queue/worker-status.js +84 -17
- package/dist/types.d.ts +90 -9
- package/dist/url-collision.js +3 -3
- package/dist/url-exclusivity-fixtures.d.ts +8 -1
- package/dist/url-exclusivity-fixtures.js +11 -1
- package/dist/user.js +2 -1
- package/dist/utils/atomic-write.js +2 -1
- package/dist/utils/base-branch.d.ts +13 -0
- package/dist/utils/base-branch.js +23 -0
- package/dist/utils/content-serialize.d.ts +15 -7
- package/dist/utils/content-serialize.js +353 -51
- package/dist/utils/content-write-lock.d.ts +6 -1
- package/dist/utils/content-write-lock.js +21 -6
- package/dist/utils/debug.d.ts +1 -1
- package/dist/utils/debug.js +5 -3
- package/dist/utils/error.js +13 -2
- package/dist/utils/escape-text.d.ts +7 -0
- package/dist/utils/escape-text.js +27 -0
- package/dist/utils/fs.d.ts +12 -4
- package/dist/utils/fs.js +18 -5
- package/dist/utils/git.d.ts +21 -1
- package/dist/utils/git.js +63 -8
- package/dist/utils/json-source-splice.d.ts +14 -0
- package/dist/utils/json-source-splice.js +120 -0
- package/dist/utils/markdown-body-splice.d.ts +39 -0
- package/dist/utils/markdown-body-splice.js +421 -0
- package/dist/utils/occ-json-write.js +18 -12
- package/dist/utils/provision-log.d.ts +25 -0
- package/dist/utils/provision-log.js +49 -0
- package/dist/utils/provisioning-lock.d.ts +32 -1
- package/dist/utils/provisioning-lock.js +78 -32
- package/dist/utils/sanitize-href.d.ts +9 -23
- package/dist/utils/sanitize-href.js +14 -28
- package/dist/utils/title-field.d.ts +10 -0
- package/dist/utils/title-field.js +47 -0
- package/dist/utils/yaml-source-splice.d.ts +58 -0
- package/dist/utils/yaml-source-splice.js +515 -0
- package/dist/validation/block-structural-keys.d.ts +1 -1
- package/dist/validation/block-structural-keys.js +1 -1
- package/dist/validation/deletion-checker.d.ts +21 -29
- package/dist/validation/deletion-checker.js +41 -117
- package/dist/validation/entry-validator.d.ts +6 -10
- package/dist/validation/entry-validator.js +19 -26
- package/dist/validation/field-traversal.d.ts +22 -0
- package/dist/validation/field-traversal.js +39 -8
- package/dist/validation/markdown-safety.d.ts +68 -0
- package/dist/validation/markdown-safety.js +596 -0
- package/dist/validation/mdx-allowlist.d.ts +55 -0
- package/dist/validation/mdx-allowlist.js +183 -0
- package/dist/validation/reference-validator.d.ts +2 -0
- package/dist/validation/reference-validator.js +3 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/branch-policy.d.ts +124 -0
- package/dist/worker/branch-policy.js +243 -0
- package/dist/worker/bundle-header.d.ts +117 -0
- package/dist/worker/bundle-header.js +253 -0
- package/dist/worker/cms-worker.d.ts +236 -142
- package/dist/worker/cms-worker.js +772 -285
- package/dist/worker/gateway-egress.d.ts +43 -0
- package/dist/worker/gateway-egress.js +209 -0
- package/dist/worker/gateway-instance.d.ts +42 -0
- package/dist/worker/gateway-instance.js +129 -0
- package/dist/worker/git-process.d.ts +81 -0
- package/dist/worker/git-process.js +234 -0
- package/dist/worker/git-sync.d.ts +34 -17
- package/dist/worker/git-sync.js +394 -131
- package/dist/worker/github-auth.d.ts +9 -9
- package/dist/worker/github-auth.js +13 -15
- package/dist/worker/github-gateway-http.d.ts +62 -0
- package/dist/worker/github-gateway-http.js +977 -0
- package/dist/worker/github-gateway-wire.d.ts +590 -0
- package/dist/worker/github-gateway-wire.js +488 -0
- package/dist/worker/github-gateway.d.ts +238 -0
- package/dist/worker/github-gateway.js +726 -0
- package/dist/worker/github-mirror-upkeep.d.ts +75 -0
- package/dist/worker/github-mirror-upkeep.js +266 -0
- package/dist/worker/github-mirror.d.ts +364 -0
- package/dist/worker/github-mirror.js +1030 -0
- package/dist/worker/github-transfer.d.ts +56 -0
- package/dist/worker/github-transfer.js +444 -0
- package/dist/worker/history-rewrite.d.ts +4 -5
- package/dist/worker/history-rewrite.js +12 -17
- package/dist/worker/provisioned-workspace.d.ts +5 -5
- package/dist/worker/provisioned-workspace.js +5 -5
- package/dist/worker/rebase.d.ts +1 -1
- package/dist/worker/rebase.js +58 -54
- package/dist/worker/remote-git-maintenance.d.ts +3 -0
- package/dist/worker/remote-git-maintenance.js +12 -0
- package/dist/worker/schema-gate.d.ts +49 -0
- package/dist/worker/schema-gate.js +226 -0
- package/dist/worker/self-checks.d.ts +107 -0
- package/dist/worker/self-checks.js +358 -0
- package/dist/worker/shared-repo-git.d.ts +96 -0
- package/dist/worker/shared-repo-git.js +459 -0
- package/dist/worker/sparse-cone.d.ts +20 -0
- package/dist/worker/sparse-cone.js +136 -0
- package/dist/worker/stale-mirror.d.ts +82 -0
- package/dist/worker/stale-mirror.js +130 -0
- package/dist/worker/task-runner.d.ts +5 -3
- package/dist/worker/task-runner.js +287 -186
- package/dist/worker/worker-context.d.ts +36 -37
- package/package.json +35 -7
- package/dist/editor/EditorPanes.d.ts +0 -10
- package/dist/editor/EditorPanes.js +0 -98
- package/dist/editor/components/EditorFooter.d.ts +0 -11
- package/dist/editor/components/EditorFooter.js +0 -9
- package/dist/editor/components/EditorSidebar.d.ts +0 -67
- package/dist/editor/components/EditorSidebar.js +0 -22
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
2
|
+
import { type SimpleGit } from 'simple-git';
|
|
3
|
+
import { type BundleHeader } from './bundle-header.js';
|
|
4
|
+
import { BranchPolicy, GatewayRefusalError } from './branch-policy.js';
|
|
5
|
+
/**
|
|
6
|
+
* The worker's private bare mirror of the GitHub repository, in a state directory the CMS Lambda
|
|
7
|
+
* cannot reach. It and the quarantines beside it are the only repositories in which git ever runs
|
|
8
|
+
* with the GitHub credential, and the state directory the only place the GitHub gateway runs git
|
|
9
|
+
* at all. Every gateway git names a repository inside it, by `GIT_DIR` and working directory
|
|
10
|
+
* alike, so no config or hook the Lambda writes is ever read by it; Lambda-written objects reach
|
|
11
|
+
* it only inside a pushed bundle, checked in a quarantine. The credential reaches git only as a
|
|
12
|
+
* per-command config file ({@link withCredentialConfig}).
|
|
13
|
+
*
|
|
14
|
+
* Objects cross the boundary as git bundles, never by a fetch or push against `remote.git`:
|
|
15
|
+
* - **out:** a fetch bundles what the caller's `have` lacks into `outgoing/`, one pending bundle
|
|
16
|
+
* at a time ({@link GitHubMirror.openBundle});
|
|
17
|
+
* - **in:** a pushed bundle is written to `incoming/`, its header read in node
|
|
18
|
+
* (worker/bundle-header.ts), and fetched, object-checked, into a fresh quarantine repository
|
|
19
|
+
* that borrows the mirror's objects through `objects/info/alternates`. The push to GitHub goes
|
|
20
|
+
* out from there. Pushed objects therefore never enter the mirror, whose objects come only
|
|
21
|
+
* from GitHub; the quarantine is deleted whole.
|
|
22
|
+
*
|
|
23
|
+
* `refs/heads/*` mirrors GitHub as of the last fetch. A cache: deleting it costs one fetch of the
|
|
24
|
+
* whole repository from GitHub.
|
|
25
|
+
*
|
|
26
|
+
* One process owns it, and {@link GitHubMirror.exclusive} runs one session at a time, so a fetch's
|
|
27
|
+
* `--prune` never meets a push half way, and the mirror's heads cannot move between a push's
|
|
28
|
+
* reachability test and the push. It sweeps what a killed git left, rebuilds itself from GitHub
|
|
29
|
+
* when it would lie, and runs maintenance beside sessions under a mutex of its own
|
|
30
|
+
* (worker/github-mirror-upkeep.ts, whose module doc holds the lock order).
|
|
31
|
+
*
|
|
32
|
+
* Every transfer runs with `--progress`: the timeout is inactivity, and a quiet fetch of a whole
|
|
33
|
+
* repository would otherwise be killed for its size. The connectivity walk after a fetch still
|
|
34
|
+
* prints nothing (safeinsights/canopycms#901).
|
|
35
|
+
*/
|
|
36
|
+
export declare class GitHubMirror {
|
|
37
|
+
private readonly stateDirectory;
|
|
38
|
+
private readonly timeoutMs;
|
|
39
|
+
private readonly maintenanceIntervalMs;
|
|
40
|
+
private readonly bundleRetentionMs;
|
|
41
|
+
readonly gitDir: string;
|
|
42
|
+
private readonly incomingDir;
|
|
43
|
+
private readonly outgoingDir;
|
|
44
|
+
private tail;
|
|
45
|
+
private ingestTail;
|
|
46
|
+
private warnedSize;
|
|
47
|
+
private ready;
|
|
48
|
+
private swept;
|
|
49
|
+
private transferDirs;
|
|
50
|
+
private pendingBundle;
|
|
51
|
+
private readonly maintenance;
|
|
52
|
+
private lastMaintenanceAt;
|
|
53
|
+
private corruption;
|
|
54
|
+
/**
|
|
55
|
+
* Changes whenever the mirror stops holding what the last GitHub fetch put there: it was
|
|
56
|
+
* created anew, found corrupt, or a rebuild replaced it. A GitHub fetch is reused only within
|
|
57
|
+
* the generation it completed in.
|
|
58
|
+
*/
|
|
59
|
+
generation: number;
|
|
60
|
+
private rebuildFailedAt;
|
|
61
|
+
/** A sweep the maintenance mutex prevented, done at the next session start that can take it. */
|
|
62
|
+
private sweepOwed;
|
|
63
|
+
private readonly activityListeners;
|
|
64
|
+
/**
|
|
65
|
+
* `maintenanceIntervalMs` (default {@link MAINTENANCE_INTERVAL_MS}) also delays the first run:
|
|
66
|
+
* a mirror just fetched is in few packs. `bundleRetentionMs` (default
|
|
67
|
+
* {@link BUNDLE_RETENTION_MS}) is how long a bundle no one opens is kept.
|
|
68
|
+
*/
|
|
69
|
+
constructor(stateDirectory: string, timeoutMs: number, maintenanceIntervalMs?: number, bundleRetentionMs?: number);
|
|
70
|
+
/**
|
|
71
|
+
* Run `fn` with the mirror to itself, after every session started before it. The first session
|
|
72
|
+
* of a gateway first clears what a killed one left ({@link sweepAtStart}), and any session first
|
|
73
|
+
* does a sweep that is owed ({@link sweepIfOwed}). Creates the mirror if it is missing, and
|
|
74
|
+
* checks it again (for corruption too) after any session that failed. Deletes any credential
|
|
75
|
+
* file a killed or failed cleanup left: no session is running, so none is in use.
|
|
76
|
+
*/
|
|
77
|
+
exclusive<T>(fn: (session: MirrorSession) => Promise<T>): Promise<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Call `listener` at each sign of life from a session's git (output, input taken) until the
|
|
80
|
+
* returned function is called: what a caller waiting on the mirror sees of progress, whoever's
|
|
81
|
+
* session it is.
|
|
82
|
+
*/
|
|
83
|
+
watchActivity(listener: () => void): () => void;
|
|
84
|
+
private readonly activity;
|
|
85
|
+
/**
|
|
86
|
+
* Create the state directory if it is missing, and refuse one this process does not own outright
|
|
87
|
+
* or another user can write: the gateway's boot check, whose failure no later session could clear.
|
|
88
|
+
*/
|
|
89
|
+
assertStateDirectory(): Promise<void>;
|
|
90
|
+
/** Create the mirror now rather than at its first use. */
|
|
91
|
+
ensure(): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Clear what a killed gateway left, before any git runs: finish or undo an interrupted rebuild,
|
|
94
|
+
* then every lock and temporary in the mirror. Nothing in this process writes it yet:
|
|
95
|
+
* maintenance starts only after a session. A git a stopped dev worker left running is not
|
|
96
|
+
* covered (safeinsights/canopycms#907).
|
|
97
|
+
*/
|
|
98
|
+
private sweepAtStart;
|
|
99
|
+
/**
|
|
100
|
+
* Create the mirror, or recreate one that is not a readable bare repository, and record whether
|
|
101
|
+
* an existing one is corrupt ({@link findCorruption}), which the next GitHub fetch's session
|
|
102
|
+
* repairs ({@link heal}); until then the generation change keeps every caller off it.
|
|
103
|
+
*/
|
|
104
|
+
private create;
|
|
105
|
+
/**
|
|
106
|
+
* Refuse a session that cannot repair the mirror while it is corrupt: one without the credential
|
|
107
|
+
* a rebuild fetches with.
|
|
108
|
+
*/
|
|
109
|
+
assertUsable(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Inside a GitHub fetch's session, rebuild a mirror {@link create} found corrupt, as a plain
|
|
112
|
+
* call (the session is not re-entrant), waiting for maintenance to finish: the lock order is session, then the
|
|
113
|
+
* maintenance mutex. The replacement is fetched whole from GitHub into `github.git.rebuild`, and
|
|
114
|
+
* swapped in only once complete: the mirror is renamed to `.old`, `.rebuild` into its place, and
|
|
115
|
+
* `.old` deleted ({@link recoverRebuild} finishes or undoes a swap a crash interrupted). No
|
|
116
|
+
* quarantine is live while the session is held, so moving the objects it would borrow is safe.
|
|
117
|
+
* After a failed rebuild, sessions answer transient for {@link REBUILD_BACKOFF_MS} rather than
|
|
118
|
+
* fetch the whole repository again each.
|
|
119
|
+
*/
|
|
120
|
+
heal(session: MirrorSession, credential: GitHubCredential): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* The GitHub fetch, inside a session. A failure sweeps the mirror's locks and temporaries
|
|
123
|
+
* ({@link sweepUnlessMaintained}), so it leaves no pack of its own behind; when git failed on
|
|
124
|
+
* one of the mirror's own leftovers ({@link isOwnLockFailure}) and the sweep ran, the fetch is
|
|
125
|
+
* tried once more. While maintenance runs, which holds such files live, nothing is swept, the
|
|
126
|
+
* sweep is owed, and a leftover's failure is transient. Never waits for the mutex, so a push
|
|
127
|
+
* never waits behind a repack.
|
|
128
|
+
*/
|
|
129
|
+
fetchFromGitHub(session: MirrorSession, credential: GitHubCredential, signal?: AbortSignal): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Inside a session, sweep the mirror's locks and temporaries ({@link sweepLocksAndTemporaries}),
|
|
132
|
+
* logging what went under `label`, unless maintenance holds the mutex: then the sweep is owed.
|
|
133
|
+
* Returns whether it swept.
|
|
134
|
+
*/
|
|
135
|
+
private sweepUnlessMaintained;
|
|
136
|
+
/** At a session's start, the sweep a held mutex prevented, if it can take the mutex now. */
|
|
137
|
+
private sweepIfOwed;
|
|
138
|
+
/**
|
|
139
|
+
* After a completed GitHub fetch's session: warn once if the mirror has grown past
|
|
140
|
+
* {@link MIRROR_SIZE_WARN_KIB}, and start maintenance, detached, at most once per maintenance
|
|
141
|
+
* interval, unless the mutex is held (a rebuild, or maintenance itself).
|
|
142
|
+
*/
|
|
143
|
+
afterFetch(): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* One maintenance run, holding the mutex; it never takes a session. A failed run owes a sweep
|
|
146
|
+
* of what it left, and the next run waits a whole interval from this one's end.
|
|
147
|
+
*/
|
|
148
|
+
private runMaintenance;
|
|
149
|
+
private warnIfLarge;
|
|
150
|
+
/**
|
|
151
|
+
* Empty `incoming/` and `outgoing/` of what an earlier gateway left, once per gateway: after
|
|
152
|
+
* that, everything in them belongs to a transfer of this one's, which removes its own, so a
|
|
153
|
+
* later call only re-creates one that has gone (the state directory removed under it).
|
|
154
|
+
*/
|
|
155
|
+
private ensureTransferDirs;
|
|
156
|
+
/**
|
|
157
|
+
* git for `check-ref-format`, run in the state directory like every other gateway git. It reads
|
|
158
|
+
* the repository's config, as any git does, and its refs only to expand `@{-N}`, which
|
|
159
|
+
* `assertPlainBranchName` refuses.
|
|
160
|
+
*/
|
|
161
|
+
checkGit(): Promise<SimpleGit>;
|
|
162
|
+
/** Where a session writes a new outgoing bundle: a fresh name, never a caller's. */
|
|
163
|
+
outgoingBundlePath(): Promise<string>;
|
|
164
|
+
/**
|
|
165
|
+
* Make `file` the one pending outgoing bundle, or none, deleting the one it replaces (never an
|
|
166
|
+
* opened one), so a loop of fetches never fills the state directory, and deleting it after the
|
|
167
|
+
* bundle retention if no one opens it. Returns the id that opens it: a key into this object,
|
|
168
|
+
* never a path.
|
|
169
|
+
*/
|
|
170
|
+
setPendingBundle(file: string | null): Promise<string | null>;
|
|
171
|
+
/**
|
|
172
|
+
* The pending bundle `id` names, readable once: it is no longer pending once opened, so a later
|
|
173
|
+
* fetch never deletes it, and its file is deleted when the stream closes.
|
|
174
|
+
* Throws {@link GitHubTransientError} for an id that is not the pending bundle's.
|
|
175
|
+
*/
|
|
176
|
+
openBundle(id: string): Promise<Readable>;
|
|
177
|
+
/**
|
|
178
|
+
* Receive a pushed bundle into a directory of its own under `incoming/`, refusing it as it
|
|
179
|
+
* arrives (header, size), run `fn` with it, then delete the directory. One at a time, so pushed
|
|
180
|
+
* bundles hold at most one cap's worth of disk, plus about as much again for the quarantine's
|
|
181
|
+
* copy of the pack.
|
|
182
|
+
*/
|
|
183
|
+
ingest<T>(body: Readable, expected: {
|
|
184
|
+
sha: string;
|
|
185
|
+
branch: string;
|
|
186
|
+
}, maxBytes: number, fn: (bundle: ReceivedBundle) => Promise<T>): Promise<T>;
|
|
187
|
+
}
|
|
188
|
+
/** A pushed bundle, received and its header read: {@link GitHubMirror.ingest}. */
|
|
189
|
+
export interface ReceivedBundle {
|
|
190
|
+
/** The directory it and its quarantine live in, deleted after the push. */
|
|
191
|
+
readonly dir: string;
|
|
192
|
+
readonly file: string;
|
|
193
|
+
readonly header: BundleHeader;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* A push or fetch the gateway could not complete for a reason a later attempt can clear: GitHub
|
|
197
|
+
* unreachable, a bundle that did not arrive whole or valid, a prerequisite GitHub no longer has,
|
|
198
|
+
* a bundle already gone. The task retries it. The code says where it failed, not whose doing it
|
|
199
|
+
* was: a `github-fetch-failed` or a `mirror-corrupt` can each follow a GitHub-bound git that
|
|
200
|
+
* failed, and only that arms a credential re-read (`LocalGitHubGateway.credentialed`).
|
|
201
|
+
*/
|
|
202
|
+
export declare class GitHubTransientError extends Error {
|
|
203
|
+
readonly code: 'github-fetch-failed' | 'bundle-rejected' | 'prerequisite-gone' | 'bundle-gone' | 'mirror-corrupt' | 'objects-still-needed' | 'ref-kept-moving' | 'default-branch-unread';
|
|
204
|
+
constructor(code: 'github-fetch-failed' | 'bundle-rejected' | 'prerequisite-gone' | 'bundle-gone' | 'mirror-corrupt' | 'objects-still-needed' | 'ref-kept-moving' | 'default-branch-unread', message: string);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* What a GitHub-bound git command authenticates with: the GitHub fetch, the `ls-remote` that reads
|
|
208
|
+
* GitHub's default branch, and the push to GitHub.
|
|
209
|
+
*/
|
|
210
|
+
export interface GitHubCredential {
|
|
211
|
+
/** GitHub's bare https URL, or a test's stand-in for it. Never carries the token. */
|
|
212
|
+
readonly url: string;
|
|
213
|
+
readonly token: string;
|
|
214
|
+
/** Told of each GitHub-bound command that fails, except on a lock of the mirror's own. */
|
|
215
|
+
onFailure(): void;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Whether git's own output, not a `remote:` line relayed from GitHub, says a lock file or
|
|
219
|
+
* `packed-refs.new` was already there: the mirror's own housekeeping holds it, or a killed git
|
|
220
|
+
* left it, which says nothing about the credential.
|
|
221
|
+
* @internal Exported for tests.
|
|
222
|
+
*/
|
|
223
|
+
export declare function isOwnLockFailure(message: string): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* A push the worker never makes: to a name that is not a plain branch name, to a protected branch
|
|
226
|
+
* (`BranchPolicy`), to a settings branch under a lease, or of an object that is not a commit.
|
|
227
|
+
*/
|
|
228
|
+
export declare class RefusedPushError extends GatewayRefusalError {
|
|
229
|
+
constructor(branch: string, reason: 'invalid' | 'protected' | 'settings' | 'not-a-commit', sha?: string);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Throw {@link RefusedPushError} (or, for another `operation`, {@link GatewayRefusalError}) unless
|
|
233
|
+
* `branch` is a plain branch name: one `branchNameProblem` passes (with `shape` false, only its
|
|
234
|
+
* length cap and no leading `-`) and `git check-ref-format --branch` accepts unchanged. That rules out a `:` (git would read what
|
|
235
|
+
* follows it in a refspec as another destination), `..`, `^`, `~`, `@{`, spaces and a leading
|
|
236
|
+
* `-`, so `refs/heads/<branch>` is exactly the ref a push names. `check-ref-format --branch` takes
|
|
237
|
+
* exactly one argument and refuses `--end-of-options`, which is why it alone goes without one.
|
|
238
|
+
* `git` is the caller's instance: the gateway's runs in its state directory.
|
|
239
|
+
*/
|
|
240
|
+
export declare function assertPlainBranchName(branch: string, git?: SimpleGit, operation?: 'push' | 'delete' | 'pull-request',
|
|
241
|
+
/** False for a name the gateway only passes on, never acts on: git's rules, its length, no leading `-`. */
|
|
242
|
+
shape?: boolean): Promise<void>;
|
|
243
|
+
/** What one {@link GitHubMirror.exclusive} call may do. */
|
|
244
|
+
export declare class MirrorSession {
|
|
245
|
+
private readonly gitDir;
|
|
246
|
+
private readonly stateDirectory;
|
|
247
|
+
private readonly timeoutMs;
|
|
248
|
+
private readonly onActivity?;
|
|
249
|
+
constructor(gitDir: string, stateDirectory: string, timeoutMs: number, onActivity?: (() => void) | undefined);
|
|
250
|
+
/** simple-git in `repo`: the mirror, or a quarantine of this session's. */
|
|
251
|
+
private git;
|
|
252
|
+
/** git with `stdin` fed to it, in `repo` under `config` (the mirror's pins by default). */
|
|
253
|
+
private run;
|
|
254
|
+
/**
|
|
255
|
+
* Run one GitHub-bound command in `repo`, `args` naming `credential.url` where git expects the
|
|
256
|
+
* remote. The credential reaches it only through {@link withCredentialConfig}'s file, named by
|
|
257
|
+
* `GIT_CONFIG_GLOBAL`, so it is in no argv and in no process's environment. No trace variable
|
|
258
|
+
* reaches this git: trace2 can print config values. Its failure is reported to the credential
|
|
259
|
+
* unless {@link isOwnLockFailure}.
|
|
260
|
+
*
|
|
261
|
+
* It runs through worker/git-process.ts, in a process group of its own, so an abort or a kill
|
|
262
|
+
* reaches what git spawned for the transfer too (`git-remote-https`, `pack-objects`); simple-git
|
|
263
|
+
* would signal git alone. Besides the inactivity bound, curl's low-speed limit ends a transfer
|
|
264
|
+
* that trickles: {@link LOW_SPEED_BYTES_PER_SECOND} for as long as the inactivity bound.
|
|
265
|
+
*/
|
|
266
|
+
private githubBound;
|
|
267
|
+
/**
|
|
268
|
+
* Bring `refs/heads/*` of `repo` (the mirror, or a rebuild's replacement) to exactly what GitHub
|
|
269
|
+
* holds. Sessions fetch through {@link GitHubMirror.fetchFromGitHub}, which cleans up after it.
|
|
270
|
+
*/
|
|
271
|
+
fetchFromGitHub(credential: GitHubCredential, signal?: AbortSignal, repo?: string): Promise<void>;
|
|
272
|
+
/** Every branch GitHub had at the last fetch, mapped to its tip. */
|
|
273
|
+
heads(): Promise<Map<string, string>>;
|
|
274
|
+
/**
|
|
275
|
+
* Bundle every branch into `file`, less what `have` already holds: each ID the mirror has as a
|
|
276
|
+
* commit is excluded with its history, and any other ID is ignored. False, with no file, when
|
|
277
|
+
* that leaves nothing to send. Each ID is validated before it reaches here, since rev-list's
|
|
278
|
+
* `--stdin` honours a pseudo-option such as `--all`.
|
|
279
|
+
*/
|
|
280
|
+
createBundle(have: readonly string[], file: string, signal?: AbortSignal): Promise<boolean>;
|
|
281
|
+
/**
|
|
282
|
+
* Each of `ids` mapped to its object type in `repo`, or to `missing`, from one
|
|
283
|
+
* `cat-file --batch-check`, which prints `<id> missing` for an absent object where `cat-file -t`
|
|
284
|
+
* shares exit 128 with every other failure. Every ID must already be validated.
|
|
285
|
+
*/
|
|
286
|
+
objectTypes(ids: readonly string[], repo?: string): Promise<Map<string, string>>;
|
|
287
|
+
/**
|
|
288
|
+
* Whether a GitHub branch contained the commit `sha` at the last fetch. Only for a commit:
|
|
289
|
+
* `--contains` exits 129 on a missing or non-commit object.
|
|
290
|
+
*/
|
|
291
|
+
reachableFromHeads(sha: string): Promise<boolean>;
|
|
292
|
+
/** Of `prerequisites`, the commits a GitHub branch contained at the last fetch. */
|
|
293
|
+
usablePrerequisites(prerequisites: readonly string[]): Promise<string[]>;
|
|
294
|
+
/**
|
|
295
|
+
* Whether every one of `commits` is reachable from one of `tips`, in ONE walk: rev-list fed the
|
|
296
|
+
* commits and a `^<tip>` per tip lists what the tips do not reach, so empty output means all
|
|
297
|
+
* are reached (several `--contains` would mean "any", not "all"). Only for commits: rev-list
|
|
298
|
+
* passes a tree or blob ID silently.
|
|
299
|
+
*/
|
|
300
|
+
private allReachable;
|
|
301
|
+
/**
|
|
302
|
+
* The branch GitHub's HEAD names, or null for a repository with none (empty, or HEAD unborn). A
|
|
303
|
+
* failure to reach GitHub throws, so a push that cannot learn it does not happen.
|
|
304
|
+
*/
|
|
305
|
+
githubDefaultBranch(credential: GitHubCredential, signal?: AbortSignal): Promise<string | null>;
|
|
306
|
+
/**
|
|
307
|
+
* Take a received bundle into a fresh quarantine repository beside it, returning the
|
|
308
|
+
* quarantine's path, with `sha` there as a commit. In order:
|
|
309
|
+
* 1. each prerequisite must be a commit the mirror holds, reachable from one of `heads` (the
|
|
310
|
+
* branches GitHub had at this session's fetch): one `cat-file --batch-check`, then one walk;
|
|
311
|
+
* 2. the quarantine borrows the mirror's objects through `objects/info/alternates`, with the
|
|
312
|
+
* mirror's pins except `core.alternateRefsCommand` ({@link quarantinePins});
|
|
313
|
+
* 3. `fetch` of the bundle's one head into a staging ref, checking every object, by a refspec
|
|
314
|
+
* built from the validated branch, never from the bundle;
|
|
315
|
+
* 4. the staging ref must be `sha`, and `sha` a commit.
|
|
316
|
+
* A refusal is {@link GitHubTransientError} (`bundle-rejected`, or `prerequisite-gone` for a
|
|
317
|
+
* prerequisite GitHub no longer has), except a non-commit `sha`, which is
|
|
318
|
+
* {@link RefusedPushError}. Nothing here writes the mirror.
|
|
319
|
+
*/
|
|
320
|
+
quarantine(bundle: ReceivedBundle, expected: {
|
|
321
|
+
sha: string;
|
|
322
|
+
branch: string;
|
|
323
|
+
}, heads: ReadonlyMap<string, string>, signal?: AbortSignal): Promise<string>;
|
|
324
|
+
/**
|
|
325
|
+
* Push exactly `sha` from `repo` (the mirror, or a quarantine holding it) to GitHub's
|
|
326
|
+
* `refs/heads/<branch>`. `lease` is the commit GitHub must still be at for the push to replace
|
|
327
|
+
* it (`--force-with-lease`); without one the push is an ordinary fast-forward. Resolves with
|
|
328
|
+
* what the push did to GitHub's ref.
|
|
329
|
+
*
|
|
330
|
+
* Validation and `policy` are here, at the one place every GitHub push (plain or under a lease)
|
|
331
|
+
* goes through, so no caller can skip them. When `policy` needs GitHub's default branch read
|
|
332
|
+
* afresh, it is read here, in this session, from the repository the push goes to. A bundle's quarantine fetch
|
|
333
|
+
* names `branch` first, so the gateway validates it before the ingest too (`pushOnce`).
|
|
334
|
+
*/
|
|
335
|
+
pushToGitHub(credential: GitHubCredential, branch: string, sha: string, options: {
|
|
336
|
+
lease?: string;
|
|
337
|
+
signal?: AbortSignal;
|
|
338
|
+
repo?: string;
|
|
339
|
+
policy: BranchPolicy;
|
|
340
|
+
/** Called once the push is allowed, just before git pushes. */
|
|
341
|
+
onPushing?: () => void;
|
|
342
|
+
}): Promise<GitHubRefUpdate>;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* What a push did to GitHub's `refs/heads/<branch>`. `from` is git's abbreviation of the old tip,
|
|
346
|
+
* null for a new branch; `to` is the full SHA pushed.
|
|
347
|
+
*/
|
|
348
|
+
export type GitHubRefUpdate = {
|
|
349
|
+
moved: false;
|
|
350
|
+
} | {
|
|
351
|
+
moved: true;
|
|
352
|
+
from: string | null;
|
|
353
|
+
to: string;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Read `refs/heads/<branch>`'s line from `git push --porcelain`'s stdout: `=` up to date, ` ` a
|
|
357
|
+
* fast-forward (`old..new`), `+` a forced update (`old...new`), `*` a new branch. A rejected ref
|
|
358
|
+
* (`!`) makes git exit non-zero before this runs. Output with no such line throws, rather than
|
|
359
|
+
* report a push this did not see.
|
|
360
|
+
* @internal Exported for tests.
|
|
361
|
+
*/
|
|
362
|
+
export declare function parsePushStatus(stdout: string, branch: string, sha: string): GitHubRefUpdate;
|
|
363
|
+
/** A full SHA-1 or SHA-256 object ID, so nothing else can reach a refspec or rev-list's stdin. */
|
|
364
|
+
export declare function isObjectId(value: string): boolean;
|