@spacemade/ui 0.0.1
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 +705 -0
- package/app.sh +806 -0
- package/cmd.sh +152 -0
- package/docs/cms-quickstart.md +206 -0
- package/docs/gallery-quickstart.md +24 -0
- package/docs/gpu-marketplace-quickstart.md +27 -0
- package/docs/metaverse-quickstart.md +25 -0
- package/docs/migration-plan.md +41 -0
- package/docs/modules.md +34 -0
- package/docs/nft-quickstart.md +26 -0
- package/docs/simple-cms-quickstart.md +22 -0
- package/middleware.ts +77 -0
- package/next-env.d.ts +6 -0
- package/next.config.ts +39 -0
- package/package.json +92 -0
- package/public/android-chrome-192x192.png +0 -0
- package/public/android-chrome-512x512.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/images/default-profile/1.png +0 -0
- package/public/images/default-profile/2.png +0 -0
- package/public/images/default-profile/3.png +0 -0
- package/public/images/default-profile/4.png +0 -0
- package/public/images/default-profile/5.png +0 -0
- package/public/images/default-profile/6.png +0 -0
- package/public/images/default-profile/7.png +0 -0
- package/public/images/defaults/Login-Person-Icon-dark.svg +13 -0
- package/public/images/defaults/Login-Person-Icon.svg +16 -0
- package/public/images/defaults/default-avatar.png +0 -0
- package/public/images/defaults/image-not-available.jpg +0 -0
- package/public/images/icons/amazon-icon.jpg +0 -0
- package/public/images/icons/azure-icon.png +0 -0
- package/public/images/icons/google-icon.jpg +0 -0
- package/public/site.webmanifest +1 -0
- package/scripts/crud-scaffold/bin/crud-scaffold.mjs +23 -0
- package/scripts/crud-scaffold/src/api/index.mjs +666 -0
- package/scripts/crud-scaffold/src/app/patches.mjs +355 -0
- package/scripts/crud-scaffold/src/core/fields.mjs +165 -0
- package/scripts/crud-scaffold/src/core/utils.mjs +161 -0
- package/scripts/crud-scaffold/src/frontend/index.mjs +1078 -0
- package/scripts/crud-scaffold/src/generator.mjs +103 -0
- package/scripts/crud-scaffold/src/templates/.gitkeep +1 -0
- package/scripts/crud-scaffold/src/utils/generator-utils.mjs +35 -0
- package/scripts/defs/cms-definition.mjs +1393 -0
- package/scripts/defs/gallery-definition.mjs +171 -0
- package/scripts/defs/gpu-definition.mjs +174 -0
- package/scripts/defs/metaverse-definition.mjs +170 -0
- package/scripts/defs/nft-definition.mjs +191 -0
- package/scripts/defs/simple-cms-definition.mjs +141 -0
- package/scripts/generate-cms-install-system.mjs +4 -0
- package/scripts/generate-gallery-system.mjs +4 -0
- package/scripts/generate-gpu-marketplace-system.mjs +4 -0
- package/scripts/generate-metaverse-system.mjs +4 -0
- package/scripts/generate-nft-system.mjs +4 -0
- package/scripts/generate-simple-cms-system.mjs +4 -0
- package/scripts/link-core.mjs +72 -0
- package/scripts/spacemade.mjs +446 -0
- package/scripts/test-generate-app.mjs +60 -0
- package/src/components/Dashboard/DashboardList.tsx +70 -0
- package/src/components/Dashboard/dashboardLayout.tsx +57 -0
- package/src/components/admin/nav/AdminLeftNav.tsx +168 -0
- package/src/components/auth/AuthBootstrap.tsx +47 -0
- package/src/components/auth/auth-card-shell.tsx +23 -0
- package/src/components/auth/forgot-password-form-template.tsx +37 -0
- package/src/components/auth/form/ForgotForm.tsx +146 -0
- package/src/components/auth/form/ResetPasswordForm.tsx +122 -0
- package/src/components/auth/form/SignInForm.tsx +139 -0
- package/src/components/auth/form/SignUpForm.tsx +166 -0
- package/src/components/auth/form/UpdateForm.tsx +165 -0
- package/src/components/auth/login-form-template.tsx +45 -0
- package/src/components/billing/CardBrandIcon.tsx +126 -0
- package/src/components/billing/block/BillingDetailsCard.tsx +120 -0
- package/src/components/billing/block/BillingHistory.tsx +143 -0
- package/src/components/billing/block/PlanDetails.tsx +138 -0
- package/src/components/billing/modal/UpdateCardDetailsModal.tsx +451 -0
- package/src/components/billing/modal/UpdatePlanModal.tsx +194 -0
- package/src/components/category/modal/UpdateCategoryModal.tsx +170 -0
- package/src/components/category/table/CategoryTable.tsx +137 -0
- package/src/components/common/Icons/BrainCircuitIcon.tsx +14 -0
- package/src/components/common/Icons/MagnifyingGlassChartIcon.tsx +14 -0
- package/src/components/common/Icons/PeopleGroupIcon.tsx +14 -0
- package/src/components/common/Icons/ScrewdriverWrenchIcon.tsx +14 -0
- package/src/components/common/Icons/SendMessageIcon.tsx +15 -0
- package/src/components/common/Icons/ShareIcon.tsx +22 -0
- package/src/components/common/Icons/XTwitterIcon.tsx +14 -0
- package/src/components/common/Image/OptimizedImage.tsx +17 -0
- package/src/components/common/SettingsPanel.tsx +119 -0
- package/src/components/common/badge/Badge.tsx +69 -0
- package/src/components/common/blocks/BackgroundImageBlock.tsx +43 -0
- package/src/components/common/blocks/Carousel.tsx +59 -0
- package/src/components/common/blocks/CodeSnippet.tsx +46 -0
- package/src/components/common/blocks/InfinityScrollWrapper.tsx +43 -0
- package/src/components/common/blocks/SplitBlock.tsx +47 -0
- package/src/components/common/blocks/TopImageBlock.tsx +39 -0
- package/src/components/common/button/Button.tsx +49 -0
- package/src/components/common/button/ButtonWithActions.tsx +71 -0
- package/src/components/common/button/DropdownButton.tsx +61 -0
- package/src/components/common/button/ScrollDownArrow.tsx +23 -0
- package/src/components/common/button/SharerActionBox.tsx +248 -0
- package/src/components/common/button/UserButton.tsx +209 -0
- package/src/components/common/contact/ContactForm.tsx +214 -0
- package/src/components/common/cta/Cta.tsx +18 -0
- package/src/components/common/dialog/ConversationFullscreenModal.tsx +95 -0
- package/src/components/common/dialog/DeleteDialog.tsx +90 -0
- package/src/components/common/dialog/MobileFiltersDrawer.tsx +60 -0
- package/src/components/common/dialog/RenameDialog.tsx +128 -0
- package/src/components/common/faq/FAQSection.tsx +119 -0
- package/src/components/common/filters/NameSearch.tsx +87 -0
- package/src/components/common/footer/SmallFooter.tsx +62 -0
- package/src/components/common/forms/AdvanceAccordion.tsx +154 -0
- package/src/components/common/forms/CheckBox.tsx +29 -0
- package/src/components/common/forms/DateTimePicker.tsx +101 -0
- package/src/components/common/forms/Dropzone.tsx +278 -0
- package/src/components/common/forms/EmailTagInput.tsx +67 -0
- package/src/components/common/forms/FieldAssistantBar.tsx +32 -0
- package/src/components/common/forms/HTMLEditor.tsx +48 -0
- package/src/components/common/forms/IconPicker.tsx +129 -0
- package/src/components/common/forms/Input.tsx +362 -0
- package/src/components/common/forms/InputColor.tsx +36 -0
- package/src/components/common/forms/RadioInputs.tsx +62 -0
- package/src/components/common/forms/Select.tsx +214 -0
- package/src/components/common/forms/SimpleTagsInput.tsx +89 -0
- package/src/components/common/forms/TagInput.tsx +111 -0
- package/src/components/common/forms/Textarea.tsx +99 -0
- package/src/components/common/forms/ToggleButton.tsx +67 -0
- package/src/components/common/forms/UserInvitePicker.tsx +600 -0
- package/src/components/common/header/AppPageTitle.tsx +34 -0
- package/src/components/common/header/SubtitleAccordion.tsx +63 -0
- package/src/components/common/home/block/GetStarted.tsx +17 -0
- package/src/components/common/home/block/Hero.tsx +33 -0
- package/src/components/common/home/block/InstallShortcut.tsx +41 -0
- package/src/components/common/home/block/MarketplaceBlock.tsx +34 -0
- package/src/components/common/home/block/OriginStoryBanner.tsx +17 -0
- package/src/components/common/home/block/OsirusCTABlock.tsx +21 -0
- package/src/components/common/home/block/PromoFeatureSlider.tsx +260 -0
- package/src/components/common/layout/DetailHero.tsx +87 -0
- package/src/components/common/layout/SideNavLayout.tsx +1016 -0
- package/src/components/common/layout/account/AccountLayout.tsx +99 -0
- package/src/components/common/layout/admin/AdminLayout.tsx +17 -0
- package/src/components/common/layout/explore/ExploreLayout.tsx +23 -0
- package/src/components/common/layout/explore/ExploreLayoutContent.tsx +20 -0
- package/src/components/common/layout/explore/ExploreLayoutFilters.tsx +28 -0
- package/src/components/common/loading/LoadingScreen.tsx +86 -0
- package/src/components/common/loading/Spinner.tsx +12 -0
- package/src/components/common/state/InvalidInviteCard.tsx +32 -0
- package/src/components/common/table/TableFilter.tsx +205 -0
- package/src/components/common/table/TableHeader.tsx +33 -0
- package/src/components/common/table/TablePaging.tsx +190 -0
- package/src/components/common/table/TablePagingButton.tsx +64 -0
- package/src/components/common/table/TablePagingInput.tsx +79 -0
- package/src/components/common/useUrlSelectedModel.ts +7 -0
- package/src/components/docs/DocsSitePreviewPage.tsx +122 -0
- package/src/components/docs/block/DocsPageDetailBlock.tsx +333 -0
- package/src/components/docs/block/DocsSidebarTopContent.tsx +8 -0
- package/src/components/docs/block/DocsSitePagesBlock.tsx +81 -0
- package/src/components/docs/block/DocsSitesBlock.tsx +35 -0
- package/src/components/docs/modal/CreateDocsSiteModal.tsx +132 -0
- package/src/components/docs/table/DocsPagesTable.tsx +163 -0
- package/src/components/docs/table/DocsSitesTable.tsx +109 -0
- package/src/components/groups/block/GroupInitialAvatar.tsx +53 -0
- package/src/components/groups/grid/OrgGroupMembersGrid.tsx +253 -0
- package/src/components/groups/modal/AddGroupModal.tsx +138 -0
- package/src/components/groups/modal/OrgGroupMembersModal.tsx +171 -0
- package/src/components/groups/modal/OrgGroupPermissionsModal.tsx +184 -0
- package/src/components/groups/table/OrgGroupsTable.tsx +470 -0
- package/src/components/head/DefaultMetadata.tsx +135 -0
- package/src/components/head/PageSeo.tsx +198 -0
- package/src/components/hoc/WithAuth.tsx +82 -0
- package/src/components/hoc/WithCustomerIO.tsx +48 -0
- package/src/components/hoc/WithGTM.tsx +31 -0
- package/src/components/hoc/WithGlobalContext.tsx +30 -0
- package/src/components/hoc/WithReCaptcha.tsx +31 -0
- package/src/components/hoc/WithStripe.tsx +68 -0
- package/src/components/layout/SidebarSizer.tsx +63 -0
- package/src/components/layout/app-left-nav.tsx +31 -0
- package/src/components/layout/app-main-layout.tsx +39 -0
- package/src/components/layout/site-footer.tsx +11 -0
- package/src/components/layout/site-header.tsx +19 -0
- package/src/components/marketplace/card/ProductCard.tsx +178 -0
- package/src/components/media/blocks/MediaAttachmentsList.tsx +79 -0
- package/src/components/media/blocks/MediaDetails.tsx +139 -0
- package/src/components/media/blocks/MediaGrid.tsx +245 -0
- package/src/components/media/form/MediaMiniForm.tsx +105 -0
- package/src/components/media/form/UpdateMediaForm.tsx +209 -0
- package/src/components/media/items/CircleMediaPicker.tsx +76 -0
- package/src/components/media/items/MediaAttachmentLinks.tsx +98 -0
- package/src/components/media/items/MediaDocumentPreview.tsx +43 -0
- package/src/components/media/items/MediaFileIcon.tsx +30 -0
- package/src/components/media/items/MediaPickerBox.tsx +94 -0
- package/src/components/media/items/MediaPickerButton.tsx +37 -0
- package/src/components/media/items/MediaSourcePreview.tsx +35 -0
- package/src/components/media/modal/AddMediaModal.tsx +237 -0
- package/src/components/media/modal/MediaAttachmentsModal.tsx +113 -0
- package/src/components/media/modal/MediaBulkDeleteWarningModal.tsx +142 -0
- package/src/components/media/modal/MediaDeleteWarningModal.tsx +98 -0
- package/src/components/media/modal/MediaPickerModal.tsx +201 -0
- package/src/components/media/table/MediaTable.tsx +340 -0
- package/src/components/media/table/MediaTableActions.tsx +130 -0
- package/src/components/media/table/MediaTableFilter.tsx +163 -0
- package/src/components/modules/module-card-grid.tsx +19 -0
- package/src/components/modules/module-page.tsx +27 -0
- package/src/components/modules/resource-page.tsx +15 -0
- package/src/components/nav/AdminMobileMenu.tsx +228 -0
- package/src/components/nav/AppTopNav.tsx +53 -0
- package/src/components/nav/MobileMenu.tsx +132 -0
- package/src/components/nav/TopNav.tsx +137 -0
- package/src/components/openapi/DeleteTokenModal.tsx +72 -0
- package/src/components/openapi/actions/ApiTokenActionsMenu.tsx +141 -0
- package/src/components/openapi/actions/ApiTokenCreateModal.tsx +107 -0
- package/src/components/openapi/actions/ApiTokenEditModal.tsx +168 -0
- package/src/components/orgs/OrgCreateModal.tsx +126 -0
- package/src/components/orgs/OrgJumpRedirect.tsx +150 -0
- package/src/components/page/SiteContentPage.tsx +129 -0
- package/src/components/post/accordion/FilterPostCategoriesAccordion.tsx +126 -0
- package/src/components/post/block/FeaturedProductCard.tsx +31 -0
- package/src/components/post/block/FeaturedProviderCard.tsx +51 -0
- package/src/components/post/block/InTheNews.tsx +77 -0
- package/src/components/post/block/PostCardsGrid.tsx +56 -0
- package/src/components/post/block/PostContent.tsx +128 -0
- package/src/components/post/block/PostDetailPage.tsx +95 -0
- package/src/components/post/block/PostList.tsx +111 -0
- package/src/components/post/block/PostNextAndPrevButtons.tsx +78 -0
- package/src/components/post/block/PostPeopleAlsoReadBlock.tsx +69 -0
- package/src/components/post/block/PostRelatedCards.tsx +43 -0
- package/src/components/post/card/FeaturedPostCard.tsx +107 -0
- package/src/components/post/card/InTheNewsCard.tsx +162 -0
- package/src/components/post/card/PostCard.tsx +125 -0
- package/src/components/post/card/RelatedPostCard.tsx +115 -0
- package/src/components/post/form/UpdatePostForm.tsx +639 -0
- package/src/components/post/modal/CreatePostModal.tsx +115 -0
- package/src/components/post/modal/PreviewPostModal.tsx +82 -0
- package/src/components/post/nav/BlogCategoriesSideNav.tsx +55 -0
- package/src/components/post/table/PostsTable.tsx +284 -0
- package/src/components/pricing/block/AddOnRow.tsx +78 -0
- package/src/components/pricing/block/CompletePurchase.tsx +546 -0
- package/src/components/pricing/block/PlanPicker.tsx +76 -0
- package/src/components/pricing/card/PricingCard.tsx +291 -0
- package/src/components/pricing/form/AddBillingInformationForm.tsx +212 -0
- package/src/components/pricing/form/AddPaymentMethodForm.tsx +252 -0
- package/src/components/pricing/form/CouponCodeForm.tsx +118 -0
- package/src/components/pricing/form/StripePaymentForm.tsx +106 -0
- package/src/components/product/block/ProductScreenshot.tsx +22 -0
- package/src/components/product/block/ProductScreenshotPreview.tsx +46 -0
- package/src/components/product/button/MediaScreenshotPicker.tsx +72 -0
- package/src/components/product/form/UpdateProductForm.tsx +718 -0
- package/src/components/product/modal/CreateProductModal.tsx +128 -0
- package/src/components/product/modal/UpdateProductCouponModal.tsx +227 -0
- package/src/components/product/modal/UpdateProductPlanModal.tsx +291 -0
- package/src/components/product/modal/UpdateProductVersionModal.tsx +236 -0
- package/src/components/product/table/ProductCouponsTable.tsx +100 -0
- package/src/components/product/table/ProductPlansTable.tsx +118 -0
- package/src/components/product/table/ProductVersionsAdminTable.tsx +103 -0
- package/src/components/product/table/ProductVersionsTable.tsx +111 -0
- package/src/components/product/table/ProductsTable.tsx +133 -0
- package/src/components/projects/ProjectFilesCard.tsx +134 -0
- package/src/components/projects/ProjectItemOptionButton.tsx +112 -0
- package/src/components/projects/ProjectPickerNav.tsx +440 -0
- package/src/components/projects/ProjectQuickCreateModal.tsx +159 -0
- package/src/components/projects/ProjectSidebarList.tsx +183 -0
- package/src/components/projects/actions/ProjectActionsMenu.tsx +77 -0
- package/src/components/projects/actions/ProjectCreateModal.tsx +577 -0
- package/src/components/projects/actions/ProjectEditModal.tsx +345 -0
- package/src/components/projects/actions/ProjectFileGrid.tsx +153 -0
- package/src/components/projects/actions/ProjectFilesModal.tsx +259 -0
- package/src/components/projects/actions/ProjectFilesPicker.tsx +31 -0
- package/src/components/projects/actions/ProjectFilesUploadModal.tsx +181 -0
- package/src/components/projects/actions/ProjectInstructions.tsx +160 -0
- package/src/components/projects/actions/RenameProjectModal.tsx +120 -0
- package/src/components/projects/actions/index.tsx +98 -0
- package/src/components/projects/block/HeaderProjectImagePicker.tsx +52 -0
- package/src/components/projects/permission/ProjectPermissionInviteModal.tsx +181 -0
- package/src/components/projects/permission/ProjectUserPermission.tsx +170 -0
- package/src/components/projects/postByCategory.tsx +118 -0
- package/src/components/projects/projectFileHistory.tsx +48 -0
- package/src/components/projects/table/ProjectTable.tsx +365 -0
- package/src/components/provider/BuildspecForm.tsx +288 -0
- package/src/components/provider/CreateProviderModal.tsx +210 -0
- package/src/components/provider/FeaturedProviders.tsx +137 -0
- package/src/components/provider/ProviderConnectModal.tsx +324 -0
- package/src/components/provider/form/UpdateProviderForm.tsx +449 -0
- package/src/components/provider/table/ProvidersTable.tsx +144 -0
- package/src/components/providers/ProviderFeaturesSideNav.tsx +52 -0
- package/src/components/settings/SettingsLayout.tsx +14 -0
- package/src/components/settings/SettingsSidebarNav.tsx +53 -0
- package/src/components/settings/settingsNav.ts +96 -0
- package/src/components/site/modal/UpdateSiteModal.tsx +134 -0
- package/src/components/site/table/SiteTable.tsx +198 -0
- package/src/components/starter/list-panel.tsx +12 -0
- package/src/components/starter/starter-overview.tsx +32 -0
- package/src/components/starter/stats-grid.tsx +20 -0
- package/src/components/storage/VectorStoreFileDeleteButton.tsx +71 -0
- package/src/components/storage/actions/VectorStoreActionsMenu.tsx +70 -0
- package/src/components/storage/actions/VectorStoreEditModal.tsx +220 -0
- package/src/components/storage/actions/VectorStoreFileActions.tsx +61 -0
- package/src/components/storage/actions/index.tsx +76 -0
- package/src/components/storage/addStorageModal.tsx +552 -0
- package/src/components/storage/table/vectorStoreTable.tsx +461 -0
- package/src/components/storage/vectorFilesModal.tsx +209 -0
- package/src/components/storage/vectorStoreFileGrid.tsx +384 -0
- package/src/components/tag/modal/UpdateTagModal.tsx +192 -0
- package/src/components/tag/table/TagTable.tsx +138 -0
- package/src/components/user/block/BadgesBlock.tsx +26 -0
- package/src/components/user/form/ChangePasswordForm.tsx +119 -0
- package/src/components/user/form/ProfileForm.tsx +168 -0
- package/src/components/user/grid/UserGrid.tsx +475 -0
- package/src/components/user/modal/AddUserModal.tsx +165 -0
- package/src/components/user/modal/UpdateUserDetailsModal.tsx +319 -0
- package/src/components/user/modal/UpgradeUserLimitModal.tsx +123 -0
- package/src/components/user/modal/UserPermissionsModal.tsx +251 -0
- package/src/components/user/table/UserTable.tsx +202 -0
- package/src/config/app.ts +16 -0
- package/src/config/modules.ts +100 -0
- package/src/config/navigation.ts +28 -0
- package/src/config/runtime.ts +3 -0
- package/src/context/CheckoutContext.tsx +123 -0
- package/src/context/ProjectContext.tsx +123 -0
- package/src/context/RouterContext.tsx +127 -0
- package/src/context/UIContext.tsx +47 -0
- package/src/context/UserAuthContext.tsx +26 -0
- package/src/context/VectorStoreContext.tsx +51 -0
- package/src/context/index.ts +2 -0
- package/src/data/bootstrap-icons.json +2080 -0
- package/src/data/bootstrap.ts +196 -0
- package/src/data/bootstrapIcons.ts +28 -0
- package/src/enum/AppEnvironments.ts +4 -0
- package/src/enum/HTTPErrorStatus.ts +10 -0
- package/src/helpers/api/index.ts +123 -0
- package/src/helpers/constants/index.ts +4 -0
- package/src/helpers/constants/messages.ts +1 -0
- package/src/helpers/constants/regex.ts +10 -0
- package/src/helpers/constants/stripe.ts +1 -0
- package/src/helpers/constants/system-agent.ts +12 -0
- package/src/helpers/data-transform/bytesToSize.ts +8 -0
- package/src/helpers/data-transform/dropzone.ts +116 -0
- package/src/helpers/data-transform/filterUtils.ts +21 -0
- package/src/helpers/data-transform/index.ts +4 -0
- package/src/helpers/data-transform/operations.ts +3 -0
- package/src/helpers/data-transform/paging.ts +24 -0
- package/src/helpers/data-transform/stringCaseTransform.ts +34 -0
- package/src/helpers/date/index.ts +149 -0
- package/src/helpers/error/formErrorHandler.tsx +38 -0
- package/src/helpers/images/assets.ts +32 -0
- package/src/helpers/images/defaultProfileImage.ts +21 -0
- package/src/helpers/images/fileType.ts +123 -0
- package/src/helpers/images/index.ts +3 -0
- package/src/helpers/navigation/routeScroll.ts +29 -0
- package/src/helpers/pageScreenshot.ts +176 -0
- package/src/helpers/permissions/index.ts +292 -0
- package/src/helpers/providers/providerFeatures.ts +29 -0
- package/src/helpers/sharer/index.ts +44 -0
- package/src/helpers/sitemap/sitemap-utils.ts +50 -0
- package/src/helpers/slugUtils/index.ts +39 -0
- package/src/helpers/sonicVoices.ts +22 -0
- package/src/helpers/string/index.ts +93 -0
- package/src/helpers/theme/colors.ts +27 -0
- package/src/helpers/types/api.ts +22 -0
- package/src/helpers/types/customer-io.ts +47 -0
- package/src/helpers/types/data-layer.ts +25 -0
- package/src/helpers/types/index.ts +4 -0
- package/src/helpers/types/nav.ts +13 -0
- package/src/helpers/types/page-props.ts +31 -0
- package/src/helpers/types/select-option.ts +4 -0
- package/src/helpers/types/utils.ts +7 -0
- package/src/helpers/url/index.ts +26 -0
- package/src/hooks/auth/useAccountStore.ts +69 -0
- package/src/hooks/auth/useAuthStore.ts +162 -0
- package/src/hooks/category/useCategoryStore.ts +71 -0
- package/src/hooks/index.ts +17 -0
- package/src/hooks/media/useMediaStore.ts +46 -0
- package/src/hooks/post/usePostStore.ts +64 -0
- package/src/hooks/post/usePostUtils.ts +27 -0
- package/src/hooks/product/useProductPlanStore.ts +73 -0
- package/src/hooks/product/useProductStore.ts +64 -0
- package/src/hooks/product/useProductVersionStore.ts +57 -0
- package/src/hooks/site/useSiteStore.ts +53 -0
- package/src/hooks/tag/useTagStore.ts +65 -0
- package/src/hooks/utils/useAutosizeTextArea.ts +20 -0
- package/src/hooks/utils/useCountries.ts +25 -0
- package/src/hooks/utils/useGA4DataLayer.ts +25 -0
- package/src/hooks/utils/useNavOptions.ts +241 -0
- package/src/hooks/utils/useSearchAndFilterCommon.ts +78 -0
- package/src/hooks/utils/useTrackingEvents.ts +65 -0
- package/src/lib/app-paths.ts +19 -0
- package/src/lib/auth.ts +42 -0
- package/src/lib/next-router.ts +164 -0
- package/src/lib/routes.ts +36 -0
- package/src/lib/security.ts +19 -0
- package/src/pages/404.tsx +104 -0
- package/src/pages/500.tsx +26 -0
- package/src/pages/_app.tsx +87 -0
- package/src/pages/_document.tsx +26 -0
- package/src/pages/account/verify.tsx +178 -0
- package/src/pages/admin/activity/[activityId].tsx +77 -0
- package/src/pages/admin/activity/bans.tsx +197 -0
- package/src/pages/admin/activity/index.tsx +207 -0
- package/src/pages/admin/activity/settings.tsx +189 -0
- package/src/pages/admin/categories/index.tsx +61 -0
- package/src/pages/admin/coupons/index.tsx +38 -0
- package/src/pages/admin/entitlements/index.tsx +646 -0
- package/src/pages/admin/index.tsx +65 -0
- package/src/pages/admin/media/[id]/index.tsx +55 -0
- package/src/pages/admin/media/index.tsx +62 -0
- package/src/pages/admin/orgs/[orgId]/[name].tsx +1 -0
- package/src/pages/admin/orgs/index.tsx +256 -0
- package/src/pages/admin/plans/index.tsx +26 -0
- package/src/pages/admin/posts/[id].tsx +80 -0
- package/src/pages/admin/posts/index.tsx +63 -0
- package/src/pages/admin/products/[id].tsx +71 -0
- package/src/pages/admin/products/index.tsx +62 -0
- package/src/pages/admin/profile/index.tsx +26 -0
- package/src/pages/admin/providers/[id].tsx +77 -0
- package/src/pages/admin/providers/index.tsx +63 -0
- package/src/pages/admin/tags/index.tsx +58 -0
- package/src/pages/admin/users/[userId]/[name].tsx +1 -0
- package/src/pages/admin/users/index.tsx +295 -0
- package/src/pages/admin/versions/[id].tsx +211 -0
- package/src/pages/admin/versions/index.tsx +25 -0
- package/src/pages/blog/[postSlug].tsx +106 -0
- package/src/pages/blog/c/[categorySlug]/index.tsx +126 -0
- package/src/pages/blog/index.tsx +37 -0
- package/src/pages/cart/[productPlanSlug].tsx +631 -0
- package/src/pages/checkout/[productPlanSlug].tsx +368 -0
- package/src/pages/docs/index.tsx +24 -0
- package/src/pages/docs/sites/[siteId]/[siteName]/index.tsx +67 -0
- package/src/pages/docs/sites/[siteId]/[siteName]/pages/[pagesId].tsx +79 -0
- package/src/pages/docs/sites/[siteId]/[siteName]/pages/index.tsx +67 -0
- package/src/pages/docs/sites/[siteId]/[siteName]/preview/[[...slug]].tsx +7 -0
- package/src/pages/forgot.tsx +46 -0
- package/src/pages/groups/[groupId]/[name].tsx +337 -0
- package/src/pages/groups/index.tsx +62 -0
- package/src/pages/healthcheck.tsx +7 -0
- package/src/pages/index.tsx +309 -0
- package/src/pages/login.tsx +75 -0
- package/src/pages/marketplace/[slug].tsx +171 -0
- package/src/pages/marketplace/index.tsx +92 -0
- package/src/pages/openapi/index.tsx +77 -0
- package/src/pages/openapi/tokens/index.tsx +128 -0
- package/src/pages/org/[name]/settings.tsx +14 -0
- package/src/pages/org/[name]/token/index.tsx +109 -0
- package/src/pages/pricing.tsx +242 -0
- package/src/pages/projects/[projectId]/[name]/files/index.tsx +121 -0
- package/src/pages/projects/[projectId]/[name]/index.tsx +305 -0
- package/src/pages/projects/[projectId]/[name]/permission/index.tsx +143 -0
- package/src/pages/projects/[projectId]/token/index.tsx +120 -0
- package/src/pages/projects/index.tsx +129 -0
- package/src/pages/providers/[name].tsx +512 -0
- package/src/pages/providers/index.tsx +472 -0
- package/src/pages/reset.tsx +69 -0
- package/src/pages/settings/billing/index.tsx +41 -0
- package/src/pages/settings/index.tsx +133 -0
- package/src/pages/settings/organizations/[orgId]/invite/index.tsx +162 -0
- package/src/pages/settings/organizations/[orgId]/settings/index.tsx +98 -0
- package/src/pages/settings/organizations/[orgId]/token/index.tsx +109 -0
- package/src/pages/settings/organizations/index.tsx +148 -0
- package/src/pages/settings/organizations/new/index.tsx +252 -0
- package/src/pages/settings/profile/change-password.tsx +26 -0
- package/src/pages/settings/profile/index.tsx +103 -0
- package/src/pages/settings/profile/org-profile.tsx +127 -0
- package/src/pages/settings/profile/profile.tsx +26 -0
- package/src/pages/settings/sites/index.tsx +85 -0
- package/src/pages/settings/subscriptions/index.tsx +76 -0
- package/src/pages/settings/tokens/index.tsx +149 -0
- package/src/pages/signup/index.tsx +83 -0
- package/src/pages/signup/verify.tsx +138 -0
- package/src/pages/sites/[siteId]/[siteName]/[[...slug]].tsx +103 -0
- package/src/pages/sites/[siteId]/[siteName]/pages/[pageId].tsx +243 -0
- package/src/pages/sites/[siteId]/[siteName]/pages/index.tsx +140 -0
- package/src/pages/sites/host/[[...slug]].tsx +75 -0
- package/src/pages/storage/[vectorStoreId]/[name].tsx +653 -0
- package/src/pages/storage/index.tsx +526 -0
- package/src/pages/update/index.tsx +109 -0
- package/src/pages/update/verify.tsx +121 -0
- package/src/pages/users/[userId]/[name].tsx +791 -0
- package/src/pages/users/index.tsx +152 -0
- package/src/sass/app.scss +59 -0
- package/src/sass/base/_animations.scss +70 -0
- package/src/sass/base/_borders.scss +78 -0
- package/src/sass/base/_custom-backgrounds.scss +107 -0
- package/src/sass/base/_interactions.scss +35 -0
- package/src/sass/base/_main.scss +239 -0
- package/src/sass/base/_positions.scss +111 -0
- package/src/sass/base/_sizes.scss +120 -0
- package/src/sass/base/_typography.scss +184 -0
- package/src/sass/components/_accordion.scss +63 -0
- package/src/sass/components/_ad.scss +44 -0
- package/src/sass/components/_avatar.scss +18 -0
- package/src/sass/components/_badge.scss +6 -0
- package/src/sass/components/_button.scss +53 -0
- package/src/sass/components/_checkbox.scss +52 -0
- package/src/sass/components/_circle-media-picker.scss +32 -0
- package/src/sass/components/_code-snipped.scss +50 -0
- package/src/sass/components/_date-time-picker.scss +796 -0
- package/src/sass/components/_dialog.scss +27 -0
- package/src/sass/components/_gradients.scss +7 -0
- package/src/sass/components/_group-detail.scss +620 -0
- package/src/sass/components/_input.scss +567 -0
- package/src/sass/components/_menu.scss +31 -0
- package/src/sass/components/_modal.scss +273 -0
- package/src/sass/components/_popover.scss +29 -0
- package/src/sass/components/_rich-content.scss +531 -0
- package/src/sass/components/_spinner.scss +71 -0
- package/src/sass/components/_swagger.scss +7 -0
- package/src/sass/components/_swiper.scss +16 -0
- package/src/sass/components/_switch.scss +46 -0
- package/src/sass/components/_table.scss +39 -0
- package/src/sass/components/_tabs.scss +38 -0
- package/src/sass/components/_tag-input.scss +28 -0
- package/src/sass/components/_toast.scss +26 -0
- package/src/sass/components/_tooltip.scss +31 -0
- package/src/sass/layout/_base.scss +937 -0
- package/src/sass/layout/_footer.scss +148 -0
- package/src/sass/layout/_hero.scss +33 -0
- package/src/sass/layout/_nav.scss +77 -0
- package/src/sass/layout/_news-card-grid.scss +507 -0
- package/src/sass/utilities/_mixins.scss +21 -0
- package/src/sass/utilities/_sizes.scss +137 -0
- package/src/sass/utilities/_utils.scss +23 -0
- package/src/sass/utilities/_variables.scss +115 -0
- package/src/store/hooks.ts +5 -0
- package/src/store/hydrate.ts +1 -0
- package/src/store/model/activity.model.ts +52 -0
- package/src/store/model/address.model.ts +9 -0
- package/src/store/model/apiToken.model.ts +26 -0
- package/src/store/model/category.model.ts +20 -0
- package/src/store/model/entityStatus.model.ts +25 -0
- package/src/store/model/index.ts +25 -0
- package/src/store/model/invoice.model.ts +37 -0
- package/src/store/model/media.model.ts +70 -0
- package/src/store/model/org-group-permission.model.ts +16 -0
- package/src/store/model/org-group.model.ts +14 -0
- package/src/store/model/org-membership.model.ts +23 -0
- package/src/store/model/org.model.ts +13 -0
- package/src/store/model/page.model.ts +33 -0
- package/src/store/model/post.model.ts +60 -0
- package/src/store/model/product-coupon.model.ts +42 -0
- package/src/store/model/product-feature-entitlement.ts +40 -0
- package/src/store/model/product-feature.ts +29 -0
- package/src/store/model/product-plan.model.ts +120 -0
- package/src/store/model/product-version.model.ts +24 -0
- package/src/store/model/product.model.ts +91 -0
- package/src/store/model/project-file.model.ts +18 -0
- package/src/store/model/project-user-permission.model.ts +41 -0
- package/src/store/model/project.model.ts +48 -0
- package/src/store/model/provider.model.ts +118 -0
- package/src/store/model/purchase.model.ts +19 -0
- package/src/store/model/site-crawl-job.model.ts +31 -0
- package/src/store/model/site-page.model.ts +37 -0
- package/src/store/model/site.model.ts +15 -0
- package/src/store/model/subscription.model.ts +60 -0
- package/src/store/model/tag.model.ts +18 -0
- package/src/store/model/user-permission.model.ts +21 -0
- package/src/store/model/user.model.ts +97 -0
- package/src/store/model/vector-store-file.model.ts +40 -0
- package/src/store/model/vector-store.model.ts +41 -0
- package/src/store/slice/api/accountApiSlice.ts +92 -0
- package/src/store/slice/api/accountSlice.ts +57 -0
- package/src/store/slice/api/activityApiSlice.ts +218 -0
- package/src/store/slice/api/apiTokenSlice.ts +153 -0
- package/src/store/slice/api/authApiSlice.ts +220 -0
- package/src/store/slice/api/base-domain-api.ts +19 -0
- package/src/store/slice/api/billingUnitTypesApiSlice.ts +45 -0
- package/src/store/slice/api/bootstrapIconApiSlice.ts +36 -0
- package/src/store/slice/api/categoriesApiSlice.ts +101 -0
- package/src/store/slice/api/fontawesomeApiSlice.ts +43 -0
- package/src/store/slice/api/invoiceApiSlice.ts +37 -0
- package/src/store/slice/api/leadApiSlice.ts +48 -0
- package/src/store/slice/api/mediaApiSlice.ts +276 -0
- package/src/store/slice/api/orgApiSlice.ts +185 -0
- package/src/store/slice/api/orgGroupApiSlice.ts +146 -0
- package/src/store/slice/api/pageApiSlice.ts +111 -0
- package/src/store/slice/api/paymentApiSlice.ts +27 -0
- package/src/store/slice/api/postApiSlice.ts +369 -0
- package/src/store/slice/api/productCouponsApiSlice.ts +101 -0
- package/src/store/slice/api/productFeaturesApiSlice.ts +93 -0
- package/src/store/slice/api/productPlansApiSlice.ts +142 -0
- package/src/store/slice/api/productSubscriptionsApiSlice.ts +156 -0
- package/src/store/slice/api/productVersionsApiSlice.ts +116 -0
- package/src/store/slice/api/productsApiSlice.ts +169 -0
- package/src/store/slice/api/projectApiSlice.ts +135 -0
- package/src/store/slice/api/projectFileApiSlice.ts +152 -0
- package/src/store/slice/api/projectUserPermissionApiSlice.ts +153 -0
- package/src/store/slice/api/providerApiSlice.ts +259 -0
- package/src/store/slice/api/providerSettingApiSlice.ts +174 -0
- package/src/store/slice/api/siteApiSlice.ts +93 -0
- package/src/store/slice/api/stripeApiSlice.ts +114 -0
- package/src/store/slice/api/tagsApiSlice.ts +96 -0
- package/src/store/slice/api/userApiSlice.ts +305 -0
- package/src/store/slice/api/vectorStoreApiSlice.ts +119 -0
- package/src/store/slice/api/vectorStoreFileApiSlice.ts +127 -0
- package/src/store/store.ts +130 -0
- package/src/types/bootstrap.ts +30 -0
- package/tsconfig.json +103 -0
|
@@ -0,0 +1,1393 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCrudScaffoldDefinition,
|
|
3
|
+
field,
|
|
4
|
+
} from '../crud-scaffold/src/generator.mjs'
|
|
5
|
+
|
|
6
|
+
const status = {
|
|
7
|
+
deployment: ['draft', 'provisioning', 'active', 'paused', 'failed', 'deleted'],
|
|
8
|
+
jobType: ['deploy', 'update', 'backup', 'delete', 'clone'],
|
|
9
|
+
job: ['queued', 'running', 'completed', 'failed'],
|
|
10
|
+
backupType: ['manual', 'scheduled'],
|
|
11
|
+
backup: ['pending', 'completed', 'failed'],
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const deploymentLaunchServiceSource = `import type { NextApiRequest } from 'next'
|
|
15
|
+
import { Op } from 'sequelize'
|
|
16
|
+
import { Deployment } from '@lib/cms/models'
|
|
17
|
+
import {
|
|
18
|
+
Product,
|
|
19
|
+
ProductPlan,
|
|
20
|
+
ProductVersion,
|
|
21
|
+
Provider,
|
|
22
|
+
ProviderSetting,
|
|
23
|
+
StripeSubscriptionStatus,
|
|
24
|
+
Subscription,
|
|
25
|
+
} from '@lib/models'
|
|
26
|
+
import {
|
|
27
|
+
requireActiveOrgId,
|
|
28
|
+
type RequestWithOrg,
|
|
29
|
+
} from '@lib/middleware/with-active-org'
|
|
30
|
+
import { ProductVersionResourceSpecService } from '@lib/service/product/product-version-resource-spec.service'
|
|
31
|
+
|
|
32
|
+
const ACTIVE_STATUSES = [
|
|
33
|
+
StripeSubscriptionStatus.Trialing,
|
|
34
|
+
StripeSubscriptionStatus.Active,
|
|
35
|
+
StripeSubscriptionStatus.PastDue,
|
|
36
|
+
StripeSubscriptionStatus.Unpaid,
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
type DeploymentOption = {
|
|
40
|
+
key: string
|
|
41
|
+
label: string
|
|
42
|
+
providerId: string | null
|
|
43
|
+
providerSettingId: string
|
|
44
|
+
providerSettingName: string
|
|
45
|
+
providerKey: string | null
|
|
46
|
+
providerLabel: string | null
|
|
47
|
+
specFormat: string | null
|
|
48
|
+
resourceUrl: string | null
|
|
49
|
+
isDefault: boolean
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type LaunchableProduct = {
|
|
53
|
+
product: Product
|
|
54
|
+
productPlan: ProductPlan
|
|
55
|
+
productVersion: ProductVersion
|
|
56
|
+
subscriptionId: string
|
|
57
|
+
deploymentOptions: DeploymentOption[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function buildDeploymentOptions(
|
|
61
|
+
productVersion: ProductVersion,
|
|
62
|
+
providerSettings: ProviderSetting[]
|
|
63
|
+
): DeploymentOption[] {
|
|
64
|
+
return providerSettings
|
|
65
|
+
.map((setting) => ({
|
|
66
|
+
setting,
|
|
67
|
+
provider: setting.provider instanceof Provider ? setting.provider : null,
|
|
68
|
+
}))
|
|
69
|
+
.filter((item): item is { setting: ProviderSetting; provider: Provider } => item.provider instanceof Provider)
|
|
70
|
+
.map(({ setting, provider }) => ({
|
|
71
|
+
setting,
|
|
72
|
+
provider,
|
|
73
|
+
providerSpec: ProductVersionResourceSpecService.getProviderSpec(productVersion, provider.key),
|
|
74
|
+
}))
|
|
75
|
+
.filter(({ providerSpec }) => providerSpec || !productVersion.resource_spec)
|
|
76
|
+
.map(({ setting, provider, providerSpec }) => ({
|
|
77
|
+
key: [provider.id, setting.id].join(':'),
|
|
78
|
+
label: [provider.label, setting.name].filter(Boolean).join(' - '),
|
|
79
|
+
providerId: provider.id,
|
|
80
|
+
providerSettingId: setting.id,
|
|
81
|
+
providerSettingName: setting.name,
|
|
82
|
+
providerKey: provider.key,
|
|
83
|
+
providerLabel: provider.label,
|
|
84
|
+
specFormat: typeof providerSpec?.specFormat === 'string' ? providerSpec.specFormat : null,
|
|
85
|
+
resourceUrl: typeof providerSpec?.resourceUrl === 'string' ? providerSpec.resourceUrl : productVersion.resource_url,
|
|
86
|
+
isDefault: !!setting.is_default,
|
|
87
|
+
}))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function deploymentOptionKey(
|
|
91
|
+
subscriptionId: string | null,
|
|
92
|
+
productPlanId: string | null,
|
|
93
|
+
productVersionId: string | null,
|
|
94
|
+
providerId: string | null,
|
|
95
|
+
providerSettingId: string | null
|
|
96
|
+
) {
|
|
97
|
+
return [
|
|
98
|
+
subscriptionId || '',
|
|
99
|
+
productPlanId || '',
|
|
100
|
+
productVersionId || '',
|
|
101
|
+
providerId || '',
|
|
102
|
+
providerSettingId || '',
|
|
103
|
+
].join(':')
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export class DeploymentLaunchService {
|
|
107
|
+
public async listLaunchableProducts(req: NextApiRequest) {
|
|
108
|
+
const orgId = requireActiveOrgId(req as RequestWithOrg)
|
|
109
|
+
|
|
110
|
+
const subscriptions = await Subscription.findAll({
|
|
111
|
+
where: {
|
|
112
|
+
org_id: orgId,
|
|
113
|
+
status: { [Op.in]: ACTIVE_STATUSES as any },
|
|
114
|
+
},
|
|
115
|
+
include: [
|
|
116
|
+
{
|
|
117
|
+
model: ProductPlan,
|
|
118
|
+
as: 'productPlans',
|
|
119
|
+
include: [
|
|
120
|
+
{
|
|
121
|
+
model: Product,
|
|
122
|
+
as: 'product',
|
|
123
|
+
include: [
|
|
124
|
+
{
|
|
125
|
+
model: ProductVersion,
|
|
126
|
+
as: 'versions',
|
|
127
|
+
required: false,
|
|
128
|
+
where: { version_status: 'active' },
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
order: [
|
|
136
|
+
['created_at', 'DESC'],
|
|
137
|
+
[{ model: ProductPlan, as: 'productPlans' }, { model: Product, as: 'product' }, { model: ProductVersion, as: 'versions' }, 'rank', 'ASC'],
|
|
138
|
+
[{ model: ProductPlan, as: 'productPlans' }, { model: Product, as: 'product' }, { model: ProductVersion, as: 'versions' }, 'name', 'DESC'],
|
|
139
|
+
],
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
const subscribedVersions = subscriptions.flatMap((subscription) => {
|
|
143
|
+
const plans = Array.isArray(subscription.productPlans) ? subscription.productPlans : []
|
|
144
|
+
|
|
145
|
+
return plans
|
|
146
|
+
.filter((plan) => plan.product instanceof Product)
|
|
147
|
+
.flatMap((plan) => {
|
|
148
|
+
const product = plan.product as Product
|
|
149
|
+
const versions = Array.isArray(product.versions) ? product.versions : []
|
|
150
|
+
|
|
151
|
+
return versions
|
|
152
|
+
.filter((version) => version instanceof ProductVersion)
|
|
153
|
+
.map((version) => ({
|
|
154
|
+
subscription,
|
|
155
|
+
plan,
|
|
156
|
+
product,
|
|
157
|
+
version,
|
|
158
|
+
}))
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
if (subscribedVersions.length === 0) {
|
|
163
|
+
return { results: [], count: 0 }
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const planIds = [...new Set(subscribedVersions.map((item) => item.plan.id))]
|
|
167
|
+
const versionIds = [...new Set(subscribedVersions.map((item) => item.version.id))]
|
|
168
|
+
const subscriptionIds = [...new Set(subscribedVersions.map((item) => item.subscription.id))]
|
|
169
|
+
|
|
170
|
+
const deployments = await Deployment.findAll({
|
|
171
|
+
where: {
|
|
172
|
+
org_id: orgId,
|
|
173
|
+
subscription_id: { [Op.in]: subscriptionIds },
|
|
174
|
+
product_plan_id: { [Op.in]: planIds },
|
|
175
|
+
product_version_id: { [Op.in]: versionIds },
|
|
176
|
+
status: { [Op.ne]: 'deleted' },
|
|
177
|
+
} as any,
|
|
178
|
+
attributes: ['id', 'subscription_id', 'product_plan_id', 'product_version_id', 'provider_id', 'provider_setting_id'],
|
|
179
|
+
})
|
|
180
|
+
const deployedKeys = new Set(
|
|
181
|
+
deployments.map((deployment) =>
|
|
182
|
+
deploymentOptionKey(
|
|
183
|
+
deployment.subscription_id,
|
|
184
|
+
deployment.product_plan_id,
|
|
185
|
+
deployment.product_version_id,
|
|
186
|
+
deployment.provider_id,
|
|
187
|
+
deployment.provider_setting_id
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
const providerSettings = await ProviderSetting.findAll({
|
|
193
|
+
where: { org_id: orgId },
|
|
194
|
+
include: [
|
|
195
|
+
{
|
|
196
|
+
model: Provider,
|
|
197
|
+
as: 'provider',
|
|
198
|
+
required: true,
|
|
199
|
+
where: { status: 'active' },
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
order: [
|
|
203
|
+
['is_default', 'DESC'],
|
|
204
|
+
['name', 'ASC'],
|
|
205
|
+
],
|
|
206
|
+
})
|
|
207
|
+
const results: LaunchableProduct[] = subscribedVersions
|
|
208
|
+
.map((item) => {
|
|
209
|
+
const providerOptions = buildDeploymentOptions(item.version, providerSettings)
|
|
210
|
+
const deploymentOptions = providerOptions.filter((option) => {
|
|
211
|
+
const key = deploymentOptionKey(
|
|
212
|
+
item.subscription.id,
|
|
213
|
+
item.plan.id,
|
|
214
|
+
item.version.id,
|
|
215
|
+
option.providerId,
|
|
216
|
+
option.providerSettingId
|
|
217
|
+
)
|
|
218
|
+
return !deployedKeys.has(key)
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
product: item.product,
|
|
223
|
+
productPlan: item.plan,
|
|
224
|
+
productVersion: item.version,
|
|
225
|
+
subscriptionId: item.subscription.id,
|
|
226
|
+
deploymentOptions,
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
.filter((item) => item.deploymentOptions.length > 0)
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
results,
|
|
233
|
+
count: results.length,
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export const deploymentLaunchService = new DeploymentLaunchService()
|
|
239
|
+
`
|
|
240
|
+
|
|
241
|
+
const deploymentPageSource = ({ ns, plural, key, options, resource }) => `import type { NextPage } from 'next'
|
|
242
|
+
import { useEffect, useMemo } from 'react'
|
|
243
|
+
import {
|
|
244
|
+
Drawer,
|
|
245
|
+
DrawerBody,
|
|
246
|
+
DrawerCloseButton,
|
|
247
|
+
DrawerContent,
|
|
248
|
+
DrawerFooter,
|
|
249
|
+
DrawerHeader,
|
|
250
|
+
DrawerOverlay,
|
|
251
|
+
useDisclosure,
|
|
252
|
+
} from '@chakra-ui/react'
|
|
253
|
+
import { FieldValues, SubmitHandler, useForm } from 'react-hook-form'
|
|
254
|
+
import { toast } from 'react-toastify'
|
|
255
|
+
import WithAuth from '@components/hoc/WithAuth'
|
|
256
|
+
import Button from '@components/common/button/Button'
|
|
257
|
+
import Input from '@components/common/forms/Input'
|
|
258
|
+
import Select from '@components/common/forms/Select'
|
|
259
|
+
import SideNavLayout from '@components/common/layout/SideNavLayout'
|
|
260
|
+
import ProjectPickerNav from '@components/projects/ProjectPickerNav'
|
|
261
|
+
import { useSearchAndFilterCommon } from '@hooks'
|
|
262
|
+
import { useRouter } from '@lib/next-router'
|
|
263
|
+
${options.sideNav?.resourceSidebar !== false ? `import { ${ns.pascal}SideNav } from '${options.src.importRoot}/components/${ns.pascal}SideNav'\n` : ''}import { ${ns.pascal}ResourceTable } from '${options.src.importRoot}/components/${ns.pascal}ResourceTable'
|
|
264
|
+
import { ${ns.camel}Resources } from '${options.src.importRoot}/config/${ns.resourcesFile}'
|
|
265
|
+
import {
|
|
266
|
+
useCreate${resource.name}Mutation,
|
|
267
|
+
useDelete${resource.name}Mutation,
|
|
268
|
+
useGet${plural}Query,
|
|
269
|
+
useGetLaunchableDeploymentProductsQuery,
|
|
270
|
+
type LaunchableDeploymentOption,
|
|
271
|
+
type LaunchableDeploymentProduct,
|
|
272
|
+
} from '${options.src.importRoot}/store/slice/api/${options.store.apiSliceName}'
|
|
273
|
+
import { useGetActiveProjectQuery } from '@store/slice/api/projectApiSlice'
|
|
274
|
+
|
|
275
|
+
type LaunchProductOption = {
|
|
276
|
+
value: string
|
|
277
|
+
label: string
|
|
278
|
+
item: LaunchableDeploymentProduct
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
type LaunchProviderOption = {
|
|
282
|
+
value: string
|
|
283
|
+
label: string
|
|
284
|
+
option: LaunchableDeploymentOption
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function slugify(value: string) {
|
|
288
|
+
return value
|
|
289
|
+
.trim()
|
|
290
|
+
.toLowerCase()
|
|
291
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
292
|
+
.replace(/^-+|-+$/g, '')
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function launchKey(item: LaunchableDeploymentProduct, option: LaunchableDeploymentOption) {
|
|
296
|
+
return [
|
|
297
|
+
item.subscriptionId,
|
|
298
|
+
item.productPlan.id,
|
|
299
|
+
item.productVersion.id,
|
|
300
|
+
option.providerId || '',
|
|
301
|
+
option.providerSettingId,
|
|
302
|
+
].join(':')
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function productKey(item: LaunchableDeploymentProduct) {
|
|
306
|
+
return [
|
|
307
|
+
item.subscriptionId,
|
|
308
|
+
item.product.id,
|
|
309
|
+
item.productPlan.id,
|
|
310
|
+
item.productVersion.id,
|
|
311
|
+
].join(':')
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
type CreateDeploymentDrawerProps = {
|
|
315
|
+
isOpen: boolean
|
|
316
|
+
isLoadingProducts: boolean
|
|
317
|
+
launchableProducts?: { results: LaunchableDeploymentProduct[] }
|
|
318
|
+
activeProjectId?: string
|
|
319
|
+
onClose: () => void
|
|
320
|
+
onCreated: () => void
|
|
321
|
+
createDeployment: ReturnType<typeof useCreate${resource.name}Mutation>[0]
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function CreateDeploymentDrawer({
|
|
325
|
+
isOpen,
|
|
326
|
+
isLoadingProducts,
|
|
327
|
+
launchableProducts,
|
|
328
|
+
activeProjectId,
|
|
329
|
+
onClose,
|
|
330
|
+
onCreated,
|
|
331
|
+
createDeployment,
|
|
332
|
+
}: CreateDeploymentDrawerProps) {
|
|
333
|
+
const {
|
|
334
|
+
register,
|
|
335
|
+
control,
|
|
336
|
+
getValues,
|
|
337
|
+
handleSubmit,
|
|
338
|
+
reset,
|
|
339
|
+
setValue,
|
|
340
|
+
watch,
|
|
341
|
+
formState: { errors, isSubmitting },
|
|
342
|
+
} = useForm<FieldValues>()
|
|
343
|
+
|
|
344
|
+
const productOptions = useMemo<LaunchProductOption[]>(() => {
|
|
345
|
+
return (launchableProducts?.results || []).map((item) => ({
|
|
346
|
+
value: productKey(item),
|
|
347
|
+
label: [item.product.name, item.productPlan.name, item.productVersion.name]
|
|
348
|
+
.filter(Boolean)
|
|
349
|
+
.join(' / '),
|
|
350
|
+
item,
|
|
351
|
+
}))
|
|
352
|
+
}, [launchableProducts])
|
|
353
|
+
const selectedProductKey = String(watch('productKey') || '')
|
|
354
|
+
const selectedProduct = productOptions.find((option) => option.value === selectedProductKey)
|
|
355
|
+
const providerOptions = useMemo<LaunchProviderOption[]>(() => {
|
|
356
|
+
if (!selectedProduct) return []
|
|
357
|
+
|
|
358
|
+
return selectedProduct.item.deploymentOptions
|
|
359
|
+
.filter((option) => option.providerId && option.providerSettingId)
|
|
360
|
+
.map((option) => ({
|
|
361
|
+
value: launchKey(selectedProduct.item, option),
|
|
362
|
+
label: [
|
|
363
|
+
option.providerSettingName || option.providerLabel || option.label,
|
|
364
|
+
option.specFormat,
|
|
365
|
+
]
|
|
366
|
+
.filter(Boolean)
|
|
367
|
+
.join(' / '),
|
|
368
|
+
option,
|
|
369
|
+
}))
|
|
370
|
+
}, [selectedProduct])
|
|
371
|
+
|
|
372
|
+
useEffect(() => {
|
|
373
|
+
if (!isOpen) return
|
|
374
|
+
|
|
375
|
+
reset({
|
|
376
|
+
productKey: productOptions[0]?.value || '',
|
|
377
|
+
providerKey: '',
|
|
378
|
+
name: '',
|
|
379
|
+
})
|
|
380
|
+
}, [isOpen, productOptions, reset])
|
|
381
|
+
|
|
382
|
+
useEffect(() => {
|
|
383
|
+
const currentProviderKey = String(getValues('providerKey') || '')
|
|
384
|
+
if (currentProviderKey && !providerOptions.some((option) => option.value === currentProviderKey)) {
|
|
385
|
+
setValue('providerKey', '')
|
|
386
|
+
}
|
|
387
|
+
}, [getValues, providerOptions, setValue, selectedProductKey])
|
|
388
|
+
|
|
389
|
+
const onSubmit: SubmitHandler<FieldValues> = async (values) => {
|
|
390
|
+
const selectedProductOption = productOptions.find((option) => option.value === values.productKey)
|
|
391
|
+
const selectedProviderOption = providerOptions.find((option) => option.value === values.providerKey)
|
|
392
|
+
|
|
393
|
+
if (!selectedProductOption || !selectedProviderOption) {
|
|
394
|
+
toast.error('Select a product and provider connection.')
|
|
395
|
+
return
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const item = selectedProductOption.item
|
|
399
|
+
const option = selectedProviderOption.option
|
|
400
|
+
const name = String(values.name || '').trim() || [item.product.name, item.productVersion.name, option.label]
|
|
401
|
+
.filter(Boolean)
|
|
402
|
+
.join(' - ')
|
|
403
|
+
const slug = slugify([item.product.slug || item.product.name, item.productVersion.name, option.key, Date.now().toString(36)].join(' '))
|
|
404
|
+
|
|
405
|
+
try {
|
|
406
|
+
await createDeployment({
|
|
407
|
+
payload: {
|
|
408
|
+
productId: item.product.id,
|
|
409
|
+
productPlanId: item.productPlan.id,
|
|
410
|
+
productVersionId: item.productVersion.id,
|
|
411
|
+
subscriptionId: item.subscriptionId,
|
|
412
|
+
providerId: option.providerId,
|
|
413
|
+
providerSettingId: option.providerSettingId,
|
|
414
|
+
deploymentValues: {
|
|
415
|
+
providerSettingName: option.providerSettingName,
|
|
416
|
+
providerKey: option.providerKey,
|
|
417
|
+
providerLabel: option.providerLabel,
|
|
418
|
+
specFormat: option.specFormat,
|
|
419
|
+
resourceUrl: option.resourceUrl,
|
|
420
|
+
},
|
|
421
|
+
name,
|
|
422
|
+
slug,
|
|
423
|
+
status: 'provisioning',
|
|
424
|
+
...(activeProjectId ? { projectId: activeProjectId } : {}),
|
|
425
|
+
} as any,
|
|
426
|
+
}).unwrap()
|
|
427
|
+
|
|
428
|
+
toast.success('Deployment created.')
|
|
429
|
+
onCreated()
|
|
430
|
+
onClose()
|
|
431
|
+
} catch {
|
|
432
|
+
toast.error('Deployment could not be created.')
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return (
|
|
437
|
+
<Drawer isOpen={isOpen} onClose={onClose} size="lg">
|
|
438
|
+
<DrawerOverlay />
|
|
439
|
+
<DrawerContent className="drawer">
|
|
440
|
+
<DrawerCloseButton />
|
|
441
|
+
<DrawerHeader>Create Deployment</DrawerHeader>
|
|
442
|
+
<DrawerBody>
|
|
443
|
+
<form id="create-deployment-form" onSubmit={handleSubmit(onSubmit)}>
|
|
444
|
+
<div className="mb-4 mt-3">
|
|
445
|
+
<label htmlFor="productKey">Product</label>
|
|
446
|
+
<p className="small mt-1 text-muted">
|
|
447
|
+
Select a subscribed product version to deploy
|
|
448
|
+
</p>
|
|
449
|
+
<Select
|
|
450
|
+
register={register('productKey', { required: 'This field is required' })}
|
|
451
|
+
label="Product"
|
|
452
|
+
options={productOptions}
|
|
453
|
+
control={control}
|
|
454
|
+
getValues={getValues}
|
|
455
|
+
setFirstAsDefault={false}
|
|
456
|
+
errors={errors}
|
|
457
|
+
isLoading={isLoadingProducts}
|
|
458
|
+
isDisabled={isLoadingProducts || productOptions.length === 0}
|
|
459
|
+
onChange={() => setValue('providerKey', '')}
|
|
460
|
+
/>
|
|
461
|
+
</div>
|
|
462
|
+
|
|
463
|
+
<div className="mb-4">
|
|
464
|
+
<label htmlFor="providerKey">Provider Connection</label>
|
|
465
|
+
<p className="small mt-1 text-muted">
|
|
466
|
+
Select the connected provider account for this deployment
|
|
467
|
+
</p>
|
|
468
|
+
<Select
|
|
469
|
+
register={register('providerKey', { required: 'This field is required' })}
|
|
470
|
+
label="Provider Connection"
|
|
471
|
+
options={providerOptions}
|
|
472
|
+
control={control}
|
|
473
|
+
getValues={getValues}
|
|
474
|
+
setFirstAsDefault={false}
|
|
475
|
+
errors={errors}
|
|
476
|
+
isDisabled={!selectedProduct || providerOptions.length === 0}
|
|
477
|
+
/>
|
|
478
|
+
</div>
|
|
479
|
+
|
|
480
|
+
<div className="mb-4">
|
|
481
|
+
<label htmlFor="name">Name</label>
|
|
482
|
+
<p className="small mt-1 text-muted">
|
|
483
|
+
Optionally set a friendly name for this deployment
|
|
484
|
+
</p>
|
|
485
|
+
<Input
|
|
486
|
+
register={register('name')}
|
|
487
|
+
errors={errors}
|
|
488
|
+
placeholder="Deployment name"
|
|
489
|
+
label="Name"
|
|
490
|
+
getValues={getValues}
|
|
491
|
+
/>
|
|
492
|
+
</div>
|
|
493
|
+
</form>
|
|
494
|
+
</DrawerBody>
|
|
495
|
+
<DrawerFooter>
|
|
496
|
+
<Button onClick={onClose}>Cancel</Button>
|
|
497
|
+
<Button
|
|
498
|
+
type="submit"
|
|
499
|
+
color="primary"
|
|
500
|
+
className="text-white"
|
|
501
|
+
form="create-deployment-form"
|
|
502
|
+
isLoading={isSubmitting}
|
|
503
|
+
disabled={isSubmitting || productOptions.length === 0}
|
|
504
|
+
>
|
|
505
|
+
Save
|
|
506
|
+
</Button>
|
|
507
|
+
</DrawerFooter>
|
|
508
|
+
</DrawerContent>
|
|
509
|
+
</Drawer>
|
|
510
|
+
)
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const ${resource.name}Page: NextPage = () => {
|
|
514
|
+
const router = useRouter()
|
|
515
|
+
const createDialog = useDisclosure()
|
|
516
|
+
const resource = ${ns.camel}Resources.${key}
|
|
517
|
+
const {
|
|
518
|
+
query: { q, limit, page },
|
|
519
|
+
} = router
|
|
520
|
+
const {
|
|
521
|
+
getLimitFromQuery,
|
|
522
|
+
calculateProperPageNumber,
|
|
523
|
+
} = useSearchAndFilterCommon()
|
|
524
|
+
const pageLimit = getLimitFromQuery(limit, 50)
|
|
525
|
+
const search = q?.toString()
|
|
526
|
+
const { data: activeProjectData } = useGetActiveProjectQuery()
|
|
527
|
+
const activeProjectId =
|
|
528
|
+
typeof activeProjectData?.projectId === 'string'
|
|
529
|
+
? activeProjectData.projectId.trim()
|
|
530
|
+
: undefined
|
|
531
|
+
const detailHref = (item: Record<string, any>) =>
|
|
532
|
+
[
|
|
533
|
+
resource.href,
|
|
534
|
+
encodeURIComponent(String(item.id || '')),
|
|
535
|
+
encodeURIComponent(slugify(String(item.name || item.slug || item.id))),
|
|
536
|
+
].join('/')
|
|
537
|
+
const {
|
|
538
|
+
data: launchableProducts,
|
|
539
|
+
isFetching: isFetchingLaunchable,
|
|
540
|
+
refetch: refetchLaunchableProducts,
|
|
541
|
+
} = useGetLaunchableDeploymentProductsQuery()
|
|
542
|
+
const {
|
|
543
|
+
data,
|
|
544
|
+
isFetching,
|
|
545
|
+
isLoading,
|
|
546
|
+
refetch: refetchDeployments,
|
|
547
|
+
} = useGet${plural}Query({
|
|
548
|
+
q: search,
|
|
549
|
+
nameLike: search,
|
|
550
|
+
limit: pageLimit,
|
|
551
|
+
page: calculateProperPageNumber(page),
|
|
552
|
+
...(activeProjectId ? { projectId: activeProjectId } : {}),
|
|
553
|
+
})
|
|
554
|
+
const [createDeployment] = useCreate${resource.name}Mutation()
|
|
555
|
+
const [deleteDeployment] = useDelete${resource.name}Mutation()
|
|
556
|
+
const launchableCount = launchableProducts?.results.length || 0
|
|
557
|
+
|
|
558
|
+
const handleCreated = () => {
|
|
559
|
+
refetchLaunchableProducts()
|
|
560
|
+
refetchDeployments()
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
const handleDelete = async (item: Record<string, any>) => {
|
|
564
|
+
if (!item.id || !window.confirm('Delete this deployment?')) return
|
|
565
|
+
|
|
566
|
+
try {
|
|
567
|
+
await deleteDeployment({ id: String(item.id) }).unwrap()
|
|
568
|
+
toast.success('Deployment deleted.')
|
|
569
|
+
refetchLaunchableProducts()
|
|
570
|
+
refetchDeployments()
|
|
571
|
+
} catch {
|
|
572
|
+
toast.error('Deployment could not be deleted.')
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
return (
|
|
577
|
+
<SideNavLayout
|
|
578
|
+
useMainContentAreaId={false}
|
|
579
|
+
mainNavMode="list"
|
|
580
|
+
sidebarTopContent={(isCollapsed) => (
|
|
581
|
+
<ProjectPickerNav isCollapsed={isCollapsed} appPath={resource.href} />
|
|
582
|
+
)}
|
|
583
|
+
${options.sideNav?.resourceSidebar !== false ? ` sidebarContent={(isCollapsed) => (!isCollapsed ? <${ns.pascal}SideNav /> : null)}` : ''}
|
|
584
|
+
>
|
|
585
|
+
<div className="mt-5 w-100">
|
|
586
|
+
<div className="d-flex align-items-start justify-content-between gap-3">
|
|
587
|
+
<div>
|
|
588
|
+
<h1 className="mb-2">{resource.title}</h1>
|
|
589
|
+
<p className="text-muted mb-0">{resource.description}</p>
|
|
590
|
+
</div>
|
|
591
|
+
</div>
|
|
592
|
+
|
|
593
|
+
<${ns.pascal}ResourceTable
|
|
594
|
+
resource={resource}
|
|
595
|
+
data={data}
|
|
596
|
+
isFetching={isFetching}
|
|
597
|
+
isLoading={isLoading}
|
|
598
|
+
onCreate={createDialog.onOpen}
|
|
599
|
+
onRowClick={(item) => item.id ? router.push(detailHref(item)) : undefined}
|
|
600
|
+
onDelete={handleDelete}
|
|
601
|
+
/>
|
|
602
|
+
|
|
603
|
+
<CreateDeploymentDrawer
|
|
604
|
+
isOpen={createDialog.isOpen}
|
|
605
|
+
isLoadingProducts={isFetchingLaunchable}
|
|
606
|
+
launchableProducts={launchableProducts}
|
|
607
|
+
activeProjectId={activeProjectId}
|
|
608
|
+
onClose={createDialog.onClose}
|
|
609
|
+
onCreated={handleCreated}
|
|
610
|
+
createDeployment={createDeployment}
|
|
611
|
+
/>
|
|
612
|
+
</div>
|
|
613
|
+
</SideNavLayout>
|
|
614
|
+
)
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
${resource.name}Page.getInitialProps = async () => {
|
|
618
|
+
return {
|
|
619
|
+
pageTitle: '${resource.title}',
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export default WithAuth(${resource.name}Page)
|
|
624
|
+
`
|
|
625
|
+
|
|
626
|
+
const deploymentUsersPageSource = ({ ns, options, resource }) => `import type { NextPage } from 'next'
|
|
627
|
+
import Link from 'next/link'
|
|
628
|
+
import { useEffect, useMemo } from 'react'
|
|
629
|
+
import { useDisclosure } from '@chakra-ui/react'
|
|
630
|
+
import SideNavLayout from '@components/common/layout/SideNavLayout'
|
|
631
|
+
import WithAuth from '@components/hoc/WithAuth'
|
|
632
|
+
import UserGrid from '@components/user/grid/UserGrid'
|
|
633
|
+
import AddUserModal from '@components/user/modal/AddUserModal'
|
|
634
|
+
import UpgradeUserLimitModal from '@components/user/modal/UpgradeUserLimitModal'
|
|
635
|
+
import { UpdatePlanModal } from '@components/billing/modal/UpdatePlanModal'
|
|
636
|
+
import { useUserAuthContext } from '@context/UserAuthContext'
|
|
637
|
+
import { useRouter } from '@lib/next-router'
|
|
638
|
+
import { useListOrgsQuery, useListOrgMembershipsQuery } from '@store/slice/api/orgApiSlice'
|
|
639
|
+
import { useGetSubscriptionQuery } from '@store/slice/api/stripeApiSlice'
|
|
640
|
+
${options.sideNav?.resourceSidebar !== false ? `import { ${ns.pascal}SideNav } from '${options.src.importRoot}/components/${ns.pascal}SideNav'\n` : ''}import { ${ns.camel}Resources } from '${options.src.importRoot}/config/${ns.resourcesFile}'
|
|
641
|
+
import { useGetOne${resource.name}Query } from '${options.src.importRoot}/store/slice/api/${options.store.apiSliceName}'
|
|
642
|
+
|
|
643
|
+
const ${resource.name}UsersPage: NextPage = () => {
|
|
644
|
+
const router = useRouter()
|
|
645
|
+
const { user, activeOrgId } = useUserAuthContext()
|
|
646
|
+
const resource = ${ns.camel}Resources.deployment
|
|
647
|
+
const id = typeof router.query.id === 'string' ? router.query.id : ''
|
|
648
|
+
const { data: deployment } = useGetOne${resource.name}Query({ id }, { skip: !id })
|
|
649
|
+
const {
|
|
650
|
+
isOpen: isOpenAddUserModal,
|
|
651
|
+
onOpen: onOpenAddUserModal,
|
|
652
|
+
onClose: onCloseAddUserModal,
|
|
653
|
+
} = useDisclosure()
|
|
654
|
+
const {
|
|
655
|
+
isOpen: isOpenUpgradeModal,
|
|
656
|
+
onOpen: onOpenUpgradeModal,
|
|
657
|
+
onClose: onCloseUpgradeModal,
|
|
658
|
+
} = useDisclosure()
|
|
659
|
+
const {
|
|
660
|
+
isOpen: isOpenPlanModal,
|
|
661
|
+
onOpen: onOpenPlanModal,
|
|
662
|
+
onClose: onClosePlanModal,
|
|
663
|
+
} = useDisclosure()
|
|
664
|
+
|
|
665
|
+
const { data: orgMembershipsData, isLoading: isLoadingOrgs } = useListOrgsQuery(undefined, {
|
|
666
|
+
skip: !user?.id,
|
|
667
|
+
})
|
|
668
|
+
|
|
669
|
+
const orgMemberships = useMemo(
|
|
670
|
+
() => orgMembershipsData ?? user?.orgMemberships ?? [],
|
|
671
|
+
[orgMembershipsData, user?.orgMemberships]
|
|
672
|
+
)
|
|
673
|
+
|
|
674
|
+
const activeMembership = useMemo(() => {
|
|
675
|
+
if (!orgMemberships.length) return null
|
|
676
|
+
return (
|
|
677
|
+
orgMemberships.find((membership) => membership.orgId === activeOrgId) ||
|
|
678
|
+
orgMemberships.find((membership) => membership.org?.orgType === 'personal') ||
|
|
679
|
+
orgMemberships[0] ||
|
|
680
|
+
null
|
|
681
|
+
)
|
|
682
|
+
}, [activeOrgId, orgMemberships])
|
|
683
|
+
|
|
684
|
+
const activeOrgOwnerId = activeMembership?.org?.ownerId ?? null
|
|
685
|
+
const resolvedOrgId = activeMembership?.orgId || activeOrgId
|
|
686
|
+
|
|
687
|
+
const { data: membersData } = useListOrgMembershipsQuery(
|
|
688
|
+
{ orgId: resolvedOrgId!, limit: 1, page: 1 },
|
|
689
|
+
{ skip: !resolvedOrgId }
|
|
690
|
+
)
|
|
691
|
+
|
|
692
|
+
const { data: subData } = useGetSubscriptionQuery()
|
|
693
|
+
|
|
694
|
+
const { planName, maxUsers, isHardCapped, currentUserCount } = useMemo(() => {
|
|
695
|
+
const subscriptions = (subData as any)?.subscriptions ?? []
|
|
696
|
+
const activeSub = subscriptions[0]
|
|
697
|
+
const plan = activeSub?.productPlans?.find((item: any) => item.product?.type === 'plan')
|
|
698
|
+
const product = plan?.product
|
|
699
|
+
const userLimit = product?.limits?.users ?? null
|
|
700
|
+
|
|
701
|
+
return {
|
|
702
|
+
planName: product?.name ?? '',
|
|
703
|
+
maxUsers:
|
|
704
|
+
typeof userLimit?.includedUnits === 'number'
|
|
705
|
+
? userLimit.includedUnits
|
|
706
|
+
: userLimit?.includedUnits == null
|
|
707
|
+
? null
|
|
708
|
+
: Number(userLimit.includedUnits),
|
|
709
|
+
isHardCapped: userLimit?.hardCap === true,
|
|
710
|
+
currentUserCount: membersData?.count ?? 0,
|
|
711
|
+
}
|
|
712
|
+
}, [membersData, subData])
|
|
713
|
+
|
|
714
|
+
const isAtUserLimit =
|
|
715
|
+
isHardCapped && maxUsers !== null && currentUserCount >= maxUsers
|
|
716
|
+
|
|
717
|
+
const handleAddUser = () => {
|
|
718
|
+
if (isAtUserLimit) {
|
|
719
|
+
onOpenUpgradeModal()
|
|
720
|
+
} else {
|
|
721
|
+
onOpenAddUserModal()
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
const handleUpgrade = () => {
|
|
726
|
+
onCloseUpgradeModal()
|
|
727
|
+
onOpenPlanModal()
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
const resolveDetailHref = (href: string) =>
|
|
731
|
+
href
|
|
732
|
+
.replaceAll('{id}', encodeURIComponent(id))
|
|
733
|
+
.replaceAll(':id', encodeURIComponent(id))
|
|
734
|
+
.replaceAll('{name}', encodeURIComponent(String(router.query.name || deployment?.name || id)))
|
|
735
|
+
.replaceAll(':name', encodeURIComponent(String(router.query.name || deployment?.name || id)))
|
|
736
|
+
|
|
737
|
+
useEffect(() => {
|
|
738
|
+
if (!user?.id || isLoadingOrgs) return
|
|
739
|
+
const activeOrg = activeMembership?.org
|
|
740
|
+
const isPersonalOrg =
|
|
741
|
+
activeOrg?.orgType === 'personal' ||
|
|
742
|
+
(!!activeOrg?.slug && !!user?.name && activeOrg.slug === user.name)
|
|
743
|
+
|
|
744
|
+
if (isPersonalOrg) {
|
|
745
|
+
router.replace('/')
|
|
746
|
+
}
|
|
747
|
+
}, [activeMembership, isLoadingOrgs, router, user?.id, user?.name])
|
|
748
|
+
|
|
749
|
+
return (
|
|
750
|
+
<SideNavLayout
|
|
751
|
+
useMainContentAreaId={false}
|
|
752
|
+
mainNavMode="list"
|
|
753
|
+
renderMainNav={() => null}
|
|
754
|
+
sidebarTopContent={() => (
|
|
755
|
+
<>
|
|
756
|
+
<h2 className="sidebar-heading">{resource.title}</h2>
|
|
757
|
+
<ul className="sidebar-list mb-5">
|
|
758
|
+
<li className="sidebar-item" title={'Back to ' + resource.title}>
|
|
759
|
+
<Link href={resource.href} className="sidebar-link">
|
|
760
|
+
<i className="bi bi-arrow-left" /> <span>Back</span>
|
|
761
|
+
</Link>
|
|
762
|
+
</li>
|
|
763
|
+
</ul>
|
|
764
|
+
</>
|
|
765
|
+
)}
|
|
766
|
+
sidebarContent={(isCollapsed) =>
|
|
767
|
+
!isCollapsed ? (
|
|
768
|
+
<>
|
|
769
|
+
${options.sideNav?.resourceSidebar !== false ? ` <${ns.pascal}SideNav />` : ''}
|
|
770
|
+
<nav className="sidebar-section mt-4" aria-label="Deployment navigation">
|
|
771
|
+
<ul className="sidebar-list">
|
|
772
|
+
{resource.detailSidebarItems.map((item) => {
|
|
773
|
+
const isActive = item.label === 'Users'
|
|
774
|
+
|
|
775
|
+
return (
|
|
776
|
+
<li key={item.href} className={'sidebar-item' + (isActive ? ' active' : '')} title={item.label}>
|
|
777
|
+
<Link href={resolveDetailHref(item.href)} className="sidebar-link">
|
|
778
|
+
{item.icon ? <i className={item.icon} /> : null} <span>{item.label}</span>
|
|
779
|
+
</Link>
|
|
780
|
+
</li>
|
|
781
|
+
)
|
|
782
|
+
})}
|
|
783
|
+
</ul>
|
|
784
|
+
</nav>
|
|
785
|
+
</>
|
|
786
|
+
) : null
|
|
787
|
+
}
|
|
788
|
+
>
|
|
789
|
+
<div className="mt-5 w-100">
|
|
790
|
+
<div className="mb-4">
|
|
791
|
+
<h1 className="mb-2">Users</h1>
|
|
792
|
+
<p className="text-muted mb-0">
|
|
793
|
+
Manage users and invitations for {String((deployment as any)?.name || 'this deployment')}.
|
|
794
|
+
</p>
|
|
795
|
+
</div>
|
|
796
|
+
|
|
797
|
+
<UserGrid
|
|
798
|
+
onCreate={handleAddUser}
|
|
799
|
+
orgId={resolvedOrgId}
|
|
800
|
+
orgOwnerId={activeOrgOwnerId}
|
|
801
|
+
/>
|
|
802
|
+
</div>
|
|
803
|
+
|
|
804
|
+
<AddUserModal
|
|
805
|
+
isOpen={isOpenAddUserModal}
|
|
806
|
+
onClose={onCloseAddUserModal}
|
|
807
|
+
orgId={resolvedOrgId}
|
|
808
|
+
/>
|
|
809
|
+
|
|
810
|
+
<UpgradeUserLimitModal
|
|
811
|
+
isOpen={isOpenUpgradeModal}
|
|
812
|
+
onClose={onCloseUpgradeModal}
|
|
813
|
+
onUpgrade={handleUpgrade}
|
|
814
|
+
currentPlanName={planName}
|
|
815
|
+
maxUsers={maxUsers ?? 0}
|
|
816
|
+
currentUserCount={currentUserCount}
|
|
817
|
+
/>
|
|
818
|
+
|
|
819
|
+
<UpdatePlanModal
|
|
820
|
+
isOpen={isOpenPlanModal}
|
|
821
|
+
onClose={onClosePlanModal}
|
|
822
|
+
/>
|
|
823
|
+
</SideNavLayout>
|
|
824
|
+
)
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
${resource.name}UsersPage.getInitialProps = async () => ({
|
|
828
|
+
pageTitle: 'Deployment Users',
|
|
829
|
+
})
|
|
830
|
+
|
|
831
|
+
export default WithAuth(${resource.name}UsersPage)
|
|
832
|
+
`
|
|
833
|
+
|
|
834
|
+
const deploymentChildResourcePageSource = ({ ns, options, resource, childPage }) => `import type { NextPage } from 'next'
|
|
835
|
+
import Link from 'next/link'
|
|
836
|
+
import SideNavLayout from '@components/common/layout/SideNavLayout'
|
|
837
|
+
import WithAuth from '@components/hoc/WithAuth'
|
|
838
|
+
import { useSearchAndFilterCommon } from '@hooks'
|
|
839
|
+
import { useRouter } from '@lib/next-router'
|
|
840
|
+
${options.sideNav?.resourceSidebar !== false ? `import { ${ns.pascal}SideNav } from '${options.src.importRoot}/components/${ns.pascal}SideNav'\n` : ''}import { ${ns.pascal}ResourceTable } from '${options.src.importRoot}/components/${ns.pascal}ResourceTable'
|
|
841
|
+
import { ${ns.camel}Resources } from '${options.src.importRoot}/config/${ns.resourcesFile}'
|
|
842
|
+
import {
|
|
843
|
+
useGetOne${resource.name}Query,
|
|
844
|
+
${childPage.listHook},
|
|
845
|
+
} from '${options.src.importRoot}/store/slice/api/${options.store.apiSliceName}'
|
|
846
|
+
|
|
847
|
+
const ${resource.name}${childPage.componentSuffix}Page: NextPage = () => {
|
|
848
|
+
const router = useRouter()
|
|
849
|
+
const resource = ${ns.camel}Resources.deployment
|
|
850
|
+
const childResource = ${ns.camel}Resources.${childPage.resourceKey}
|
|
851
|
+
const id = typeof router.query.id === 'string' ? router.query.id : ''
|
|
852
|
+
const {
|
|
853
|
+
query: { q, limit, page },
|
|
854
|
+
} = router
|
|
855
|
+
const {
|
|
856
|
+
getLimitFromQuery,
|
|
857
|
+
calculateProperPageNumber,
|
|
858
|
+
} = useSearchAndFilterCommon()
|
|
859
|
+
const pageLimit = getLimitFromQuery(limit, 50)
|
|
860
|
+
const search = q?.toString()
|
|
861
|
+
const { data: deployment } = useGetOne${resource.name}Query({ id }, { skip: !id })
|
|
862
|
+
const { data, isFetching, isLoading } = ${childPage.listHook}({
|
|
863
|
+
q: search,
|
|
864
|
+
nameLike: search,
|
|
865
|
+
limit: pageLimit,
|
|
866
|
+
page: calculateProperPageNumber(page),
|
|
867
|
+
deploymentId: id,
|
|
868
|
+
}, { skip: !id } as any)
|
|
869
|
+
const detailName = String(router.query.name || (deployment as any)?.name || id)
|
|
870
|
+
|
|
871
|
+
const resolveDetailHref = (href: string) =>
|
|
872
|
+
href
|
|
873
|
+
.replaceAll('{id}', encodeURIComponent(id))
|
|
874
|
+
.replaceAll(':id', encodeURIComponent(id))
|
|
875
|
+
.replaceAll('{name}', encodeURIComponent(detailName))
|
|
876
|
+
.replaceAll(':name', encodeURIComponent(detailName))
|
|
877
|
+
|
|
878
|
+
return (
|
|
879
|
+
<SideNavLayout
|
|
880
|
+
useMainContentAreaId={false}
|
|
881
|
+
mainNavMode="list"
|
|
882
|
+
renderMainNav={() => null}
|
|
883
|
+
sidebarTopContent={() => (
|
|
884
|
+
<>
|
|
885
|
+
<h2 className="sidebar-heading">{resource.title}</h2>
|
|
886
|
+
<ul className="sidebar-list mb-5">
|
|
887
|
+
<li className="sidebar-item" title={'Back to ' + resource.title}>
|
|
888
|
+
<Link href={resource.href} className="sidebar-link">
|
|
889
|
+
<i className="bi bi-arrow-left" /> <span>Back</span>
|
|
890
|
+
</Link>
|
|
891
|
+
</li>
|
|
892
|
+
</ul>
|
|
893
|
+
</>
|
|
894
|
+
)}
|
|
895
|
+
sidebarContent={(isCollapsed) =>
|
|
896
|
+
!isCollapsed ? (
|
|
897
|
+
<>
|
|
898
|
+
${options.sideNav?.resourceSidebar !== false ? ` <${ns.pascal}SideNav />` : ''}
|
|
899
|
+
<nav className="sidebar-section mt-4" aria-label="Deployment navigation">
|
|
900
|
+
<ul className="sidebar-list">
|
|
901
|
+
{resource.detailSidebarItems.map((item) => {
|
|
902
|
+
const isActive = item.label === '${childPage.activeLabel}'
|
|
903
|
+
|
|
904
|
+
return (
|
|
905
|
+
<li key={item.href} className={'sidebar-item' + (isActive ? ' active' : '')} title={item.label}>
|
|
906
|
+
<Link href={resolveDetailHref(item.href)} className="sidebar-link">
|
|
907
|
+
{item.icon ? <i className={item.icon} /> : null} <span>{item.label}</span>
|
|
908
|
+
</Link>
|
|
909
|
+
</li>
|
|
910
|
+
)
|
|
911
|
+
})}
|
|
912
|
+
</ul>
|
|
913
|
+
</nav>
|
|
914
|
+
</>
|
|
915
|
+
) : null
|
|
916
|
+
}
|
|
917
|
+
>
|
|
918
|
+
<div className="mt-5 w-100">
|
|
919
|
+
<div className="mb-4">
|
|
920
|
+
<h1 className="mb-2">${childPage.title}</h1>
|
|
921
|
+
<p className="text-muted mb-0">
|
|
922
|
+
View ${childPage.description.toLowerCase()} for {String((deployment as any)?.name || 'this deployment')}.
|
|
923
|
+
</p>
|
|
924
|
+
</div>
|
|
925
|
+
|
|
926
|
+
<${ns.pascal}ResourceTable
|
|
927
|
+
resource={childResource}
|
|
928
|
+
data={data}
|
|
929
|
+
isFetching={isFetching}
|
|
930
|
+
isLoading={isLoading}
|
|
931
|
+
onRowClick={(item) => item.id ? router.push(childResource.href + '/' + item.id) : undefined}
|
|
932
|
+
/>
|
|
933
|
+
</div>
|
|
934
|
+
</SideNavLayout>
|
|
935
|
+
)
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
${resource.name}${childPage.componentSuffix}Page.getInitialProps = async () => ({
|
|
939
|
+
pageTitle: '${childPage.pageTitle}',
|
|
940
|
+
})
|
|
941
|
+
|
|
942
|
+
export default WithAuth(${resource.name}${childPage.componentSuffix}Page)
|
|
943
|
+
`
|
|
944
|
+
|
|
945
|
+
const resources = [
|
|
946
|
+
{
|
|
947
|
+
name: 'DeploymentTemplate',
|
|
948
|
+
slug: 'deployment-template',
|
|
949
|
+
route: 'cms-templates',
|
|
950
|
+
responseKey: 'deploymentTemplate',
|
|
951
|
+
title: 'Templates',
|
|
952
|
+
icon: 'bi bi-layout-text-window-reverse',
|
|
953
|
+
description: 'Manage reusable deployment blueprints and starter site configurations.',
|
|
954
|
+
bullets: [
|
|
955
|
+
'Version templates',
|
|
956
|
+
'Control active starter blueprints',
|
|
957
|
+
'Attach templates to deployment creation flows',
|
|
958
|
+
],
|
|
959
|
+
searchFields: ['name', 'slug', 'description'],
|
|
960
|
+
fields: [
|
|
961
|
+
field.uuid('org_id', { nullable: true, references: 'org', skipSchema: true, hideInTable: true }),
|
|
962
|
+
field.string('name', { required: true, minLength: 2 }),
|
|
963
|
+
field.string('slug', { required: true, regex: 'SLUG_REGEX' }),
|
|
964
|
+
field.text('description', { nullable: true }),
|
|
965
|
+
field.string('version', { required: true }),
|
|
966
|
+
field.boolean('is_active', { defaultValue: true }),
|
|
967
|
+
],
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
name: 'Deployment',
|
|
971
|
+
slug: 'deployment',
|
|
972
|
+
route: 'cms-deployments',
|
|
973
|
+
responseKey: 'deployment',
|
|
974
|
+
title: 'Deployments',
|
|
975
|
+
icon: 'bi bi-rocket-takeoff',
|
|
976
|
+
detailRoute: '[id]/[name]',
|
|
977
|
+
description: 'Manage product deployment lifecycle operations including create, update, backup, clone, and delete.',
|
|
978
|
+
pageSource: deploymentPageSource,
|
|
979
|
+
tableColumns: [
|
|
980
|
+
{ key: 'name', label: 'Name' },
|
|
981
|
+
{ key: 'status', label: 'Status' },
|
|
982
|
+
{ key: 'createdAt', label: 'On' },
|
|
983
|
+
],
|
|
984
|
+
detailActions: [
|
|
985
|
+
{ label: 'Templates', href: '/templates', icon: 'bi bi-layout-text-window-reverse' },
|
|
986
|
+
],
|
|
987
|
+
detailSidebarItems: [
|
|
988
|
+
{ label: 'Jobs', href: '/deployments/{id}/{name}/jobs', icon: 'bi bi-list-check' },
|
|
989
|
+
{ label: 'Backup Jobs', href: '/deployments/{id}/{name}/backups', icon: 'bi bi-archive' },
|
|
990
|
+
{ label: 'Users', href: '/deployments/{id}/{name}/users', icon: 'bi bi-people' },
|
|
991
|
+
],
|
|
992
|
+
detailPages: [
|
|
993
|
+
{
|
|
994
|
+
path: 'jobs',
|
|
995
|
+
resourceKey: 'deploymentJob',
|
|
996
|
+
title: 'Jobs',
|
|
997
|
+
description: 'deployment jobs',
|
|
998
|
+
activeLabel: 'Jobs',
|
|
999
|
+
componentSuffix: 'Jobs',
|
|
1000
|
+
pageTitle: 'Deployment Jobs',
|
|
1001
|
+
listHook: 'useGetCmsDeploymentJobsQuery',
|
|
1002
|
+
pageSource: deploymentChildResourcePageSource,
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
path: 'backups',
|
|
1006
|
+
resourceKey: 'deploymentBackup',
|
|
1007
|
+
title: 'Backup Jobs',
|
|
1008
|
+
description: 'backup jobs',
|
|
1009
|
+
activeLabel: 'Backup Jobs',
|
|
1010
|
+
componentSuffix: 'Backups',
|
|
1011
|
+
pageTitle: 'Deployment Backup Jobs',
|
|
1012
|
+
listHook: 'useGetCmsBackupsQuery',
|
|
1013
|
+
pageSource: deploymentChildResourcePageSource,
|
|
1014
|
+
},
|
|
1015
|
+
{ path: 'users', pageSource: deploymentUsersPageSource },
|
|
1016
|
+
],
|
|
1017
|
+
bullets: [
|
|
1018
|
+
'Create and launch subscribed products',
|
|
1019
|
+
'Track status and operational health',
|
|
1020
|
+
'Attach each deployment to the core site that handles domains and routing',
|
|
1021
|
+
],
|
|
1022
|
+
searchFields: ['name', 'slug', 'status', 'runtime_key'],
|
|
1023
|
+
fields: [
|
|
1024
|
+
field.uuid('org_id', { nullable: true, references: 'org', skipSchema: true, hideInTable: true }),
|
|
1025
|
+
field.uuid('project_id', { nullable: true, references: 'project', skipSchema: true, hideInTable: true }),
|
|
1026
|
+
field.uuid('site_id', {
|
|
1027
|
+
nullable: true,
|
|
1028
|
+
references: 'site',
|
|
1029
|
+
validate: {
|
|
1030
|
+
model: 'Site',
|
|
1031
|
+
importRoot: '@lib/models',
|
|
1032
|
+
message: 'Site Not Found',
|
|
1033
|
+
where: [
|
|
1034
|
+
{ column: 'id', value: '$value' },
|
|
1035
|
+
{ column: 'org_id', value: 'scopedValues.org_id' },
|
|
1036
|
+
],
|
|
1037
|
+
},
|
|
1038
|
+
}),
|
|
1039
|
+
field.uuid('product_id', {
|
|
1040
|
+
required: true,
|
|
1041
|
+
references: 'product',
|
|
1042
|
+
onDelete: 'RESTRICT',
|
|
1043
|
+
validate: {
|
|
1044
|
+
model: 'Product',
|
|
1045
|
+
importRoot: '@lib/models',
|
|
1046
|
+
message: 'Product Not Found',
|
|
1047
|
+
where: [
|
|
1048
|
+
{ column: 'id', value: '$value' },
|
|
1049
|
+
],
|
|
1050
|
+
},
|
|
1051
|
+
}),
|
|
1052
|
+
field.uuid('product_plan_id', {
|
|
1053
|
+
nullable: true,
|
|
1054
|
+
references: 'product_plan',
|
|
1055
|
+
validate: {
|
|
1056
|
+
model: 'ProductPlan',
|
|
1057
|
+
importRoot: '@lib/models',
|
|
1058
|
+
message: 'ProductPlan Not Found',
|
|
1059
|
+
where: [
|
|
1060
|
+
{ column: 'id', value: '$value' },
|
|
1061
|
+
{ column: 'product_id', value: 'payload.product_id ?? record?.product_id' },
|
|
1062
|
+
],
|
|
1063
|
+
},
|
|
1064
|
+
}),
|
|
1065
|
+
field.uuid('product_version_id', {
|
|
1066
|
+
nullable: true,
|
|
1067
|
+
references: 'product_version',
|
|
1068
|
+
validate: {
|
|
1069
|
+
model: 'ProductVersion',
|
|
1070
|
+
importRoot: '@lib/models',
|
|
1071
|
+
message: 'ProductVersion Not Found',
|
|
1072
|
+
where: [
|
|
1073
|
+
{ column: 'id', value: '$value' },
|
|
1074
|
+
{ column: 'product_id', value: 'payload.product_id ?? record?.product_id' },
|
|
1075
|
+
],
|
|
1076
|
+
},
|
|
1077
|
+
}),
|
|
1078
|
+
field.uuid('subscription_id', {
|
|
1079
|
+
nullable: true,
|
|
1080
|
+
references: 'product_subscription',
|
|
1081
|
+
validate: {
|
|
1082
|
+
model: 'Subscription',
|
|
1083
|
+
importRoot: '@lib/models',
|
|
1084
|
+
message: 'Subscription Not Found',
|
|
1085
|
+
where: [
|
|
1086
|
+
{ column: 'id', value: '$value' },
|
|
1087
|
+
{ column: 'org_id', value: 'scopedValues.org_id' },
|
|
1088
|
+
],
|
|
1089
|
+
},
|
|
1090
|
+
}),
|
|
1091
|
+
field.uuid('provider_id', {
|
|
1092
|
+
required: true,
|
|
1093
|
+
references: 'provider',
|
|
1094
|
+
onDelete: 'RESTRICT',
|
|
1095
|
+
validate: {
|
|
1096
|
+
model: 'Provider',
|
|
1097
|
+
importRoot: '@lib/models',
|
|
1098
|
+
message: 'Provider Not Found',
|
|
1099
|
+
where: [
|
|
1100
|
+
{ column: 'id', value: '$value' },
|
|
1101
|
+
{ column: 'status', value: "'active'" },
|
|
1102
|
+
],
|
|
1103
|
+
},
|
|
1104
|
+
}),
|
|
1105
|
+
field.uuid('provider_setting_id', {
|
|
1106
|
+
required: true,
|
|
1107
|
+
references: 'provider_settings',
|
|
1108
|
+
onDelete: 'RESTRICT',
|
|
1109
|
+
validate: {
|
|
1110
|
+
model: 'ProviderSetting',
|
|
1111
|
+
importRoot: '@lib/models',
|
|
1112
|
+
message: 'ProviderSetting Not Found',
|
|
1113
|
+
where: [
|
|
1114
|
+
{ column: 'id', value: '$value' },
|
|
1115
|
+
{ column: 'org_id', value: 'scopedValues.org_id' },
|
|
1116
|
+
{ column: 'provider_id', value: 'payload.provider_id ?? record?.provider_id' },
|
|
1117
|
+
],
|
|
1118
|
+
},
|
|
1119
|
+
}),
|
|
1120
|
+
field.json('deployment_values', { nullable: true, hideInTable: true }),
|
|
1121
|
+
field.string('name', { required: true, minLength: 2 }),
|
|
1122
|
+
field.string('slug', { required: true, regex: 'SLUG_REGEX' }),
|
|
1123
|
+
field.enum('status', status.deployment, { defaultValue: 'draft' }),
|
|
1124
|
+
field.uuid('template_id', {
|
|
1125
|
+
nullable: true,
|
|
1126
|
+
references: 'deployment_template',
|
|
1127
|
+
validate: {
|
|
1128
|
+
model: 'DeploymentTemplate',
|
|
1129
|
+
message: 'DeploymentTemplate Not Found',
|
|
1130
|
+
where: [
|
|
1131
|
+
{ column: 'id', value: '$value' },
|
|
1132
|
+
{ column: 'org_id', value: 'scopedValues.org_id' },
|
|
1133
|
+
],
|
|
1134
|
+
},
|
|
1135
|
+
}),
|
|
1136
|
+
field.string('runtime_key', { nullable: true }),
|
|
1137
|
+
field.uuid('owner_user_id', {
|
|
1138
|
+
nullable: true,
|
|
1139
|
+
references: 'user',
|
|
1140
|
+
validate: {
|
|
1141
|
+
model: 'User',
|
|
1142
|
+
importRoot: '@lib/models',
|
|
1143
|
+
message: 'User Not Found',
|
|
1144
|
+
where: [
|
|
1145
|
+
{ column: 'id', value: '$value' },
|
|
1146
|
+
],
|
|
1147
|
+
},
|
|
1148
|
+
}),
|
|
1149
|
+
],
|
|
1150
|
+
serviceValidate: `
|
|
1151
|
+
const subscribedSubscriptionId = payload.subscription_id !== undefined ? payload.subscription_id : record?.subscription_id
|
|
1152
|
+
const subscribedProductPlanId = payload.product_plan_id !== undefined ? payload.product_plan_id : record?.product_plan_id
|
|
1153
|
+
const subscribedProductVersionId = payload.product_version_id !== undefined ? payload.product_version_id : record?.product_version_id
|
|
1154
|
+
const subscribedProductId = payload.product_id !== undefined ? payload.product_id : record?.product_id
|
|
1155
|
+
|
|
1156
|
+
if (subscribedSubscriptionId && subscribedProductPlanId) {
|
|
1157
|
+
const subscribedPlan = await ProductPlan.findOne({
|
|
1158
|
+
where: {
|
|
1159
|
+
id: subscribedProductPlanId,
|
|
1160
|
+
product_id: subscribedProductId,
|
|
1161
|
+
},
|
|
1162
|
+
include: [
|
|
1163
|
+
{
|
|
1164
|
+
model: Subscription,
|
|
1165
|
+
as: 'subscriptions',
|
|
1166
|
+
required: true,
|
|
1167
|
+
attributes: ['id'],
|
|
1168
|
+
where: {
|
|
1169
|
+
id: subscribedSubscriptionId,
|
|
1170
|
+
org_id: scopedValues.org_id,
|
|
1171
|
+
},
|
|
1172
|
+
through: { attributes: [] },
|
|
1173
|
+
},
|
|
1174
|
+
],
|
|
1175
|
+
})
|
|
1176
|
+
|
|
1177
|
+
if (!(subscribedPlan instanceof ProductPlan)) {
|
|
1178
|
+
throw NotFoundError('Subscribed ProductPlan Not Found')
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
if (subscribedProductVersionId && subscribedProductId) {
|
|
1183
|
+
const subscribedVersion = await ProductVersion.findOne({
|
|
1184
|
+
where: {
|
|
1185
|
+
id: subscribedProductVersionId,
|
|
1186
|
+
product_id: subscribedProductId,
|
|
1187
|
+
},
|
|
1188
|
+
})
|
|
1189
|
+
|
|
1190
|
+
if (!(subscribedVersion instanceof ProductVersion)) {
|
|
1191
|
+
throw NotFoundError('ProductVersion Not Found')
|
|
1192
|
+
}
|
|
1193
|
+
}`,
|
|
1194
|
+
collectionActions: [
|
|
1195
|
+
{
|
|
1196
|
+
name: 'launchableProducts',
|
|
1197
|
+
route: 'cms-deployments/launchable-products',
|
|
1198
|
+
serviceFile: 'deployment-launch',
|
|
1199
|
+
serviceInstance: 'deploymentLaunchService',
|
|
1200
|
+
serviceMethod: 'listLaunchableProducts',
|
|
1201
|
+
httpMethod: 'GET',
|
|
1202
|
+
serviceSource: deploymentLaunchServiceSource,
|
|
1203
|
+
storeImports: [
|
|
1204
|
+
"import type { Product, ProductPlan, ProductVersion } from '@store/model'",
|
|
1205
|
+
],
|
|
1206
|
+
storeTypes: `export type LaunchableDeploymentOption = {
|
|
1207
|
+
key: string
|
|
1208
|
+
label: string
|
|
1209
|
+
providerId: string | null
|
|
1210
|
+
providerSettingId: string
|
|
1211
|
+
providerSettingName: string
|
|
1212
|
+
providerKey: string | null
|
|
1213
|
+
providerLabel: string | null
|
|
1214
|
+
specFormat: string | null
|
|
1215
|
+
resourceUrl: string | null
|
|
1216
|
+
isDefault: boolean
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
export type LaunchableDeploymentProduct = {
|
|
1220
|
+
product: Product
|
|
1221
|
+
productPlan: ProductPlan
|
|
1222
|
+
productVersion: ProductVersion
|
|
1223
|
+
subscriptionId: string
|
|
1224
|
+
deploymentOptions: LaunchableDeploymentOption[]
|
|
1225
|
+
}`,
|
|
1226
|
+
storeEndpoint: ` getLaunchableDeploymentProducts: builder.query<ApiPagingResponse<LaunchableDeploymentProduct>, void>({
|
|
1227
|
+
query: () => '/cms-deployments/launchable-products',
|
|
1228
|
+
transformResponse: (res) => keysToCamel(res),
|
|
1229
|
+
}),`,
|
|
1230
|
+
storeHook: 'useGetLaunchableDeploymentProductsQuery',
|
|
1231
|
+
},
|
|
1232
|
+
],
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
name: 'DeploymentJob',
|
|
1236
|
+
slug: 'deployment-job',
|
|
1237
|
+
route: 'cms-deployment-jobs',
|
|
1238
|
+
responseKey: 'deploymentJob',
|
|
1239
|
+
title: 'Deployment Jobs',
|
|
1240
|
+
icon: 'bi bi-list-check',
|
|
1241
|
+
description: 'Track deployment creation, update, backup, clone, and delete operations.',
|
|
1242
|
+
listFilters: ['deployment_id'],
|
|
1243
|
+
bullets: [
|
|
1244
|
+
'Queue deployment operations',
|
|
1245
|
+
'Capture execution state and errors',
|
|
1246
|
+
'Attach operational payloads to each job',
|
|
1247
|
+
],
|
|
1248
|
+
searchFields: ['job_type', 'status', 'error_message'],
|
|
1249
|
+
fields: [
|
|
1250
|
+
field.uuid('org_id', { nullable: true, references: 'org', skipSchema: true, hideInTable: true }),
|
|
1251
|
+
field.uuid('project_id', { nullable: true, references: 'project', skipSchema: true, hideInTable: true }),
|
|
1252
|
+
field.uuid('deployment_id', { required: true, references: 'deployment', onDelete: 'CASCADE' }),
|
|
1253
|
+
field.uuid('product_id', { nullable: true, references: 'product' }),
|
|
1254
|
+
field.uuid('product_version_id', { nullable: true, references: 'product_version' }),
|
|
1255
|
+
field.uuid('subscription_id', { nullable: true, references: 'product_subscription' }),
|
|
1256
|
+
field.uuid('provider_id', { nullable: true, references: 'provider' }),
|
|
1257
|
+
field.enum('job_type', status.jobType, { required: true }),
|
|
1258
|
+
field.enum('status', status.job, { defaultValue: 'queued' }),
|
|
1259
|
+
field.json('payload', { nullable: true }),
|
|
1260
|
+
field.date('started_at', { nullable: true }),
|
|
1261
|
+
field.date('finished_at', { nullable: true }),
|
|
1262
|
+
field.text('error_message', { nullable: true }),
|
|
1263
|
+
],
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
name: 'DeploymentBackup',
|
|
1267
|
+
slug: 'deployment-backup',
|
|
1268
|
+
route: 'cms-backups',
|
|
1269
|
+
responseKey: 'deploymentBackup',
|
|
1270
|
+
title: 'Backups',
|
|
1271
|
+
icon: 'bi bi-cloud-arrow-up',
|
|
1272
|
+
description: 'Track backup and restore artifacts for deployments.',
|
|
1273
|
+
listFilters: ['deployment_id'],
|
|
1274
|
+
bullets: [
|
|
1275
|
+
'Record manual and scheduled backups',
|
|
1276
|
+
'Track backup storage keys',
|
|
1277
|
+
'Surface backup completion state',
|
|
1278
|
+
],
|
|
1279
|
+
searchFields: ['backup_type', 'storage_key', 'status'],
|
|
1280
|
+
fields: [
|
|
1281
|
+
field.uuid('org_id', { nullable: true, references: 'org', skipSchema: true, hideInTable: true }),
|
|
1282
|
+
field.uuid('project_id', { nullable: true, references: 'project', skipSchema: true, hideInTable: true }),
|
|
1283
|
+
field.uuid('deployment_id', { required: true, references: 'deployment', onDelete: 'CASCADE' }),
|
|
1284
|
+
field.enum('backup_type', status.backupType, { required: true }),
|
|
1285
|
+
field.string('storage_key', { required: true }),
|
|
1286
|
+
field.enum('status', status.backup, { defaultValue: 'pending' }),
|
|
1287
|
+
],
|
|
1288
|
+
},
|
|
1289
|
+
]
|
|
1290
|
+
|
|
1291
|
+
const associations = [
|
|
1292
|
+
{ source: 'Org', method: 'hasMany', target: 'DeploymentTemplate', options: "{ foreignKey: 'org_id', sourceKey: 'id', as: 'deploymentTemplates' }" },
|
|
1293
|
+
{ source: 'DeploymentTemplate', method: 'belongsTo', target: 'Org', options: "{ foreignKey: 'org_id', as: 'org' }" },
|
|
1294
|
+
{ source: 'Org', method: 'hasMany', target: 'Deployment', options: "{ foreignKey: 'org_id', sourceKey: 'id', as: 'deployments' }" },
|
|
1295
|
+
{ source: 'Deployment', method: 'belongsTo', target: 'Org', options: "{ foreignKey: 'org_id', as: 'org' }" },
|
|
1296
|
+
{ source: 'Project', method: 'hasMany', target: 'Deployment', options: "{ foreignKey: 'project_id', sourceKey: 'id', as: 'deployments' }" },
|
|
1297
|
+
{ source: 'Deployment', method: 'belongsTo', target: 'Project', options: "{ foreignKey: 'project_id', as: 'project' }" },
|
|
1298
|
+
{ source: 'User', method: 'hasMany', target: 'Deployment', options: "{ foreignKey: 'owner_user_id', sourceKey: 'id', as: 'deployments' }" },
|
|
1299
|
+
{ source: 'Deployment', method: 'belongsTo', target: 'User', options: "{ foreignKey: 'owner_user_id', as: 'owner' }" },
|
|
1300
|
+
{ source: 'Site', method: 'hasMany', target: 'Deployment', options: "{ foreignKey: 'site_id', sourceKey: 'id', as: 'deployments' }" },
|
|
1301
|
+
{ source: 'Deployment', method: 'belongsTo', target: 'Site', options: "{ foreignKey: 'site_id', as: 'site' }" },
|
|
1302
|
+
{ source: 'Product', method: 'hasMany', target: 'Deployment', options: "{ foreignKey: 'product_id', sourceKey: 'id', as: 'deployments' }" },
|
|
1303
|
+
{ source: 'Deployment', method: 'belongsTo', target: 'Product', options: "{ foreignKey: 'product_id', as: 'product' }" },
|
|
1304
|
+
{ source: 'ProductPlan', method: 'hasMany', target: 'Deployment', options: "{ foreignKey: 'product_plan_id', sourceKey: 'id', as: 'deployments' }" },
|
|
1305
|
+
{ source: 'Deployment', method: 'belongsTo', target: 'ProductPlan', options: "{ foreignKey: 'product_plan_id', as: 'productPlan' }" },
|
|
1306
|
+
{ source: 'ProductVersion', method: 'hasMany', target: 'Deployment', options: "{ foreignKey: 'product_version_id', sourceKey: 'id', as: 'deployments' }" },
|
|
1307
|
+
{ source: 'Deployment', method: 'belongsTo', target: 'ProductVersion', options: "{ foreignKey: 'product_version_id', as: 'productVersion' }" },
|
|
1308
|
+
{ source: 'Subscription', method: 'hasMany', target: 'Deployment', options: "{ foreignKey: 'subscription_id', sourceKey: 'id', as: 'deployments' }" },
|
|
1309
|
+
{ source: 'Deployment', method: 'belongsTo', target: 'Subscription', options: "{ foreignKey: 'subscription_id', as: 'subscription' }" },
|
|
1310
|
+
{ source: 'Provider', method: 'hasMany', target: 'Deployment', options: "{ foreignKey: 'provider_id', sourceKey: 'id', as: 'deployments' }" },
|
|
1311
|
+
{ source: 'Deployment', method: 'belongsTo', target: 'Provider', options: "{ foreignKey: 'provider_id', as: 'provider' }" },
|
|
1312
|
+
{ source: 'ProviderSetting', method: 'hasMany', target: 'Deployment', options: "{ foreignKey: 'provider_setting_id', sourceKey: 'id', as: 'deployments' }" },
|
|
1313
|
+
{ source: 'Deployment', method: 'belongsTo', target: 'ProviderSetting', options: "{ foreignKey: 'provider_setting_id', as: 'providerSetting' }" },
|
|
1314
|
+
{ source: 'DeploymentTemplate', method: 'hasMany', target: 'Deployment', options: "{ foreignKey: 'template_id', sourceKey: 'id', as: 'deployments' }" },
|
|
1315
|
+
{ source: 'Deployment', method: 'belongsTo', target: 'DeploymentTemplate', options: "{ foreignKey: 'template_id', as: 'template' }" },
|
|
1316
|
+
{ source: 'Deployment', method: 'hasMany', target: 'DeploymentJob', options: "{ foreignKey: 'deployment_id', as: 'jobs', onDelete: 'CASCADE' }" },
|
|
1317
|
+
{ source: 'DeploymentJob', method: 'belongsTo', target: 'Deployment', options: "{ foreignKey: 'deployment_id', as: 'deployment' }" },
|
|
1318
|
+
{ source: 'Org', method: 'hasMany', target: 'DeploymentJob', options: "{ foreignKey: 'org_id', sourceKey: 'id', as: 'deploymentJobs' }" },
|
|
1319
|
+
{ source: 'DeploymentJob', method: 'belongsTo', target: 'Org', options: "{ foreignKey: 'org_id', as: 'org' }" },
|
|
1320
|
+
{ source: 'Project', method: 'hasMany', target: 'DeploymentJob', options: "{ foreignKey: 'project_id', sourceKey: 'id', as: 'deploymentJobs' }" },
|
|
1321
|
+
{ source: 'DeploymentJob', method: 'belongsTo', target: 'Project', options: "{ foreignKey: 'project_id', as: 'project' }" },
|
|
1322
|
+
{ source: 'Product', method: 'hasMany', target: 'DeploymentJob', options: "{ foreignKey: 'product_id', sourceKey: 'id', as: 'deploymentJobs' }" },
|
|
1323
|
+
{ source: 'DeploymentJob', method: 'belongsTo', target: 'Product', options: "{ foreignKey: 'product_id', as: 'product' }" },
|
|
1324
|
+
{ source: 'ProductVersion', method: 'hasMany', target: 'DeploymentJob', options: "{ foreignKey: 'product_version_id', sourceKey: 'id', as: 'deploymentJobs' }" },
|
|
1325
|
+
{ source: 'DeploymentJob', method: 'belongsTo', target: 'ProductVersion', options: "{ foreignKey: 'product_version_id', as: 'productVersion' }" },
|
|
1326
|
+
{ source: 'Subscription', method: 'hasMany', target: 'DeploymentJob', options: "{ foreignKey: 'subscription_id', sourceKey: 'id', as: 'deploymentJobs' }" },
|
|
1327
|
+
{ source: 'DeploymentJob', method: 'belongsTo', target: 'Subscription', options: "{ foreignKey: 'subscription_id', as: 'subscription' }" },
|
|
1328
|
+
{ source: 'Provider', method: 'hasMany', target: 'DeploymentJob', options: "{ foreignKey: 'provider_id', sourceKey: 'id', as: 'deploymentJobs' }" },
|
|
1329
|
+
{ source: 'DeploymentJob', method: 'belongsTo', target: 'Provider', options: "{ foreignKey: 'provider_id', as: 'provider' }" },
|
|
1330
|
+
{ source: 'Deployment', method: 'hasMany', target: 'DeploymentBackup', options: "{ foreignKey: 'deployment_id', as: 'backups', onDelete: 'CASCADE' }" },
|
|
1331
|
+
{ source: 'DeploymentBackup', method: 'belongsTo', target: 'Deployment', options: "{ foreignKey: 'deployment_id', as: 'deployment' }" },
|
|
1332
|
+
{ source: 'Org', method: 'hasMany', target: 'DeploymentBackup', options: "{ foreignKey: 'org_id', sourceKey: 'id', as: 'deploymentBackups' }" },
|
|
1333
|
+
{ source: 'DeploymentBackup', method: 'belongsTo', target: 'Org', options: "{ foreignKey: 'org_id', as: 'org' }" },
|
|
1334
|
+
{ source: 'Project', method: 'hasMany', target: 'DeploymentBackup', options: "{ foreignKey: 'project_id', sourceKey: 'id', as: 'deploymentBackups' }" },
|
|
1335
|
+
{ source: 'DeploymentBackup', method: 'belongsTo', target: 'Project', options: "{ foreignKey: 'project_id', as: 'project' }" },
|
|
1336
|
+
]
|
|
1337
|
+
|
|
1338
|
+
export const cmsDefinition = createCrudScaffoldDefinition({
|
|
1339
|
+
title: 'CMS',
|
|
1340
|
+
routePrefix: 'cms-',
|
|
1341
|
+
resources,
|
|
1342
|
+
associations,
|
|
1343
|
+
migrationPrefix: '20260615090',
|
|
1344
|
+
doneMessage: 'CMS deployment system scaffold complete.\nRun again with --force to overwrite existing generated files.',
|
|
1345
|
+
namespace: {
|
|
1346
|
+
camel: 'cms',
|
|
1347
|
+
kebab: 'cms',
|
|
1348
|
+
pascal: 'Cms',
|
|
1349
|
+
title: 'CMS',
|
|
1350
|
+
},
|
|
1351
|
+
scope: {
|
|
1352
|
+
resource: 'deployments',
|
|
1353
|
+
org: { field: 'org_id' },
|
|
1354
|
+
project: { field: 'project_id', picker: true },
|
|
1355
|
+
},
|
|
1356
|
+
api: {
|
|
1357
|
+
root: 'api/lib/cms',
|
|
1358
|
+
importRoot: '@lib/cms',
|
|
1359
|
+
migrationRoot: 'api/lib/cms/migrations',
|
|
1360
|
+
},
|
|
1361
|
+
externalModelImports: {
|
|
1362
|
+
ProviderSetting: '@lib/models',
|
|
1363
|
+
},
|
|
1364
|
+
src: {
|
|
1365
|
+
root: 'src/cms',
|
|
1366
|
+
importRoot: '@/cms',
|
|
1367
|
+
},
|
|
1368
|
+
store: {
|
|
1369
|
+
apiSliceName: 'cmsApiSlice',
|
|
1370
|
+
reducerPath: 'api/cms',
|
|
1371
|
+
insertAfterApiSlice: 'pageApiSlice',
|
|
1372
|
+
},
|
|
1373
|
+
sideNav: {
|
|
1374
|
+
appKey: 'deployments',
|
|
1375
|
+
label: 'Deployments',
|
|
1376
|
+
title: 'Deployments',
|
|
1377
|
+
icon: 'bi bi-rocket-takeoff',
|
|
1378
|
+
primaryRoute: 'cms-deployments',
|
|
1379
|
+
activeRoutes: ['cms-deployments'],
|
|
1380
|
+
previousAdditionalItemKeys: ['deployment-jobs'],
|
|
1381
|
+
resourceSidebar: false,
|
|
1382
|
+
previousAppKeys: ['cms'],
|
|
1383
|
+
},
|
|
1384
|
+
permissions: {
|
|
1385
|
+
appKey: 'deployments',
|
|
1386
|
+
label: 'Deployments',
|
|
1387
|
+
actions: ['read', 'create', 'update', 'delete'],
|
|
1388
|
+
previousAppKeys: ['cms'],
|
|
1389
|
+
insertAfterAppKey: 'providers',
|
|
1390
|
+
},
|
|
1391
|
+
})
|
|
1392
|
+
|
|
1393
|
+
export default cmsDefinition
|