@alpaca-editor/core 1.0.3938 → 1.0.3941
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/dist/components/ActionButton.d.ts +1 -0
- package/dist/components/ActionButton.js +2 -2
- package/dist/components/ActionButton.js.map +1 -1
- package/dist/editor/ContentTree.js +12 -8
- package/dist/editor/ContentTree.js.map +1 -1
- package/dist/editor/ContextMenu.d.ts +1 -1
- package/dist/editor/ContextMenu.js +17 -3
- package/dist/editor/ContextMenu.js.map +1 -1
- package/dist/editor/FieldActionsOverlay.d.ts +18 -0
- package/dist/editor/FieldActionsOverlay.js +139 -0
- package/dist/editor/FieldActionsOverlay.js.map +1 -0
- package/dist/editor/FieldHistory.d.ts +2 -1
- package/dist/editor/FieldHistory.js +11 -8
- package/dist/editor/FieldHistory.js.map +1 -1
- package/dist/editor/FieldListField.js +14 -17
- package/dist/editor/FieldListField.js.map +1 -1
- package/dist/editor/PictureCropper.js +65 -23
- package/dist/editor/PictureCropper.js.map +1 -1
- package/dist/editor/PictureEditor.js +43 -3
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/Titlebar.js +19 -10
- package/dist/editor/Titlebar.js.map +1 -1
- package/dist/editor/ai/AiTerminal.js +27 -41
- package/dist/editor/ai/AiTerminal.js.map +1 -1
- package/dist/editor/ai/GhostWriter.js +21 -2
- package/dist/editor/ai/GhostWriter.js.map +1 -1
- package/dist/editor/client/EditorClient.js +48 -18
- package/dist/editor/client/EditorClient.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +1 -1
- package/dist/editor/client/editContext.js.map +1 -1
- package/dist/editor/client/itemsRepository.js +126 -90
- package/dist/editor/client/itemsRepository.js.map +1 -1
- package/dist/editor/commands/componentCommands.js +7 -3
- package/dist/editor/commands/componentCommands.js.map +1 -1
- package/dist/editor/media-selector/MediaFolderBrowser.d.ts +5 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js +77 -0
- package/dist/editor/media-selector/MediaFolderBrowser.js.map +1 -0
- package/dist/editor/media-selector/MediaSelector.js +1 -1
- package/dist/editor/media-selector/MediaSelector.js.map +1 -1
- package/dist/editor/media-selector/Thumbnails.js +2 -2
- package/dist/editor/media-selector/index.d.ts +8 -0
- package/dist/editor/media-selector/index.js +9 -0
- package/dist/editor/media-selector/index.js.map +1 -0
- package/dist/editor/menubar/BrowseHistory.js +3 -4
- package/dist/editor/menubar/BrowseHistory.js.map +1 -1
- package/dist/editor/menubar/PageSelector.js +62 -10
- package/dist/editor/menubar/PageSelector.js.map +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicator.js +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicator.js.map +1 -1
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js +37 -11
- package/dist/editor/page-editor-chrome/useInlineAICompletion.js.map +1 -1
- package/dist/editor/page-viewer/PageViewerFrame.js +98 -2
- package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
- package/dist/editor/pageModel.d.ts +14 -0
- package/dist/editor/reviews/Comment.js +3 -2
- package/dist/editor/reviews/Comment.js.map +1 -1
- package/dist/editor/services/aiService.js +0 -1
- package/dist/editor/services/aiService.js.map +1 -1
- package/dist/editor/services/editService.d.ts +1 -1
- package/dist/editor/services/editService.js +2 -1
- package/dist/editor/services/editService.js.map +1 -1
- package/dist/editor/sidebar/ComponentTree.js +3 -4
- package/dist/editor/sidebar/ComponentTree.js.map +1 -1
- package/dist/editor/ui/Icons.js +1 -1
- package/dist/editor/ui/Icons.js.map +1 -1
- package/dist/editor/ui/ItemList.d.ts +16 -0
- package/dist/editor/ui/ItemList.js +19 -0
- package/dist/editor/ui/ItemList.js.map +1 -0
- package/dist/editor/ui/ItemSearch.js +2 -12
- package/dist/editor/ui/ItemSearch.js.map +1 -1
- package/dist/editor/ui/SimpleTabs.d.ts +1 -0
- package/dist/editor/ui/SimpleTabs.js +3 -3
- package/dist/editor/ui/SimpleTabs.js.map +1 -1
- package/dist/editor/ui/Splitter.js +61 -6
- package/dist/editor/ui/Splitter.js.map +1 -1
- package/dist/editor/views/MediaFolderEditView.d.ts +4 -0
- package/dist/editor/views/MediaFolderEditView.js +40 -0
- package/dist/editor/views/MediaFolderEditView.js.map +1 -0
- package/dist/editor/views/SingleEditView.js +9 -1
- package/dist/editor/views/SingleEditView.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +64 -13
- package/package.json +8 -2
- package/.prettierrc +0 -3
- package/build.css +0 -3
- package/components.json +0 -21
- package/eslint.config.mjs +0 -4
- package/images/bg-shape-black.webp +0 -0
- package/images/wizard-bg.png +0 -0
- package/images/wizard-tour.png +0 -0
- package/images/wizard.png +0 -0
- package/src/client-components/api.ts +0 -6
- package/src/client-components/index.ts +0 -19
- package/src/components/ActionButton.tsx +0 -41
- package/src/components/Error.tsx +0 -57
- package/src/components/ui/CardConnector.tsx +0 -56
- package/src/components/ui/button.tsx +0 -62
- package/src/components/ui/card.tsx +0 -372
- package/src/components/ui/context-menu.tsx +0 -250
- package/src/config/config.tsx +0 -917
- package/src/config/types.ts +0 -286
- package/src/editor/ComponentInfo.tsx +0 -90
- package/src/editor/ConfirmationDialog.tsx +0 -103
- package/src/editor/ContentTree.tsx +0 -727
- package/src/editor/ContextMenu.tsx +0 -212
- package/src/editor/Editor.tsx +0 -90
- package/src/editor/EditorWarning.tsx +0 -34
- package/src/editor/EditorWarnings.tsx +0 -33
- package/src/editor/FieldEditorPopup.tsx +0 -65
- package/src/editor/FieldHistory.tsx +0 -74
- package/src/editor/FieldList.tsx +0 -190
- package/src/editor/FieldListField.tsx +0 -391
- package/src/editor/FieldListFieldWithFallbacks.tsx +0 -217
- package/src/editor/FloatingToolbar.tsx +0 -163
- package/src/editor/ImageEditor.tsx +0 -128
- package/src/editor/ItemInfo.tsx +0 -90
- package/src/editor/LinkEditorDialog.tsx +0 -196
- package/src/editor/MainLayout.tsx +0 -95
- package/src/editor/MobileLayout.tsx +0 -68
- package/src/editor/NewEditorClient.tsx +0 -11
- package/src/editor/PictureCropper.tsx +0 -503
- package/src/editor/PictureEditor.tsx +0 -212
- package/src/editor/PictureEditorDialog.tsx +0 -381
- package/src/editor/PublishDialog.ignore +0 -74
- package/src/editor/ScrollingContentTree.tsx +0 -67
- package/src/editor/Terminal.tsx +0 -227
- package/src/editor/Titlebar.tsx +0 -93
- package/src/editor/ai/AiPopup.tsx +0 -59
- package/src/editor/ai/AiResponseMessage.tsx +0 -106
- package/src/editor/ai/AiTerminal.tsx +0 -514
- package/src/editor/ai/AiToolCall.tsx +0 -61
- package/src/editor/ai/EditorAiTerminal.tsx +0 -20
- package/src/editor/ai/GhostWriter.tsx +0 -432
- package/src/editor/ai/aiPageModel.ts +0 -108
- package/src/editor/ai/editorAiContext.ts +0 -18
- package/src/editor/client/AboutDialog.tsx +0 -44
- package/src/editor/client/EditorClient.tsx +0 -2197
- package/src/editor/client/GenericDialog.tsx +0 -50
- package/src/editor/client/editContext.ts +0 -412
- package/src/editor/client/helpers.ts +0 -44
- package/src/editor/client/itemsRepository.ts +0 -538
- package/src/editor/client/operations.ts +0 -768
- package/src/editor/client/pageModelBuilder.ts +0 -219
- package/src/editor/commands/commands.ts +0 -22
- package/src/editor/commands/componentCommands.tsx +0 -424
- package/src/editor/commands/createVersionCommand.ts +0 -33
- package/src/editor/commands/deleteVersionCommand.ts +0 -71
- package/src/editor/commands/itemCommands.tsx +0 -351
- package/src/editor/commands/localizeItem/LocalizeItemDialog.tsx +0 -201
- package/src/editor/commands/localizeItem/LocalizeItemUtils.ts +0 -27
- package/src/editor/commands/undo.ts +0 -39
- package/src/editor/component-designer/ComponentDesigner.tsx +0 -70
- package/src/editor/component-designer/ComponentDesignerAiTerminal.tsx +0 -11
- package/src/editor/component-designer/ComponentDesignerMenu.tsx +0 -91
- package/src/editor/component-designer/ComponentEditor.tsx +0 -97
- package/src/editor/component-designer/ComponentRenderingCodeEditor.tsx +0 -31
- package/src/editor/component-designer/ComponentRenderingEditor.tsx +0 -104
- package/src/editor/component-designer/ComponentsDropdown.tsx +0 -39
- package/src/editor/component-designer/PlaceholdersEditor.tsx +0 -179
- package/src/editor/component-designer/RenderingsDropdown.tsx +0 -36
- package/src/editor/component-designer/TemplateEditor.tsx +0 -236
- package/src/editor/component-designer/aiContext.ts +0 -23
- package/src/editor/componentTreeHelper.tsx +0 -116
- package/src/editor/context-menu/CopyMoveMenu.tsx +0 -103
- package/src/editor/context-menu/InsertMenu.tsx +0 -347
- package/src/editor/control-center/About.tsx +0 -342
- package/src/editor/control-center/ControlCenterMenu.tsx +0 -76
- package/src/editor/control-center/IndexOverview.tsx +0 -50
- package/src/editor/control-center/IndexSettings.tsx +0 -266
- package/src/editor/control-center/Info.tsx +0 -104
- package/src/editor/control-center/QuotaInfo.tsx +0 -301
- package/src/editor/control-center/Status.tsx +0 -113
- package/src/editor/control-center/WebSocketMessages.tsx +0 -155
- package/src/editor/editor-warnings/ItemLocked.tsx +0 -63
- package/src/editor/editor-warnings/NoLanguageWriteAccess.tsx +0 -22
- package/src/editor/editor-warnings/NoWorkflowWriteAccess.tsx +0 -23
- package/src/editor/editor-warnings/NoWriteAccess.tsx +0 -16
- package/src/editor/editor-warnings/ValidationErrors.tsx +0 -54
- package/src/editor/field-types/AttachmentEditor.tsx +0 -9
- package/src/editor/field-types/CheckboxEditor.tsx +0 -47
- package/src/editor/field-types/DropLinkEditor.tsx +0 -80
- package/src/editor/field-types/DropListEditor.tsx +0 -84
- package/src/editor/field-types/ImageFieldEditor.tsx +0 -65
- package/src/editor/field-types/InternalLinkFieldEditor.tsx +0 -117
- package/src/editor/field-types/LinkFieldEditor.tsx +0 -85
- package/src/editor/field-types/MultiLineText.tsx +0 -82
- package/src/editor/field-types/PictureFieldEditor.tsx +0 -121
- package/src/editor/field-types/RawEditor.tsx +0 -53
- package/src/editor/field-types/ReactQuill.tsx +0 -580
- package/src/editor/field-types/RichTextEditor.tsx +0 -22
- package/src/editor/field-types/RichTextEditorComponent.tsx +0 -127
- package/src/editor/field-types/SingleLineText.tsx +0 -174
- package/src/editor/field-types/TreeListEditor.tsx +0 -261
- package/src/editor/fieldTypes.ts +0 -140
- package/src/editor/media-selector/AiImageSearch.tsx +0 -185
- package/src/editor/media-selector/AiImageSearchPrompt.tsx +0 -94
- package/src/editor/media-selector/MediaSelector.tsx +0 -42
- package/src/editor/media-selector/Preview.tsx +0 -14
- package/src/editor/media-selector/Thumbnails.tsx +0 -48
- package/src/editor/media-selector/TreeSelector.tsx +0 -292
- package/src/editor/media-selector/UploadZone.tsx +0 -137
- package/src/editor/menubar/ActionsMenu.tsx +0 -94
- package/src/editor/menubar/ActiveUsers.tsx +0 -17
- package/src/editor/menubar/ApproveAndPublish.tsx +0 -18
- package/src/editor/menubar/BrowseHistory.tsx +0 -37
- package/src/editor/menubar/ItemLanguageVersion.tsx +0 -76
- package/src/editor/menubar/LanguageSelector.tsx +0 -226
- package/src/editor/menubar/Menu.tsx +0 -83
- package/src/editor/menubar/NavButtons.tsx +0 -74
- package/src/editor/menubar/PageSelector.tsx +0 -141
- package/src/editor/menubar/PageViewerControls.tsx +0 -120
- package/src/editor/menubar/PreviewSecondaryControls.tsx +0 -18
- package/src/editor/menubar/SecondaryControls.tsx +0 -45
- package/src/editor/menubar/Separator.tsx +0 -12
- package/src/editor/menubar/SiteInfo.tsx +0 -53
- package/src/editor/menubar/User.tsx +0 -27
- package/src/editor/menubar/VersionSelector.tsx +0 -142
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +0 -307
- package/src/editor/page-editor-chrome/CommentHighlightings.tsx +0 -35
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +0 -59
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +0 -23
- package/src/editor/page-editor-chrome/FieldEditedIndicator.tsx +0 -64
- package/src/editor/page-editor-chrome/FieldEditedIndicators.tsx +0 -35
- package/src/editor/page-editor-chrome/FrameMenu.tsx +0 -338
- package/src/editor/page-editor-chrome/FrameMenus.tsx +0 -48
- package/src/editor/page-editor-chrome/InlineEditor.tsx +0 -765
- package/src/editor/page-editor-chrome/LockedFieldIndicator.tsx +0 -61
- package/src/editor/page-editor-chrome/NoLayout.tsx +0 -36
- package/src/editor/page-editor-chrome/PageEditorChrome.tsx +0 -122
- package/src/editor/page-editor-chrome/PictureEditorOverlay.tsx +0 -161
- package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +0 -169
- package/src/editor/page-editor-chrome/PlaceholderDropZones.tsx +0 -315
- package/src/editor/page-editor-chrome/SuggestionHighlighting.tsx +0 -300
- package/src/editor/page-editor-chrome/SuggestionHighlightings.tsx +0 -40
- package/src/editor/page-editor-chrome/useInlineAICompletion.tsx +0 -791
- package/src/editor/page-viewer/DeviceToolbar.tsx +0 -70
- package/src/editor/page-viewer/EditorForm.tsx +0 -258
- package/src/editor/page-viewer/MiniMap.tsx +0 -362
- package/src/editor/page-viewer/PageViewer.tsx +0 -169
- package/src/editor/page-viewer/PageViewerFrame.tsx +0 -879
- package/src/editor/page-viewer/pageModelSkeletonBuilder.ts +0 -412
- package/src/editor/page-viewer/pageViewContext.ts +0 -186
- package/src/editor/pageModel.ts +0 -208
- package/src/editor/picture-shared.tsx +0 -53
- package/src/editor/reviews/Comment.tsx +0 -308
- package/src/editor/reviews/Comments.tsx +0 -125
- package/src/editor/reviews/DiffView.tsx +0 -109
- package/src/editor/reviews/PreviewInfo.tsx +0 -35
- package/src/editor/reviews/Reviews.tsx +0 -280
- package/src/editor/reviews/SuggestedEdit.tsx +0 -316
- package/src/editor/reviews/reviewCommands.tsx +0 -47
- package/src/editor/reviews/useReviews.tsx +0 -70
- package/src/editor/services/aiService.ts +0 -174
- package/src/editor/services/componentDesignerService.ts +0 -151
- package/src/editor/services/contentService.ts +0 -180
- package/src/editor/services/editService.ts +0 -486
- package/src/editor/services/indexService.ts +0 -24
- package/src/editor/services/reviewsService.ts +0 -53
- package/src/editor/services/serviceHelper.ts +0 -95
- package/src/editor/services/suggestedEditsService.ts +0 -39
- package/src/editor/services/systemService.ts +0 -5
- package/src/editor/services/translationService.ts +0 -21
- package/src/editor/services-server/api.ts +0 -150
- package/src/editor/services-server/graphQL.ts +0 -106
- package/src/editor/sidebar/ComponentPalette.tsx +0 -161
- package/src/editor/sidebar/ComponentTree.tsx +0 -548
- package/src/editor/sidebar/ComponentTree2.tsxx +0 -490
- package/src/editor/sidebar/Debug.tsx +0 -111
- package/src/editor/sidebar/DictionaryEditor.tsx +0 -261
- package/src/editor/sidebar/EditHistory.tsx +0 -134
- package/src/editor/sidebar/GraphQL.tsx +0 -164
- package/src/editor/sidebar/Insert.tsx +0 -35
- package/src/editor/sidebar/MainContentTree.tsx +0 -102
- package/src/editor/sidebar/Performance.tsx +0 -53
- package/src/editor/sidebar/Sessions.tsx +0 -35
- package/src/editor/sidebar/Sidebar.tsx +0 -20
- package/src/editor/sidebar/SidebarView.tsx +0 -152
- package/src/editor/sidebar/Translations.tsx +0 -295
- package/src/editor/sidebar/Validation.tsx +0 -102
- package/src/editor/sidebar/ViewSelector.tsx +0 -60
- package/src/editor/sidebar/Workbox.tsx +0 -209
- package/src/editor/ui/CenteredMessage.tsx +0 -7
- package/src/editor/ui/CopyMoveTargetSelectorDialog.tsx +0 -81
- package/src/editor/ui/CopyToClipboardButton.tsx +0 -24
- package/src/editor/ui/DialogButtons.tsx +0 -11
- package/src/editor/ui/Icons.tsx +0 -708
- package/src/editor/ui/ItemNameDialogNew.tsx +0 -118
- package/src/editor/ui/ItemSearch.tsx +0 -190
- package/src/editor/ui/PerfectTree.tsx +0 -571
- package/src/editor/ui/Section.tsx +0 -35
- package/src/editor/ui/SimpleIconButton.tsx +0 -54
- package/src/editor/ui/SimpleMenu.tsx +0 -40
- package/src/editor/ui/SimpleTable.tsx +0 -60
- package/src/editor/ui/SimpleTabs.tsx +0 -55
- package/src/editor/ui/SimpleToolbar.tsx +0 -7
- package/src/editor/ui/Spinner.tsx +0 -9
- package/src/editor/ui/Splitter.tsx +0 -314
- package/src/editor/ui/StackedPanels.tsx +0 -134
- package/src/editor/ui/Toolbar.tsx +0 -7
- package/src/editor/utils/id-helper.ts +0 -3
- package/src/editor/utils/insertOptions.ts +0 -69
- package/src/editor/utils/itemutils.ts +0 -29
- package/src/editor/utils/useMemoDebug.ts +0 -28
- package/src/editor/utils.ts +0 -486
- package/src/editor/views/CompareView.tsx +0 -245
- package/src/editor/views/EditView.tsx +0 -27
- package/src/editor/views/ItemEditor.tsx +0 -58
- package/src/editor/views/SingleEditView.tsx +0 -46
- package/src/fonts/Geist-Black.woff2 +0 -0
- package/src/fonts/Geist-Bold.woff2 +0 -0
- package/src/fonts/Geist-ExtraBold.woff2 +0 -0
- package/src/fonts/Geist-ExtraLight.woff2 +0 -0
- package/src/fonts/Geist-Light.woff2 +0 -0
- package/src/fonts/Geist-Medium.woff2 +0 -0
- package/src/fonts/Geist-Regular.woff2 +0 -0
- package/src/fonts/Geist-SemiBold.woff2 +0 -0
- package/src/fonts/Geist-Thin.woff2 +0 -0
- package/src/fonts/Geist[wght].woff2 +0 -0
- package/src/fonts/index.ts +0 -10
- package/src/index.ts +0 -23
- package/src/lib/safelist.tsx +0 -16
- package/src/lib/utils.ts +0 -6
- package/src/page-wizard/PageWizard.tsx +0 -139
- package/src/page-wizard/WizardBox.tsx +0 -4
- package/src/page-wizard/WizardBoxConnector.tsx +0 -56
- package/src/page-wizard/WizardSteps.tsx +0 -458
- package/src/page-wizard/service.ts +0 -35
- package/src/page-wizard/startPageWizardCommand.ts +0 -26
- package/src/page-wizard/steps/BuildPageStep.tsx +0 -259
- package/src/page-wizard/steps/CollectStep.tsx +0 -296
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +0 -454
- package/src/page-wizard/steps/Components.tsx +0 -193
- package/src/page-wizard/steps/ContentStep.tsx +0 -890
- package/src/page-wizard/steps/EditButton.tsx +0 -34
- package/src/page-wizard/steps/FieldEditor.tsx +0 -102
- package/src/page-wizard/steps/Generate.tsx +0 -60
- package/src/page-wizard/steps/ImagesStep.tsx +0 -382
- package/src/page-wizard/steps/LayoutStep.tsx +0 -227
- package/src/page-wizard/steps/MetaDataStep.tsx +0 -173
- package/src/page-wizard/steps/SelectStep.tsx +0 -281
- package/src/page-wizard/steps/schema.ts +0 -180
- package/src/page-wizard/steps/usePageCreator.ts +0 -325
- package/src/page-wizard/usePageWizard.ts +0 -79
- package/src/revision.ts +0 -2
- package/src/splash-screen/NewPage.tsx +0 -294
- package/src/splash-screen/OpenPage.tsx +0 -113
- package/src/splash-screen/RecentPages.tsx +0 -123
- package/src/splash-screen/SectionHeadline.tsx +0 -21
- package/src/splash-screen/SplashScreen.tsx +0 -195
- package/src/tour/Tour.tsx +0 -566
- package/src/tour/default-tour.tsx +0 -301
- package/src/tour/preview-tour.tsx +0 -128
- package/src/types.ts +0 -335
- package/styles.css +0 -765
- package/tsconfig.build.json +0 -31
- package/tsconfig.json +0 -14
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { TranslationStatus } from "../../config/types";
|
|
2
|
-
import { LanguagesAndVersions } from "../../types";
|
|
3
|
-
import { get, post } from "./serviceHelper";
|
|
4
|
-
|
|
5
|
-
export async function requestTranslation({itemId, targetLanguage, sourceLanguage, sessionId, provider, metadata}: {itemId: string, targetLanguage: string, sourceLanguage: string, sessionId: string, provider: string, metadata: string} ) {
|
|
6
|
-
return await post<LanguagesAndVersions>(
|
|
7
|
-
"/alpaca/editor/translation/requestTranslation",
|
|
8
|
-
{ itemId, targetLanguage, sourceLanguage, sessionId, provider, metadata }
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export async function getTranslationStatus(itemId: string) {
|
|
14
|
-
return await get<TranslationStatus[]>(
|
|
15
|
-
`/alpaca/editor/translation/getTranslations?itemId=${itemId}`
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export async function getTranslationProviders() {
|
|
20
|
-
return await get<string[]>(`/alpaca/editor/translation/providers`);
|
|
21
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import "server-only";
|
|
2
|
-
|
|
3
|
-
import { headers } from "next/headers";
|
|
4
|
-
import axios, { AxiosRequestHeaders, AxiosResponse } from "axios";
|
|
5
|
-
|
|
6
|
-
export type FetchOptions = {
|
|
7
|
-
tags?: string[];
|
|
8
|
-
revalidate?: number | false;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type FetchResult = {
|
|
12
|
-
status: number;
|
|
13
|
-
error?: string;
|
|
14
|
-
data?: any;
|
|
15
|
-
headers: Headers;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type ApiConfig = {
|
|
19
|
-
apiKey?: string;
|
|
20
|
-
headers?: Headers;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export async function apiGet(
|
|
24
|
-
route: string,
|
|
25
|
-
config?: ApiConfig
|
|
26
|
-
): Promise<FetchResult> {
|
|
27
|
-
const url = process.env.LAYOUT_SERVICE_URL + route;
|
|
28
|
-
|
|
29
|
-
const requestHeaders: any = getRequestHeaders(config);
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const response: AxiosResponse = await axios.get(url, {
|
|
33
|
-
headers: requestHeaders,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
data: response.data,
|
|
38
|
-
status: response.status,
|
|
39
|
-
headers: convertAxiosHeaders(response.headers),
|
|
40
|
-
};
|
|
41
|
-
} catch (error: any) {
|
|
42
|
-
if (error.response) {
|
|
43
|
-
return {
|
|
44
|
-
status: error.response.status,
|
|
45
|
-
error: error.response.statusText,
|
|
46
|
-
headers: convertAxiosHeaders(error.response.headers),
|
|
47
|
-
};
|
|
48
|
-
} else {
|
|
49
|
-
return {
|
|
50
|
-
status: 500,
|
|
51
|
-
error: error.message,
|
|
52
|
-
headers: convertAxiosHeaders(error.response.headers),
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function getRequestHeaders(config?: ApiConfig): AxiosRequestHeaders {
|
|
59
|
-
const requestHeaders: AxiosRequestHeaders = {} as AxiosRequestHeaders;
|
|
60
|
-
|
|
61
|
-
// Convert Headers (node-fetch) to AxiosRequestHeaders (plain object)
|
|
62
|
-
if (config?.headers) {
|
|
63
|
-
config.headers.forEach((value, key) => {
|
|
64
|
-
requestHeaders[key] = value;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Set default headers
|
|
69
|
-
requestHeaders["Content-Type"] = "application/json";
|
|
70
|
-
requestHeaders["x-api-key"] = config?.apiKey ?? getApiKey();
|
|
71
|
-
|
|
72
|
-
return requestHeaders;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export async function apiPostObject(
|
|
76
|
-
route: string,
|
|
77
|
-
object: any,
|
|
78
|
-
config?: ApiConfig
|
|
79
|
-
): Promise<FetchResult> {
|
|
80
|
-
const url = process.env.LAYOUT_SERVICE_URL + route;
|
|
81
|
-
|
|
82
|
-
const requestHeaders: any = getRequestHeaders(config);
|
|
83
|
-
|
|
84
|
-
const body = JSON.stringify(object);
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
const response: AxiosResponse = await axios.post(url, body, {
|
|
88
|
-
headers: requestHeaders,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
data: response.data,
|
|
93
|
-
status: response.status,
|
|
94
|
-
headers: convertAxiosHeaders(response.headers),
|
|
95
|
-
};
|
|
96
|
-
} catch (error: any) {
|
|
97
|
-
if (error.errors) {
|
|
98
|
-
let message = "";
|
|
99
|
-
error.errors.forEach((error: any) => {
|
|
100
|
-
message += error.message + " ";
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
status: 500,
|
|
105
|
-
error: message,
|
|
106
|
-
headers: new Headers(),
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
if (error.response) {
|
|
110
|
-
return {
|
|
111
|
-
status: error.response.status,
|
|
112
|
-
error: error.response.statusText,
|
|
113
|
-
headers: convertAxiosHeaders(error.response.headers),
|
|
114
|
-
};
|
|
115
|
-
} else {
|
|
116
|
-
return {
|
|
117
|
-
status: 500,
|
|
118
|
-
error: error.message,
|
|
119
|
-
headers: new Headers(),
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function getApiKey() {
|
|
126
|
-
const apiKey = process.env.ALPACA_HEADLESS_API_KEY || process.env.API_KEY;
|
|
127
|
-
if (!apiKey)
|
|
128
|
-
console.log(
|
|
129
|
-
"ERROR: Could not find API key environment variable: ALPACA_HEADLESS_API_KEY"
|
|
130
|
-
);
|
|
131
|
-
return apiKey;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function convertAxiosHeaders(headers: any): Headers {
|
|
135
|
-
const convertedHeaders = new Headers();
|
|
136
|
-
for (const key in headers) {
|
|
137
|
-
if (headers.hasOwnProperty(key)) {
|
|
138
|
-
convertedHeaders.set(key.toLowerCase(), headers[key]);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return convertedHeaders;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export async function getApiHeaders() {
|
|
145
|
-
const requestHeaders = await headers();
|
|
146
|
-
const apiHeaders = new Headers();
|
|
147
|
-
apiHeaders.set("Cookie", requestHeaders.get("Cookie") || "");
|
|
148
|
-
apiHeaders.set("Authorization", requestHeaders.get("Authorization") || "");
|
|
149
|
-
return apiHeaders;
|
|
150
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { ApiConfig, apiGet, apiPostObject } from "../services-server/api";
|
|
2
|
-
|
|
3
|
-
export type ExecuteGraphQLParams = {
|
|
4
|
-
query: string;
|
|
5
|
-
tags?: string[];
|
|
6
|
-
host?: string;
|
|
7
|
-
path?: string;
|
|
8
|
-
language?: string;
|
|
9
|
-
mode?: string;
|
|
10
|
-
itemId?: string;
|
|
11
|
-
version?: number;
|
|
12
|
-
revalidate?: number;
|
|
13
|
-
siteName?: string;
|
|
14
|
-
sessionId?: string;
|
|
15
|
-
schema?: string;
|
|
16
|
-
apiConfig?: ApiConfig;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export async function executeGraphQLQuery({
|
|
20
|
-
query,
|
|
21
|
-
host,
|
|
22
|
-
path,
|
|
23
|
-
language,
|
|
24
|
-
mode,
|
|
25
|
-
itemId,
|
|
26
|
-
version,
|
|
27
|
-
// tags,
|
|
28
|
-
// revalidate,
|
|
29
|
-
siteName,
|
|
30
|
-
schema,
|
|
31
|
-
sessionId,
|
|
32
|
-
apiConfig,
|
|
33
|
-
}: ExecuteGraphQLParams) {
|
|
34
|
-
let url = "/alpaca/headless/graphql";
|
|
35
|
-
|
|
36
|
-
if (sessionId) url += "?sessionId=" + sessionId;
|
|
37
|
-
|
|
38
|
-
//console.log(`GraphQL query:`, query);
|
|
39
|
-
|
|
40
|
-
const request: {
|
|
41
|
-
Host?: string;
|
|
42
|
-
Path?: string;
|
|
43
|
-
ItemId?: string;
|
|
44
|
-
Language?: string;
|
|
45
|
-
Version?: number;
|
|
46
|
-
Mode?: string;
|
|
47
|
-
Query: string;
|
|
48
|
-
SiteName?: string;
|
|
49
|
-
Schema?: string;
|
|
50
|
-
} = {
|
|
51
|
-
Query: query,
|
|
52
|
-
Host: host,
|
|
53
|
-
Path: path,
|
|
54
|
-
ItemId: itemId,
|
|
55
|
-
Language: language,
|
|
56
|
-
Version: version,
|
|
57
|
-
Mode: mode,
|
|
58
|
-
SiteName: siteName,
|
|
59
|
-
Schema: schema,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
//TODO: cache:
|
|
63
|
-
|
|
64
|
-
const response = await apiPostObject(url, request, apiConfig);
|
|
65
|
-
|
|
66
|
-
if (response.status !== 200) {
|
|
67
|
-
return { status: response.status, errors: getErrors(response) };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (response.data?.errors) {
|
|
71
|
-
return {
|
|
72
|
-
status: 400,
|
|
73
|
-
errors: response.data?.errors,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
data: response.data?.data,
|
|
79
|
-
status: response.status,
|
|
80
|
-
errors: getErrors(response),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function getErrors(response: any) {
|
|
85
|
-
if (response.data?.errors) return response.data?.errors;
|
|
86
|
-
if (response.error) return [{ message: response.error }];
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export async function getGraphQLSchema({
|
|
91
|
-
id,
|
|
92
|
-
apiConfig,
|
|
93
|
-
}: {
|
|
94
|
-
id: string;
|
|
95
|
-
apiConfig: ApiConfig;
|
|
96
|
-
}) {
|
|
97
|
-
let url = "/alpaca/headless/graphql/schema?id=" + id;
|
|
98
|
-
|
|
99
|
-
const response = await apiGet(url, apiConfig);
|
|
100
|
-
|
|
101
|
-
if (response.status !== 200) {
|
|
102
|
-
return { status: response.status, error: response.error };
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return response.data;
|
|
106
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { getInsertOptionsForCurrentSelection } from "../utils/insertOptions";
|
|
2
|
-
import { ArrowDownIcon } from "../ui/Icons";
|
|
3
|
-
|
|
4
|
-
import { getAbsoluteIconUrl } from "../utils";
|
|
5
|
-
import { classNames } from "primereact/utils";
|
|
6
|
-
import { InsertOption } from "../../types";
|
|
7
|
-
|
|
8
|
-
import { useEditContext } from "../client/editContext";
|
|
9
|
-
import { InputText } from "primereact/inputtext";
|
|
10
|
-
import { useState, useRef } from "react";
|
|
11
|
-
|
|
12
|
-
export function ComponentPalette({}: {}) {
|
|
13
|
-
const editContext = useEditContext()!;
|
|
14
|
-
const [filter, setFilter] = useState("");
|
|
15
|
-
const filterRef = useRef<HTMLInputElement>(null);
|
|
16
|
-
|
|
17
|
-
const insertOptions = getInsertOptionsForCurrentSelection(editContext);
|
|
18
|
-
|
|
19
|
-
const insertOptionsByGroup = insertOptions.reduce(
|
|
20
|
-
(acc, value) => {
|
|
21
|
-
const group = value.group || "Other";
|
|
22
|
-
if (!acc[group]) {
|
|
23
|
-
acc[group] = [];
|
|
24
|
-
}
|
|
25
|
-
acc[group].push(value);
|
|
26
|
-
return acc;
|
|
27
|
-
},
|
|
28
|
-
{} as { [key: string]: InsertOption[] },
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div className="tour-component-palette relative flex h-full flex-col">
|
|
33
|
-
<div className="p-4">
|
|
34
|
-
<div className="relative flex items-center">
|
|
35
|
-
<input
|
|
36
|
-
ref={filterRef}
|
|
37
|
-
type="text"
|
|
38
|
-
value={filter}
|
|
39
|
-
onChange={(e) => setFilter(e.target.value)}
|
|
40
|
-
className="w-full rounded border border-gray-300 px-2 py-1 pr-6 text-xs focus:border-blue-400 focus:ring-1 focus:ring-blue-400 focus:outline-none"
|
|
41
|
-
placeholder="Filter..."
|
|
42
|
-
/>
|
|
43
|
-
{!filter && (
|
|
44
|
-
<i className="pi pi-search absolute right-2 text-xs text-gray-400" />
|
|
45
|
-
)}
|
|
46
|
-
{filter && (
|
|
47
|
-
<i
|
|
48
|
-
className="pi pi-times absolute right-2 cursor-pointer text-xs text-gray-400 hover:text-gray-600"
|
|
49
|
-
onClick={() => setFilter("")}
|
|
50
|
-
/>
|
|
51
|
-
)}
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
<div className="relative flex-1">
|
|
55
|
-
<div className="absolute inset-0 overflow-y-auto">
|
|
56
|
-
{Object.keys(insertOptionsByGroup)
|
|
57
|
-
.sort()
|
|
58
|
-
.map((group, index) => {
|
|
59
|
-
const options = insertOptionsByGroup[group]!.filter(
|
|
60
|
-
(x) => !x.isHidden,
|
|
61
|
-
).filter(
|
|
62
|
-
(x) => x.name.toLowerCase().indexOf(filter.toLowerCase()) > -1,
|
|
63
|
-
);
|
|
64
|
-
if (options.length === 0) return;
|
|
65
|
-
return (
|
|
66
|
-
<div
|
|
67
|
-
className={classNames(
|
|
68
|
-
"m-4",
|
|
69
|
-
index > 0 ? "border-t border-gray-200" : "",
|
|
70
|
-
)}
|
|
71
|
-
key={group}
|
|
72
|
-
>
|
|
73
|
-
<div className="mt-2 mb-3 flex items-center gap-2 text-xs font-bold">
|
|
74
|
-
<ArrowDownIcon /> {group}
|
|
75
|
-
</div>
|
|
76
|
-
<div className="grid grid-cols-[repeat(auto-fill,_minmax(70px,_1fr))] gap-4">
|
|
77
|
-
{options.map((option) => {
|
|
78
|
-
function handleDragStart(
|
|
79
|
-
event: React.DragEvent<HTMLDivElement>,
|
|
80
|
-
): void {
|
|
81
|
-
editContext?.dragStart({
|
|
82
|
-
type: "template",
|
|
83
|
-
typeId: option.typeId,
|
|
84
|
-
name: option.name,
|
|
85
|
-
});
|
|
86
|
-
event.stopPropagation();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function handleDragEnd(): void {
|
|
90
|
-
editContext!.dragEnd();
|
|
91
|
-
editContext!.setSelectedForInsertion("");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const isDraggable = !option.isInvalid;
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<div
|
|
98
|
-
id={"insert-component-" + option.typeId}
|
|
99
|
-
onClick={() => {
|
|
100
|
-
editContext!.setSelectedForInsertion(option.typeId);
|
|
101
|
-
}}
|
|
102
|
-
draggable={isDraggable}
|
|
103
|
-
onDragStart={handleDragStart}
|
|
104
|
-
onDragEnd={handleDragEnd}
|
|
105
|
-
className={classNames(
|
|
106
|
-
"relative flex flex-col items-center gap-2 rounded border border-gray-200 p-2 text-center text-xs break-all",
|
|
107
|
-
isDraggable ? "cursor-grab" : "",
|
|
108
|
-
editContext.selectedForInsertion === option.typeId
|
|
109
|
-
? "border-sky-500"
|
|
110
|
-
: "",
|
|
111
|
-
)}
|
|
112
|
-
key={option.typeId}
|
|
113
|
-
data-testid="insert-component-option"
|
|
114
|
-
>
|
|
115
|
-
{option.svg && (
|
|
116
|
-
<div
|
|
117
|
-
className="h-8 w-8"
|
|
118
|
-
dangerouslySetInnerHTML={{ __html: option.svg }}
|
|
119
|
-
></div>
|
|
120
|
-
)}
|
|
121
|
-
{!option.svg && (
|
|
122
|
-
<img
|
|
123
|
-
src={getAbsoluteIconUrl(option.icon)}
|
|
124
|
-
width="32"
|
|
125
|
-
height="32"
|
|
126
|
-
></img>
|
|
127
|
-
)}
|
|
128
|
-
|
|
129
|
-
<div className="text-xs">
|
|
130
|
-
{option.name
|
|
131
|
-
.split(new RegExp(`(${filter})`, "i"))
|
|
132
|
-
.map((part: string, i: number) =>
|
|
133
|
-
part.toLowerCase() === filter.toLowerCase() &&
|
|
134
|
-
part ? (
|
|
135
|
-
<u className="font-bold" key={i}>
|
|
136
|
-
{part}
|
|
137
|
-
</u>
|
|
138
|
-
) : (
|
|
139
|
-
part && <span key={i}>{part}</span>
|
|
140
|
-
),
|
|
141
|
-
)}
|
|
142
|
-
</div>
|
|
143
|
-
|
|
144
|
-
{option.isInvalid && (
|
|
145
|
-
<i
|
|
146
|
-
className="pi pi-exclamation-triangle absolute top-0 right-0 text-red-500"
|
|
147
|
-
title={option.message}
|
|
148
|
-
/>
|
|
149
|
-
)}
|
|
150
|
-
</div>
|
|
151
|
-
);
|
|
152
|
-
})}
|
|
153
|
-
</div>
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
})}
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
</div>
|
|
160
|
-
);
|
|
161
|
-
}
|