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.
- package/README.md +30 -3
- package/dist/ai/generate.js +1 -27
- package/dist/ai/handler.d.ts +0 -4
- package/dist/ai/handler.js +0 -11
- package/dist/ai/index.d.ts +1 -8
- package/dist/ai/index.js +1 -8
- package/dist/ai/json-to-markdown.js +15 -58
- package/dist/ai/resolve-branch.d.ts +2 -7
- package/dist/ai/resolve-branch.js +2 -8
- package/dist/ai/strip-mdx.d.ts +5 -13
- package/dist/ai/strip-mdx.js +5 -17
- package/dist/ai/to-plain-text.d.ts +10 -28
- package/dist/ai/to-plain-text.js +10 -28
- package/dist/ai/transform-components.d.ts +2 -4
- package/dist/ai/transform-components.js +8 -19
- package/dist/ai/types.d.ts +5 -10
- package/dist/api/admin-branch-health.d.ts +4 -12
- package/dist/api/admin-branch-health.js +26 -66
- package/dist/api/admin.d.ts +4 -12
- package/dist/api/admin.js +10 -26
- package/dist/api/assets.d.ts +0 -25
- package/dist/api/assets.js +50 -91
- package/dist/api/branch-merge.d.ts +1 -1
- package/dist/api/branch-merge.js +0 -2
- package/dist/api/branch-review.d.ts +0 -8
- package/dist/api/branch-review.js +0 -13
- package/dist/api/branch-status.d.ts +0 -3
- package/dist/api/branch-status.js +8 -33
- package/dist/api/branch-withdraw.d.ts +0 -1
- package/dist/api/branch-withdraw.js +6 -9
- package/dist/api/branch.d.ts +7 -12
- package/dist/api/branch.js +7 -44
- package/dist/api/client.d.ts +71 -224
- package/dist/api/client.js +82 -233
- package/dist/api/comments.d.ts +2 -4
- package/dist/api/comments.js +0 -17
- package/dist/api/content.d.ts +0 -6
- package/dist/api/content.js +66 -142
- package/dist/api/entries-constants.d.ts +5 -9
- package/dist/api/entries-constants.js +5 -9
- package/dist/api/entries.d.ts +8 -13
- package/dist/api/entries.js +20 -51
- package/dist/api/github-sync.d.ts +2 -4
- package/dist/api/github-sync.js +4 -8
- package/dist/api/groups.d.ts +3 -0
- package/dist/api/groups.js +8 -21
- package/dist/api/guards.d.ts +4 -16
- package/dist/api/guards.js +3 -22
- package/dist/api/index.d.ts +4 -4
- package/dist/api/permissions.d.ts +2 -0
- package/dist/api/permissions.js +18 -40
- package/dist/api/reference-options.d.ts +0 -1
- package/dist/api/reference-options.js +3 -11
- package/dist/api/request-body-hash.d.ts +12 -23
- package/dist/api/request-body-hash.js +12 -23
- package/dist/api/resolve-references.d.ts +0 -1
- package/dist/api/resolve-references.js +13 -28
- package/dist/api/route-builder.d.ts +3 -7
- package/dist/api/route-builder.js +1 -1
- package/dist/api/routes.d.ts +12 -0
- package/dist/api/routes.js +47 -0
- package/dist/api/schema.d.ts +23 -33
- package/dist/api/schema.js +20 -74
- package/dist/api/settings-helpers.js +4 -5
- package/dist/api/types.d.ts +0 -5
- package/dist/api/user.js +0 -5
- package/dist/api/validators.d.ts +14 -52
- package/dist/api/validators.js +14 -52
- package/dist/assets/asset-prefixes.d.ts +4 -8
- package/dist/assets/asset-prefixes.js +4 -8
- package/dist/assets/asset-src.d.ts +5 -22
- package/dist/assets/asset-src.js +5 -21
- package/dist/assets/factory.d.ts +1 -2
- package/dist/assets/factory.js +1 -2
- package/dist/assets/finalize.d.ts +3 -1
- package/dist/assets/finalize.js +3 -1
- package/dist/assets/index.d.ts +3 -3
- package/dist/assets/index.js +1 -1
- package/dist/assets/keys.d.ts +5 -3
- package/dist/assets/keys.js +6 -3
- package/dist/assets/pipeline.d.ts +3 -2
- package/dist/assets/pipeline.js +22 -56
- package/dist/assets/sharp-loader.d.ts +2 -10
- package/dist/assets/sharp-loader.js +2 -10
- package/dist/assets/store-local.d.ts +1 -2
- package/dist/assets/store-local.js +1 -2
- package/dist/assets/store-s3.d.ts +3 -4
- package/dist/assets/svg-sanitizer.d.ts +6 -14
- package/dist/assets/svg-sanitizer.js +6 -14
- package/dist/assets/transform-directives.d.ts +3 -4
- package/dist/assets/transform-directives.js +1 -1
- package/dist/assets/transform.d.ts +19 -30
- package/dist/assets/transform.js +18 -31
- package/dist/auth/cache.d.ts +2 -3
- package/dist/auth/cache.js +2 -3
- package/dist/auth/caching-auth-plugin.d.ts +11 -22
- package/dist/auth/caching-auth-plugin.js +12 -14
- package/dist/auth/context-helpers.d.ts +6 -20
- package/dist/auth/context-helpers.js +5 -17
- package/dist/auth/file-based-auth-cache.d.ts +10 -21
- package/dist/auth/file-based-auth-cache.js +23 -51
- package/dist/auth/plugin.d.ts +29 -61
- package/dist/auth/plugin.js +9 -13
- package/dist/auth/types.d.ts +11 -20
- package/dist/authorization/branch.d.ts +30 -49
- package/dist/authorization/branch.js +16 -42
- package/dist/authorization/content.d.ts +11 -40
- package/dist/authorization/content.js +13 -45
- package/dist/authorization/groups/index.d.ts +0 -3
- package/dist/authorization/groups/index.js +0 -3
- package/dist/authorization/groups/loader.d.ts +14 -28
- package/dist/authorization/groups/loader.js +14 -38
- package/dist/authorization/groups/schema.d.ts +0 -6
- package/dist/authorization/groups/schema.js +4 -7
- package/dist/authorization/helpers.d.ts +9 -28
- package/dist/authorization/helpers.js +9 -28
- package/dist/authorization/index.d.ts +3 -25
- package/dist/authorization/index.js +3 -35
- package/dist/authorization/path.d.ts +6 -13
- package/dist/authorization/path.js +8 -25
- package/dist/authorization/permissions/index.d.ts +0 -3
- package/dist/authorization/permissions/index.js +0 -3
- package/dist/authorization/permissions/loader.d.ts +14 -27
- package/dist/authorization/permissions/loader.js +14 -32
- package/dist/authorization/permissions/schema.d.ts +1 -6
- package/dist/authorization/permissions/schema.js +6 -13
- package/dist/authorization/protected-branch.d.ts +36 -65
- package/dist/authorization/protected-branch.js +29 -41
- package/dist/authorization/settings-file-store.d.ts +38 -81
- package/dist/authorization/settings-file-store.js +38 -79
- package/dist/authorization/types.d.ts +4 -26
- package/dist/authorization/types.js +0 -6
- package/dist/authorization/validation.d.ts +1 -23
- package/dist/authorization/validation.js +1 -24
- package/dist/branch-health.d.ts +39 -67
- package/dist/branch-health.js +27 -43
- package/dist/branch-metadata-file.d.ts +16 -32
- package/dist/branch-metadata-file.js +13 -26
- package/dist/branch-metadata.d.ts +49 -80
- package/dist/branch-metadata.js +57 -87
- package/dist/branch-registry.d.ts +26 -64
- package/dist/branch-registry.js +44 -93
- package/dist/branch-schema-cache.d.ts +34 -124
- package/dist/branch-schema-cache.js +49 -155
- package/dist/branch-workspace.d.ts +4 -4
- package/dist/branch-workspace.js +15 -19
- package/dist/build/generate-ai-content.d.ts +1 -0
- package/dist/build/generate-ai-content.js +12 -25
- package/dist/build-canopy.d.ts +17 -27
- package/dist/build-canopy.js +16 -23
- package/dist/build-mode.d.ts +25 -27
- package/dist/build-mode.js +25 -29
- package/dist/cli/cli.d.ts +15 -26
- package/dist/cli/cli.js +601 -978
- package/dist/cli/generate-ai-content.js +351 -628
- package/dist/cli/github-app-manifest.d.ts +84 -0
- package/dist/cli/github-app-manifest.js +161 -0
- package/dist/cli/init-github-app.d.ts +110 -444
- package/dist/cli/init-github-app.js +236 -773
- package/dist/cli/init.js +39 -80
- package/dist/cli/migrate.d.ts +13 -10
- package/dist/cli/migrate.js +22 -30
- package/dist/cli/project-detect.d.ts +17 -31
- package/dist/cli/project-detect.js +31 -42
- package/dist/cli/project-root.d.ts +4 -11
- package/dist/cli/project-root.js +4 -11
- package/dist/cli/prompt.d.ts +10 -0
- package/dist/cli/prompt.js +67 -0
- package/dist/cli/sync.d.ts +0 -8
- package/dist/cli/sync.js +8 -28
- package/dist/cli/template-files/middleware.ts.template +15 -29
- package/dist/cli/templates.d.ts +2 -12
- package/dist/cli/templates.js +4 -4
- package/dist/client.d.ts +1 -1
- package/dist/comment-store.d.ts +32 -53
- package/dist/comment-store.js +32 -52
- package/dist/config/flatten.d.ts +0 -3
- package/dist/config/flatten.js +2 -12
- package/dist/config/helpers.js +2 -2
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +1 -4
- package/dist/config/schemas/collection.d.ts +0 -8
- package/dist/config/schemas/collection.js +0 -10
- package/dist/config/schemas/config.d.ts +6 -78
- package/dist/config/schemas/config.js +38 -54
- package/dist/config/schemas/field.d.ts +2 -242
- package/dist/config/schemas/field.js +9 -20
- package/dist/config/schemas/media.js +1 -1
- package/dist/config/schemas/permissions.js +0 -2
- package/dist/config/schemas/url.d.ts +5 -6
- package/dist/config/schemas/url.js +5 -6
- package/dist/config/types.d.ts +45 -33
- package/dist/config/types.js +0 -1
- package/dist/config.d.ts +1 -8
- package/dist/config.js +1 -9
- package/dist/content-id-index.d.ts +76 -188
- package/dist/content-id-index.js +79 -230
- package/dist/content-index-generation.d.ts +27 -48
- package/dist/content-index-generation.js +35 -84
- package/dist/content-index-registry.d.ts +15 -24
- package/dist/content-index-registry.js +5 -9
- package/dist/content-listing.d.ts +64 -107
- package/dist/content-listing.js +68 -118
- package/dist/content-reader.d.ts +20 -29
- package/dist/content-reader.js +10 -18
- package/dist/content-store.d.ts +210 -336
- package/dist/content-store.js +413 -657
- package/dist/content-tree.d.ts +44 -86
- package/dist/content-tree.js +26 -54
- package/dist/context.d.ts +67 -94
- package/dist/context.js +53 -72
- package/dist/dev-content-watcher.d.ts +18 -18
- package/dist/dev-content-watcher.js +41 -44
- package/dist/editor/BranchManager.d.ts +3 -6
- package/dist/editor/BranchManager.js +24 -44
- package/dist/editor/CanopyEditor.js +5 -2
- package/dist/editor/CommentsPanel.js +0 -2
- package/dist/editor/Editor.js +19 -76
- package/dist/editor/EditorAuthGate.d.ts +27 -0
- package/dist/editor/EditorAuthGate.js +140 -0
- package/dist/editor/EntryNavigator.js +0 -20
- package/dist/editor/FormRenderer.d.ts +1 -2
- package/dist/editor/FormRenderer.js +8 -23
- package/dist/editor/admin/SystemHealthPanel.js +20 -37
- package/dist/editor/admin/useSystemHealth.d.ts +2 -3
- package/dist/editor/admin/useSystemHealth.js +10 -12
- package/dist/editor/client-reference-resolver.d.ts +2 -5
- package/dist/editor/client-reference-resolver.js +2 -19
- package/dist/editor/comments/BranchComments.js +0 -4
- package/dist/editor/comments/EntryComments.js +0 -4
- package/dist/editor/comments/FieldWrapper.js +0 -4
- package/dist/editor/comments/InlineCommentThread.js +0 -2
- package/dist/editor/comments/ThreadCarousel.d.ts +0 -58
- package/dist/editor/comments/ThreadCarousel.js +0 -12
- package/dist/editor/components/EditorFooter.d.ts +0 -8
- package/dist/editor/components/EditorFooter.js +0 -5
- package/dist/editor/components/EditorHeader.d.ts +0 -31
- package/dist/editor/components/EditorHeader.js +21 -71
- package/dist/editor/components/EditorSidebar.d.ts +0 -19
- package/dist/editor/components/EditorSidebar.js +0 -16
- package/dist/editor/components/EntryCreateModal.d.ts +4 -4
- package/dist/editor/components/EntryCreateModal.js +7 -22
- package/dist/editor/components/RenameEntryModal.js +0 -4
- package/dist/editor/components/UserBadge.js +0 -10
- package/dist/editor/components/index.js +0 -2
- package/dist/editor/context/ApiClientContext.d.ts +8 -7
- package/dist/editor/context/ApiClientContext.js +39 -11
- package/dist/editor/context/AssetContext.d.ts +7 -17
- package/dist/editor/context/AssetContext.js +7 -17
- package/dist/editor/context/EditorIdentityContext.d.ts +13 -0
- package/dist/editor/context/EditorIdentityContext.js +7 -0
- package/dist/editor/context/EditorStateContext.d.ts +10 -41
- package/dist/editor/context/EditorStateContext.js +7 -23
- package/dist/editor/context/SWRProvider.d.ts +3 -6
- package/dist/editor/context/index.d.ts +1 -20
- package/dist/editor/context/index.js +1 -20
- package/dist/editor/editor-utils.d.ts +8 -47
- package/dist/editor/editor-utils.js +19 -72
- package/dist/editor/fields/BlockField.d.ts +2 -2
- package/dist/editor/fields/BlockField.js +1 -2
- package/dist/editor/fields/CodeField.d.ts +0 -1
- package/dist/editor/fields/CodeField.js +0 -1
- package/dist/editor/fields/DateTimeField.d.ts +15 -22
- package/dist/editor/fields/DateTimeField.js +17 -26
- package/dist/editor/fields/ImageField.d.ts +2 -2
- package/dist/editor/fields/ImageField.js +8 -14
- package/dist/editor/fields/InlineGroupField.d.ts +0 -1
- package/dist/editor/fields/InlineGroupField.js +0 -1
- package/dist/editor/fields/MarkdownField.d.ts +0 -1
- package/dist/editor/fields/MarkdownField.js +6 -11
- package/dist/editor/fields/MdxImageDialog.d.ts +1 -1
- package/dist/editor/fields/MdxImageDialog.js +0 -1
- package/dist/editor/fields/NumberField.d.ts +9 -19
- package/dist/editor/fields/NumberField.js +11 -22
- package/dist/editor/fields/NumberListField.d.ts +7 -10
- package/dist/editor/fields/NumberListField.js +7 -10
- package/dist/editor/fields/ObjectField.d.ts +5 -8
- package/dist/editor/fields/ObjectField.js +0 -1
- package/dist/editor/fields/ReferenceField.d.ts +1 -1
- package/dist/editor/fields/ReferenceField.js +11 -16
- package/dist/editor/fields/SelectField.d.ts +2 -2
- package/dist/editor/fields/SelectField.js +0 -1
- package/dist/editor/fields/StringListField.d.ts +0 -4
- package/dist/editor/fields/StringListField.js +4 -9
- package/dist/editor/fields/TextField.d.ts +0 -1
- package/dist/editor/fields/TextField.js +0 -1
- package/dist/editor/fields/ToggleField.d.ts +0 -1
- package/dist/editor/fields/ToggleField.js +0 -1
- package/dist/editor/fields/entry-link/EntryLinkContext.js +2 -4
- package/dist/editor/fields/entry-link/InsertEntryLink.d.ts +0 -3
- package/dist/editor/fields/entry-link/InsertEntryLink.js +0 -4
- package/dist/editor/group-manager/ExternalGroupsTab.d.ts +0 -3
- package/dist/editor/group-manager/ExternalGroupsTab.js +0 -1
- package/dist/editor/group-manager/GroupCard.d.ts +0 -3
- package/dist/editor/group-manager/GroupForm.d.ts +0 -3
- package/dist/editor/group-manager/InternalGroupsTab.d.ts +0 -3
- package/dist/editor/group-manager/InternalGroupsTab.js +0 -2
- package/dist/editor/group-manager/MemberList.d.ts +0 -3
- package/dist/editor/group-manager/hooks/useExternalGroupSearch.d.ts +0 -3
- package/dist/editor/group-manager/hooks/useExternalGroupSearch.js +0 -3
- package/dist/editor/group-manager/hooks/useGroupState.d.ts +0 -3
- package/dist/editor/group-manager/hooks/useGroupState.js +0 -5
- package/dist/editor/group-manager/hooks/useUserSearch.d.ts +0 -3
- package/dist/editor/group-manager/hooks/useUserSearch.js +0 -3
- package/dist/editor/group-manager/index.d.ts +0 -6
- package/dist/editor/group-manager/index.js +0 -10
- package/dist/editor/group-manager/types.d.ts +2 -5
- package/dist/editor/group-manager/types.js +0 -3
- package/dist/editor/hooks/index.d.ts +6 -11
- package/dist/editor/hooks/index.js +6 -12
- package/dist/editor/hooks/useBranchActions.d.ts +0 -14
- package/dist/editor/hooks/useBranchActions.js +0 -22
- package/dist/editor/hooks/useBranchManager.d.ts +2 -48
- package/dist/editor/hooks/useBranchManager.js +4 -64
- package/dist/editor/hooks/useBranchesData.d.ts +7 -6
- package/dist/editor/hooks/useBranchesData.js +7 -6
- package/dist/editor/hooks/useCommentSystem.d.ts +0 -49
- package/dist/editor/hooks/useCommentSystem.js +1 -36
- package/dist/editor/hooks/useDraftManager.d.ts +2 -35
- package/dist/editor/hooks/useDraftManager.js +23 -64
- package/dist/editor/hooks/useEditorLayout.d.ts +0 -20
- package/dist/editor/hooks/useEditorLayout.js +0 -23
- package/dist/editor/hooks/useEntriesData.d.ts +1 -0
- package/dist/editor/hooks/useEntriesData.js +2 -3
- package/dist/editor/hooks/useEntryLinkResolution.d.ts +2 -2
- package/dist/editor/hooks/useEntryLinkResolution.js +2 -2
- package/dist/editor/hooks/useEntryManager.d.ts +2 -27
- package/dist/editor/hooks/useEntryManager.js +29 -78
- package/dist/editor/hooks/useGroupManager.d.ts +0 -21
- package/dist/editor/hooks/useGroupManager.js +0 -21
- package/dist/editor/hooks/usePermissionManager.d.ts +0 -20
- package/dist/editor/hooks/usePermissionManager.js +0 -20
- package/dist/editor/hooks/useReferenceResolution.d.ts +2 -33
- package/dist/editor/hooks/useReferenceResolution.js +1 -48
- package/dist/editor/hooks/useSchemaManager.d.ts +8 -27
- package/dist/editor/hooks/useSchemaManager.js +0 -19
- package/dist/editor/hooks/useUserContext.d.ts +2 -9
- package/dist/editor/hooks/useUserContext.js +10 -10
- package/dist/editor/hooks/useUserMetadata.d.ts +0 -2
- package/dist/editor/hooks/useUserMetadata.js +0 -3
- package/dist/editor/media/AssetCard.d.ts +0 -1
- package/dist/editor/media/AssetCard.js +1 -2
- package/dist/editor/media/CropStep.d.ts +0 -1
- package/dist/editor/media/CropStep.js +0 -1
- package/dist/editor/media/MediaLibrary.d.ts +1 -2
- package/dist/editor/media/MediaLibrary.js +1 -2
- package/dist/editor/media/MediaLibraryBody.d.ts +0 -1
- package/dist/editor/media/MediaLibraryBody.js +0 -1
- package/dist/editor/media/crop-math.d.ts +1 -1
- package/dist/editor/media/crop-math.js +1 -1
- package/dist/editor/permission-manager/GroupSelector.d.ts +0 -3
- package/dist/editor/permission-manager/PermissionEditor.d.ts +0 -4
- package/dist/editor/permission-manager/PermissionEditor.js +0 -1
- package/dist/editor/permission-manager/PermissionLevelBadge.d.ts +0 -7
- package/dist/editor/permission-manager/PermissionLevelBadge.js +0 -4
- package/dist/editor/permission-manager/PermissionTree.d.ts +0 -4
- package/dist/editor/permission-manager/UserSelector.d.ts +0 -3
- package/dist/editor/permission-manager/constants.d.ts +0 -3
- package/dist/editor/permission-manager/hooks/useGroupsAndUsers.d.ts +0 -3
- package/dist/editor/permission-manager/hooks/useGroupsAndUsers.js +0 -10
- package/dist/editor/permission-manager/hooks/usePermissionTree.d.ts +0 -14
- package/dist/editor/permission-manager/hooks/usePermissionTree.js +0 -11
- package/dist/editor/permission-manager/index.d.ts +0 -7
- package/dist/editor/permission-manager/index.js +0 -16
- package/dist/editor/permission-manager/types.d.ts +2 -12
- package/dist/editor/permission-manager/types.js +0 -3
- package/dist/editor/permission-manager/utils.d.ts +0 -28
- package/dist/editor/permission-manager/utils.js +9 -23
- package/dist/editor/preview-bridge.d.ts +5 -1
- package/dist/editor/preview-bridge.js +4 -4
- package/dist/editor/schema-editor/CollectionEditor.d.ts +0 -5
- package/dist/editor/schema-editor/CollectionEditor.js +9 -31
- package/dist/editor/schema-editor/EntryTypeEditor.d.ts +0 -6
- package/dist/editor/schema-editor/EntryTypeEditor.js +3 -24
- package/dist/editor/schema-editor/index.d.ts +0 -7
- package/dist/editor/schema-editor/index.js +0 -7
- package/dist/editor/utils/env.d.ts +3 -18
- package/dist/editor/utils/env.js +6 -25
- package/dist/entry-link-resolver.d.ts +13 -35
- package/dist/entry-link-resolver.js +20 -53
- package/dist/entry-schema-registry.d.ts +20 -60
- package/dist/entry-schema-registry.js +20 -69
- package/dist/entry-schema.d.ts +118 -223
- package/dist/entry-schema.js +46 -91
- package/dist/git-manager.d.ts +101 -200
- package/dist/git-manager.js +211 -384
- package/dist/github-service.d.ts +34 -75
- package/dist/github-service.js +37 -91
- package/dist/http/handler.d.ts +6 -37
- package/dist/http/handler.js +65 -120
- package/dist/http/router.d.ts +15 -32
- package/dist/http/router.js +34 -99
- package/dist/http/types.d.ts +15 -40
- package/dist/http/types.js +3 -7
- package/dist/id.d.ts +4 -10
- package/dist/id.js +4 -10
- package/dist/index.js +6 -9
- package/dist/operating-mode/client-safe-strategy.d.ts +7 -14
- package/dist/operating-mode/client-safe-strategy.js +8 -28
- package/dist/operating-mode/client-unsafe-strategy.d.ts +6 -16
- package/dist/operating-mode/client-unsafe-strategy.js +9 -34
- package/dist/operating-mode/client.d.ts +3 -10
- package/dist/operating-mode/client.js +3 -8
- package/dist/operating-mode/deployment-name-fixtures.d.ts +14 -18
- package/dist/operating-mode/deployment-name-fixtures.js +14 -18
- package/dist/operating-mode/deployment-name.d.ts +19 -29
- package/dist/operating-mode/deployment-name.js +29 -47
- package/dist/operating-mode/index.d.ts +4 -25
- package/dist/operating-mode/index.js +9 -31
- package/dist/operating-mode/mode-env.d.ts +32 -54
- package/dist/operating-mode/mode-env.js +36 -58
- package/dist/operating-mode/types.d.ts +24 -72
- package/dist/operating-mode/types.js +1 -7
- package/dist/paths/branch-name.d.ts +30 -40
- package/dist/paths/branch-name.js +30 -40
- package/dist/paths/branch.d.ts +4 -18
- package/dist/paths/branch.js +6 -22
- package/dist/paths/index.d.ts +2 -13
- package/dist/paths/index.js +3 -23
- package/dist/paths/normalize-server.d.ts +3 -15
- package/dist/paths/normalize-server.js +3 -15
- package/dist/paths/normalize.d.ts +13 -33
- package/dist/paths/normalize.js +13 -33
- package/dist/paths/resolve.d.ts +4 -17
- package/dist/paths/resolve.js +4 -22
- package/dist/paths/types.d.ts +12 -34
- package/dist/paths/types.js +5 -7
- package/dist/paths/validation.d.ts +22 -119
- package/dist/paths/validation.js +30 -148
- package/dist/reference-resolver.d.ts +0 -13
- package/dist/reference-resolver.js +0 -18
- package/dist/resolve-canopy-user.d.ts +16 -18
- package/dist/resolve-canopy-user.js +17 -26
- package/dist/resource-generation.d.ts +16 -25
- package/dist/resource-generation.js +34 -97
- package/dist/schema/meta-loader.d.ts +2 -14
- package/dist/schema/meta-loader.js +15 -64
- package/dist/schema/resolver.d.ts +1 -4
- package/dist/schema/resolver.js +1 -6
- package/dist/schema/schema-store-types.d.ts +0 -12
- package/dist/schema/schema-store.d.ts +61 -138
- package/dist/schema/schema-store.js +85 -282
- package/dist/schema/types.d.ts +0 -4
- package/dist/server.d.ts +62 -93
- package/dist/server.js +63 -94
- package/dist/services.d.ts +23 -47
- package/dist/services.js +55 -98
- package/dist/settings-workspace.d.ts +17 -30
- package/dist/settings-workspace.js +51 -81
- package/dist/static/index.d.ts +26 -52
- package/dist/static/index.js +33 -67
- package/dist/{worker/task-queue.d.ts → task-queue/cms-task-queue.d.ts} +7 -9
- package/dist/task-queue/cms-task-queue.js +13 -0
- package/dist/task-queue/task-queue-config.d.ts +3 -0
- package/dist/{worker → task-queue}/task-queue-config.js +1 -6
- package/dist/task-queue/task-queue.d.ts +16 -22
- package/dist/task-queue/task-queue.js +20 -44
- package/dist/task-queue/types.d.ts +0 -1
- package/dist/task-queue/worker-status.d.ts +35 -0
- package/dist/task-queue/worker-status.js +40 -0
- package/dist/types.d.ts +40 -51
- package/dist/url-collision.d.ts +26 -40
- package/dist/url-collision.js +47 -63
- package/dist/url-exclusivity-fixtures.d.ts +15 -20
- package/dist/url-exclusivity-fixtures.js +14 -19
- package/dist/url-path-resolver.d.ts +8 -16
- package/dist/url-path-resolver.js +19 -29
- package/dist/user.d.ts +8 -21
- package/dist/user.js +10 -19
- package/dist/utils/async-mutex.js +4 -6
- package/dist/utils/atomic-write.d.ts +2 -11
- package/dist/utils/atomic-write.js +2 -11
- package/dist/utils/body-field.d.ts +8 -15
- package/dist/utils/body-field.js +8 -15
- package/dist/utils/content-serialize.d.ts +18 -24
- package/dist/utils/content-serialize.js +109 -160
- package/dist/utils/content-write-lock.d.ts +51 -106
- package/dist/utils/content-write-lock.js +66 -111
- package/dist/utils/debug.d.ts +7 -23
- package/dist/utils/debug.js +7 -23
- package/dist/utils/entry-url.d.ts +11 -23
- package/dist/utils/entry-url.js +11 -26
- package/dist/utils/error.d.ts +25 -90
- package/dist/utils/error.js +60 -147
- package/dist/utils/flatten-group-fields.d.ts +5 -7
- package/dist/utils/flatten-group-fields.js +5 -7
- package/dist/utils/format.d.ts +1 -5
- package/dist/utils/format.js +1 -5
- package/dist/utils/fs.d.ts +3 -4
- package/dist/utils/fs.js +3 -4
- package/dist/utils/git.d.ts +52 -83
- package/dist/utils/git.js +79 -125
- package/dist/utils/logger.d.ts +35 -50
- package/dist/utils/logger.js +35 -52
- package/dist/utils/provisioning-lock.d.ts +23 -35
- package/dist/utils/provisioning-lock.js +49 -69
- package/dist/utils/sanitize-href.d.ts +5 -10
- package/dist/utils/sanitize-href.js +8 -18
- package/dist/utils/title-field.d.ts +17 -20
- package/dist/utils/title-field.js +18 -27
- package/dist/utils/typed-filename.d.ts +20 -48
- package/dist/utils/typed-filename.js +25 -61
- package/dist/utils/url-prefix.d.ts +3 -3
- package/dist/utils/url-prefix.js +3 -3
- package/dist/validation/block-structural-keys.d.ts +16 -31
- package/dist/validation/block-structural-keys.js +19 -29
- package/dist/validation/deletion-checker.d.ts +0 -34
- package/dist/validation/deletion-checker.js +1 -43
- package/dist/validation/entry-link-validator.d.ts +6 -13
- package/dist/validation/entry-link-validator.js +4 -13
- package/dist/validation/entry-type-reference-validator.d.ts +13 -18
- package/dist/validation/entry-type-reference-validator.js +13 -18
- package/dist/validation/entry-validator.d.ts +13 -25
- package/dist/validation/entry-validator.js +15 -32
- package/dist/validation/field-traversal.d.ts +3 -30
- package/dist/validation/field-traversal.js +1 -32
- package/dist/validation/reference-validator.d.ts +5 -24
- package/dist/validation/reference-validator.js +5 -30
- package/dist/worker/cms-worker.d.ts +172 -232
- package/dist/worker/cms-worker.js +241 -333
- package/dist/worker/git-sync.d.ts +32 -133
- package/dist/worker/git-sync.js +129 -191
- package/dist/worker/github-auth.d.ts +13 -19
- package/dist/worker/github-auth.js +13 -19
- package/dist/worker/history-rewrite.d.ts +53 -66
- package/dist/worker/history-rewrite.js +54 -60
- package/dist/worker/log.d.ts +24 -41
- package/dist/worker/log.js +25 -42
- package/dist/worker/rebase.d.ts +20 -110
- package/dist/worker/rebase.js +279 -354
- package/dist/worker/task-runner.d.ts +32 -66
- package/dist/worker/task-runner.js +126 -162
- package/dist/worker/worker-context.d.ts +41 -81
- package/package.json +4 -4
- package/dist/cli/template-files/middleware-clerk.ts.template +0 -37
- package/dist/worker/task-queue-config.d.ts +0 -8
- package/dist/worker/task-queue.js +0 -19
- package/dist/worker/worker-status.d.ts +0 -47
- 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
|
-
*
|
|
8
|
-
*
|
|
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
|
-
*
|
|
15
|
-
*
|
|
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
|
-
*
|
|
40
|
-
* (`canopycms-settings-{deploymentName}`, default
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
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
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
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
|
|
67
|
-
*
|
|
68
|
-
*
|
|
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
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
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
|
|
82
|
-
*
|
|
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
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* start()
|
|
111
|
-
*
|
|
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'`:
|
|
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
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* DEFERRED out of the constructor deliberately,
|
|
128
|
-
*
|
|
129
|
-
* CmsWorker(...)`
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
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
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
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
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
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
|
|
175
|
-
*
|
|
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
|
|
180
|
-
*
|
|
157
|
+
* semantics. After a crash the dead holder's heartbeat expires within
|
|
158
|
+
* lockStaleMs and the next start succeeds.
|
|
181
159
|
*
|
|
182
|
-
* Staleness
|
|
183
|
-
*
|
|
184
|
-
*
|
|
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
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
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
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
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
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
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 --
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
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
|
|
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,
|
|
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
|
-
*
|
|
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
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
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
|
|
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
|
|
262
|
-
* `new CmsWorker(...)` lands BEFORE the only code that writes
|
|
263
|
-
* `lastFatalError` — start()'s catch.
|
|
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
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
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
|
-
*
|
|
287
|
-
*
|
|
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
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
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`
|
|
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
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
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
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
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
|
-
*
|
|
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
|
|
350
|
-
* that does not exist -- which
|
|
351
|
-
*
|
|
352
|
-
*
|
|
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
|
-
*
|
|
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
|
|
366
|
-
*
|
|
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
|
|
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
|
|
376
|
-
*
|
|
377
|
-
*
|
|
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
|
-
*
|
|
388
|
-
*
|
|
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
|
|
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
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
* so a
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
* `
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
* `
|
|
422
|
-
*
|
|
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;
|