@webiny/ai-powerups 6.3.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AiPowerups.d.ts +2 -0
- package/AiPowerups.js +12 -0
- package/AiPowerups.js.map +1 -0
- package/LICENSE +36 -0
- package/README.md +11 -0
- package/admin/Extension.d.ts +2 -0
- package/admin/Extension.js +31 -0
- package/admin/Extension.js.map +1 -0
- package/admin/features/feature.d.ts +1 -0
- package/admin/features/feature.js +21 -0
- package/admin/features/feature.js.map +1 -0
- package/admin/features/generatePageContent/GeneratePageContentGateway.d.ts +12 -0
- package/admin/features/generatePageContent/GeneratePageContentGateway.js +26 -0
- package/admin/features/generatePageContent/GeneratePageContentGateway.js.map +1 -0
- package/admin/features/generatePageContent/GeneratePageContentUseCase.d.ts +11 -0
- package/admin/features/generatePageContent/GeneratePageContentUseCase.js +15 -0
- package/admin/features/generatePageContent/GeneratePageContentUseCase.js.map +1 -0
- package/admin/features/generatePageContent/abstractions.d.ts +20 -0
- package/admin/features/generatePageContent/abstractions.js +5 -0
- package/admin/features/generatePageContent/abstractions.js.map +1 -0
- package/admin/features/generatePageContent/feature.d.ts +1 -0
- package/admin/features/generatePageContent/feature.js +12 -0
- package/admin/features/generatePageContent/feature.js.map +1 -0
- package/admin/features/generatePageContent/index.d.ts +3 -0
- package/admin/features/generatePageContent/index.js +4 -0
- package/admin/features/generatePageContent/index.js.map +1 -0
- package/admin/features/listModels/ListModelsGateway.d.ts +12 -0
- package/admin/features/listModels/ListModelsGateway.js +31 -0
- package/admin/features/listModels/ListModelsGateway.js.map +1 -0
- package/admin/features/listModels/ListModelsRepository.d.ts +13 -0
- package/admin/features/listModels/ListModelsRepository.js +24 -0
- package/admin/features/listModels/ListModelsRepository.js.map +1 -0
- package/admin/features/listModels/ListModelsUseCase.d.ts +10 -0
- package/admin/features/listModels/ListModelsUseCase.js +15 -0
- package/admin/features/listModels/ListModelsUseCase.js.map +1 -0
- package/admin/features/listModels/abstractions.d.ts +28 -0
- package/admin/features/listModels/abstractions.js +6 -0
- package/admin/features/listModels/abstractions.js.map +1 -0
- package/admin/features/listModels/feature.d.ts +3 -0
- package/admin/features/listModels/feature.js +20 -0
- package/admin/features/listModels/feature.js.map +1 -0
- package/admin/features/listModels/index.d.ts +2 -0
- package/admin/features/listModels/index.js +4 -0
- package/admin/features/listModels/index.js.map +1 -0
- package/admin/features/settings/getSettings/GetSettingsGateway.d.ts +11 -0
- package/admin/features/settings/getSettings/GetSettingsGateway.js +26 -0
- package/admin/features/settings/getSettings/GetSettingsGateway.js.map +1 -0
- package/admin/features/settings/getSettings/GetSettingsRepository.d.ts +12 -0
- package/admin/features/settings/getSettings/GetSettingsRepository.js +23 -0
- package/admin/features/settings/getSettings/GetSettingsRepository.js.map +1 -0
- package/admin/features/settings/getSettings/GetSettingsUseCase.d.ts +10 -0
- package/admin/features/settings/getSettings/GetSettingsUseCase.js +15 -0
- package/admin/features/settings/getSettings/GetSettingsUseCase.js.map +1 -0
- package/admin/features/settings/getSettings/abstractions.d.ts +22 -0
- package/admin/features/settings/getSettings/abstractions.js +6 -0
- package/admin/features/settings/getSettings/abstractions.js.map +1 -0
- package/admin/features/settings/getSettings/feature.d.ts +3 -0
- package/admin/features/settings/getSettings/feature.js +20 -0
- package/admin/features/settings/getSettings/feature.js.map +1 -0
- package/admin/features/settings/getSettings/index.d.ts +2 -0
- package/admin/features/settings/getSettings/index.js +4 -0
- package/admin/features/settings/getSettings/index.js.map +1 -0
- package/admin/features/settings/shared/SettingsCache.d.ts +9 -0
- package/admin/features/settings/shared/SettingsCache.js +18 -0
- package/admin/features/settings/shared/SettingsCache.js.map +1 -0
- package/admin/features/settings/shared/abstractions.d.ts +9 -0
- package/admin/features/settings/shared/abstractions.js +21 -0
- package/admin/features/settings/shared/abstractions.js.map +1 -0
- package/admin/features/settings/shared/feature.d.ts +1 -0
- package/admin/features/settings/shared/feature.js +14 -0
- package/admin/features/settings/shared/feature.js.map +1 -0
- package/admin/features/settings/shared/index.d.ts +2 -0
- package/admin/features/settings/shared/index.js +4 -0
- package/admin/features/settings/shared/index.js.map +1 -0
- package/admin/features/settings/updateSettings/UpdateSettingsGateway.d.ts +12 -0
- package/admin/features/settings/updateSettings/UpdateSettingsGateway.js +29 -0
- package/admin/features/settings/updateSettings/UpdateSettingsGateway.js.map +1 -0
- package/admin/features/settings/updateSettings/UpdateSettingsRepository.d.ts +13 -0
- package/admin/features/settings/updateSettings/UpdateSettingsRepository.js +19 -0
- package/admin/features/settings/updateSettings/UpdateSettingsRepository.js.map +1 -0
- package/admin/features/settings/updateSettings/UpdateSettingsUseCase.d.ts +11 -0
- package/admin/features/settings/updateSettings/UpdateSettingsUseCase.js +15 -0
- package/admin/features/settings/updateSettings/UpdateSettingsUseCase.js.map +1 -0
- package/admin/features/settings/updateSettings/abstractions.d.ts +22 -0
- package/admin/features/settings/updateSettings/abstractions.js +6 -0
- package/admin/features/settings/updateSettings/abstractions.js.map +1 -0
- package/admin/features/settings/updateSettings/feature.d.ts +3 -0
- package/admin/features/settings/updateSettings/feature.js +20 -0
- package/admin/features/settings/updateSettings/feature.js.map +1 -0
- package/admin/features/settings/updateSettings/index.d.ts +2 -0
- package/admin/features/settings/updateSettings/index.js +4 -0
- package/admin/features/settings/updateSettings/index.js.map +1 -0
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsConfig.d.ts +2 -0
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsConfig.js +11 -0
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsConfig.js.map +1 -0
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsDialog.d.ts +5 -0
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsDialog.js +58 -0
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsDialog.js.map +1 -0
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPresenter.d.ts +25 -0
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPresenter.js +140 -0
- package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPresenter.js.map +1 -0
- package/admin/presentation/AiPowerUpsSettings/abstractions.d.ts +17 -0
- package/admin/presentation/AiPowerUpsSettings/abstractions.js +4 -0
- package/admin/presentation/AiPowerUpsSettings/abstractions.js.map +1 -0
- package/admin/presentation/AiPowerUpsSettings/feature.d.ts +3 -0
- package/admin/presentation/AiPowerUpsSettings/feature.js +21 -0
- package/admin/presentation/AiPowerUpsSettings/feature.js.map +1 -0
- package/admin/presentation/AiPowerUpsSettings/index.d.ts +5 -0
- package/admin/presentation/AiPowerUpsSettings/index.js +7 -0
- package/admin/presentation/AiPowerUpsSettings/index.js.map +1 -0
- package/admin/presentation/AiPowerUpsSettings/settingsGroup.d.ts +18 -0
- package/admin/presentation/AiPowerUpsSettings/settingsGroup.js +4 -0
- package/admin/presentation/AiPowerUpsSettings/settingsGroup.js.map +1 -0
- package/admin/presentation/AiPowerUpsSettings/useAiPowerUpsSettingsDialog.d.ts +1 -0
- package/admin/presentation/AiPowerUpsSettings/useAiPowerUpsSettingsDialog.js +12 -0
- package/admin/presentation/AiPowerUpsSettings/useAiPowerUpsSettingsDialog.js.map +1 -0
- package/admin/presentation/PersonasSettings.d.ts +11 -0
- package/admin/presentation/PersonasSettings.js +28 -0
- package/admin/presentation/PersonasSettings.js.map +1 -0
- package/admin/presentation/ProvidersSettings.d.ts +16 -0
- package/admin/presentation/ProvidersSettings.js +37 -0
- package/admin/presentation/ProvidersSettings.js.map +1 -0
- package/admin/presentation/WbContentGeneration/Extension.d.ts +2 -0
- package/admin/presentation/WbContentGeneration/Extension.js +23 -0
- package/admin/presentation/WbContentGeneration/Extension.js.map +1 -0
- package/admin/presentation/WbContentGeneration/GenerateContentButton.d.ts +2 -0
- package/admin/presentation/WbContentGeneration/GenerateContentButton.js +17 -0
- package/admin/presentation/WbContentGeneration/GenerateContentButton.js.map +1 -0
- package/admin/presentation/WbContentGeneration/GenerateContentDialog.d.ts +21 -0
- package/admin/presentation/WbContentGeneration/GenerateContentDialog.js +102 -0
- package/admin/presentation/WbContentGeneration/GenerateContentDialog.js.map +1 -0
- package/admin/presentation/WbContentGeneration/GenerateContentPresenter.d.ts +24 -0
- package/admin/presentation/WbContentGeneration/GenerateContentPresenter.js +91 -0
- package/admin/presentation/WbContentGeneration/GenerateContentPresenter.js.map +1 -0
- package/admin/presentation/WbContentGeneration/PROCESS_IDEA.md +190 -0
- package/admin/presentation/WbContentGeneration/abstractions.d.ts +28 -0
- package/admin/presentation/WbContentGeneration/abstractions.js +4 -0
- package/admin/presentation/WbContentGeneration/abstractions.js.map +1 -0
- package/admin/presentation/WbContentGeneration/decompressGzipBase64.d.ts +1 -0
- package/admin/presentation/WbContentGeneration/decompressGzipBase64.js +14 -0
- package/admin/presentation/WbContentGeneration/decompressGzipBase64.js.map +1 -0
- package/admin/presentation/WbContentGeneration/feature.d.ts +3 -0
- package/admin/presentation/WbContentGeneration/feature.js +16 -0
- package/admin/presentation/WbContentGeneration/feature.js.map +1 -0
- package/api/Extension.d.ts +4 -0
- package/api/Extension.js +16 -0
- package/api/Extension.js.map +1 -0
- package/api/constants.d.ts +1 -0
- package/api/constants.js +3 -0
- package/api/constants.js.map +1 -0
- package/api/features/GetSettings/GetSettingsRepository.d.ts +15 -0
- package/api/features/GetSettings/GetSettingsRepository.js +45 -0
- package/api/features/GetSettings/GetSettingsRepository.js.map +1 -0
- package/api/features/GetSettings/GetSettingsUseCase.d.ts +10 -0
- package/api/features/GetSettings/GetSettingsUseCase.js +15 -0
- package/api/features/GetSettings/GetSettingsUseCase.js.map +1 -0
- package/api/features/GetSettings/abstractions.d.ts +16 -0
- package/api/features/GetSettings/abstractions.js +5 -0
- package/api/features/GetSettings/abstractions.js.map +1 -0
- package/api/features/GetSettings/feature.d.ts +4 -0
- package/api/features/GetSettings/feature.js +12 -0
- package/api/features/GetSettings/feature.js.map +1 -0
- package/api/features/GetSettings/index.d.ts +1 -0
- package/api/features/GetSettings/index.js +3 -0
- package/api/features/GetSettings/index.js.map +1 -0
- package/api/features/UpdateSettings/UpdateSettingsRepository.d.ts +15 -0
- package/api/features/UpdateSettings/UpdateSettingsRepository.js +42 -0
- package/api/features/UpdateSettings/UpdateSettingsRepository.js.map +1 -0
- package/api/features/UpdateSettings/UpdateSettingsUseCase.d.ts +14 -0
- package/api/features/UpdateSettings/UpdateSettingsUseCase.js +40 -0
- package/api/features/UpdateSettings/UpdateSettingsUseCase.js.map +1 -0
- package/api/features/UpdateSettings/abstractions.d.ts +46 -0
- package/api/features/UpdateSettings/abstractions.js +10 -0
- package/api/features/UpdateSettings/abstractions.js.map +1 -0
- package/api/features/UpdateSettings/events.d.ts +10 -0
- package/api/features/UpdateSettings/events.js +16 -0
- package/api/features/UpdateSettings/events.js.map +1 -0
- package/api/features/UpdateSettings/feature.d.ts +4 -0
- package/api/features/UpdateSettings/feature.js +12 -0
- package/api/features/UpdateSettings/feature.js.map +1 -0
- package/api/features/UpdateSettings/index.d.ts +1 -0
- package/api/features/UpdateSettings/index.js +3 -0
- package/api/features/UpdateSettings/index.js.map +1 -0
- package/api/features/UpdateSettings/validation.d.ts +17 -0
- package/api/features/UpdateSettings/validation.js +21 -0
- package/api/features/UpdateSettings/validation.js.map +1 -0
- package/api/features/WbGeneratePageContent/WbGeneratePageContentTask.d.ts +29 -0
- package/api/features/WbGeneratePageContent/WbGeneratePageContentTask.js +72 -0
- package/api/features/WbGeneratePageContent/WbGeneratePageContentTask.js.map +1 -0
- package/api/features/WbGeneratePageContent/WbGeneratePageContentUseCase.d.ts +17 -0
- package/api/features/WbGeneratePageContent/WbGeneratePageContentUseCase.js +62 -0
- package/api/features/WbGeneratePageContent/WbGeneratePageContentUseCase.js.map +1 -0
- package/api/features/WbGeneratePageContent/abstractions.d.ts +14 -0
- package/api/features/WbGeneratePageContent/abstractions.js +4 -0
- package/api/features/WbGeneratePageContent/abstractions.js.map +1 -0
- package/api/features/WbGeneratePageContent/buildPrompt.d.ts +1 -0
- package/api/features/WbGeneratePageContent/buildPrompt.js +142 -0
- package/api/features/WbGeneratePageContent/buildPrompt.js.map +1 -0
- package/api/features/WbGeneratePageContent/feature.d.ts +4 -0
- package/api/features/WbGeneratePageContent/feature.js +12 -0
- package/api/features/WbGeneratePageContent/feature.js.map +1 -0
- package/api/features/WbGeneratePageContent/index.d.ts +1 -0
- package/api/features/WbGeneratePageContent/index.js +3 -0
- package/api/features/WbGeneratePageContent/index.js.map +1 -0
- package/api/graphql/BaseGraphQLSchema.d.ts +8 -0
- package/api/graphql/BaseGraphQLSchema.js +110 -0
- package/api/graphql/BaseGraphQLSchema.js.map +1 -0
- package/api/types.d.ts +19 -0
- package/api/types.js +3 -0
- package/api/types.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +3 -0
- package/index.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useRef","observer","useDialog","Dialog","OverlayLoader","Textarea","useToast","useFeature","useWebsockets","useSelectFromEditor","useCreateElement","GenerateContentFeature","decompressGzipBase64","GENERATE_CONTENT_DIALOG","WS_ACTION_CONTENT","WS_ACTION_ERROR","GenerateContentDialog","closeDialog","presenter","vm","wasSubmitting","websockets","toast","components","state","createElement","createElements","elements","forEach","el","aiComponents","Object","values","filter","c","useInAiContentGeneration","map","name","label","aiContext","inputs","input","type","description","init","contentSubscription","onMessage","message","responseText","data","value","processAiResponse","errorSubscription","showWarningToast","title","cancelPrompt","off","current","submitting","handleSubmit","submit","isProcessing","processing","isSubmitting","open","onClose","size","actions","Fragment","CancelAction","onClick","text","ConfirmAction","disabled","prompt","trim","onChange","setPrompt","String","rows"],"sources":["GenerateContentDialog.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useDialog } from \"@webiny/app-admin\";\nimport { Dialog, OverlayLoader, Textarea, useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport type { IncomingGenericData } from \"@webiny/app-websockets\";\nimport { useWebsockets } from \"@webiny/app-websockets\";\nimport { useSelectFromEditor } from \"@webiny/app-website-builder/BaseEditor/hooks/useSelectFromEditor.js\";\nimport { useCreateElement } from \"@webiny/app-website-builder/BaseEditor/hooks/useCreateElement.js\";\nimport { GenerateContentFeature } from \"./feature.js\";\nimport { decompressGzipBase64 } from \"./decompressGzipBase64.js\";\nimport type { CreateElementParams } from \"./abstractions.js\";\n\nexport const GENERATE_CONTENT_DIALOG = \"generate-content\";\n\nexport const WS_ACTION_CONTENT = \"aiPowerUps.generatePageContent.content\";\nexport const WS_ACTION_ERROR = \"aiPowerUps.generatePageContent.error\";\n\nexport interface GeneratePageContentMessage extends IncomingGenericData {\n action: typeof WS_ACTION_CONTENT;\n data: {\n compression: \"gzip\";\n value: string;\n };\n}\n\nexport interface GeneratePageContentErrorMessage extends IncomingGenericData {\n action: typeof WS_ACTION_ERROR;\n data: {\n message: string;\n };\n}\n\nexport const GenerateContentDialog = observer(() => {\n const { closeDialog } = useDialog();\n const { presenter } = useFeature(GenerateContentFeature);\n const vm = presenter.vm;\n const wasSubmitting = useRef(false);\n const websockets = useWebsockets();\n const toast = useToast();\n\n const components = useSelectFromEditor(state => state.components);\n const { createElement } = useCreateElement();\n\n const createElements = useCallback(\n (elements: CreateElementParams[]) => {\n elements.forEach(el => createElement(el));\n },\n [createElement]\n );\n\n useEffect(() => {\n const aiComponents = Object.values(components)\n .filter(c => c.useInAiContentGeneration !== false)\n .map(c => {\n return {\n name: c.name,\n label: c.label,\n aiContext: c.aiContext,\n inputs: c.inputs.map(input => ({\n type: input.type,\n name: input.name,\n label: input.label,\n description: input.description\n }))\n };\n });\n presenter.init(aiComponents, createElements);\n }, [components, createElements]);\n\n useEffect(() => {\n const contentSubscription = websockets.onMessage<GeneratePageContentMessage>(\n WS_ACTION_CONTENT,\n async message => {\n const responseText = await decompressGzipBase64(message.data.value);\n await presenter.processAiResponse(responseText);\n }\n );\n\n const errorSubscription = websockets.onMessage<GeneratePageContentErrorMessage>(\n WS_ACTION_ERROR,\n async message => {\n toast.showWarningToast({\n title: \"Failed to generate content\",\n description: message.data.message\n });\n presenter.cancelPrompt();\n }\n );\n\n return () => {\n contentSubscription.off();\n errorSubscription.off();\n };\n }, []);\n\n useEffect(() => {\n if (wasSubmitting.current && !vm.submitting) {\n closeDialog();\n }\n wasSubmitting.current = vm.submitting;\n }, [vm.submitting]);\n\n const handleSubmit = async () => {\n await presenter.submit();\n };\n\n const isProcessing = vm.processing;\n const isSubmitting = vm.submitting;\n\n return (\n <Dialog\n open={true}\n onClose={closeDialog}\n title=\"Generate Content\"\n size={\"lg\"}\n actions={\n <>\n <Dialog.CancelAction onClick={closeDialog} text=\"Cancel\" />\n <Dialog.ConfirmAction\n onClick={handleSubmit}\n text=\"Generate\"\n disabled={!vm.prompt.trim() || vm.submitting}\n />\n </>\n }\n >\n {isSubmitting ? <OverlayLoader text={\"Generating content...\"} /> : null}\n {isProcessing ? <OverlayLoader text={\"Processing content...\"} /> : null}\n <Textarea\n label=\"Prompt\"\n description=\"Describe the page content you want to generate.\"\n value={vm.prompt}\n onChange={value => presenter.setPrompt(String(value ?? \"\"))}\n rows={6}\n />\n </Dialog>\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAC7D,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,MAAM,EAAEC,aAAa,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,kBAAkB;AAC5E,SAASC,UAAU,QAAQ,aAAa;AAExC,SAASC,aAAa,QAAQ,wBAAwB;AACtD,SAASC,mBAAmB,QAAQ,qEAAqE;AACzG,SAASC,gBAAgB,QAAQ,kEAAkE;AACnG,SAASC,sBAAsB;AAC/B,SAASC,oBAAoB;AAG7B,OAAO,MAAMC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,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ToolRegistry, ToolPipelineRunner } from "@webiny/app-admin";
|
|
2
|
+
import { GenerateContentPresenter, type CreateElementsFn } from "./abstractions.js";
|
|
3
|
+
import { GeneratePageContentUseCase } from "../../../admin/features/generatePageContent/index.js";
|
|
4
|
+
declare class GenerateContentPresenterImpl implements GenerateContentPresenter.Interface {
|
|
5
|
+
private toolRegistry;
|
|
6
|
+
private pipelineRunner;
|
|
7
|
+
private generatePageContent;
|
|
8
|
+
private _prompt;
|
|
9
|
+
private _submitting;
|
|
10
|
+
private _processing;
|
|
11
|
+
private _components;
|
|
12
|
+
private _createElements;
|
|
13
|
+
constructor(toolRegistry: ToolRegistry.Interface, pipelineRunner: ToolPipelineRunner.Interface, generatePageContent: GeneratePageContentUseCase.Interface);
|
|
14
|
+
get vm(): GenerateContentPresenter.ViewModel;
|
|
15
|
+
init(components: Record<string, any>[], createElements: CreateElementsFn): void;
|
|
16
|
+
setPrompt(value: string): void;
|
|
17
|
+
submit(): Promise<void>;
|
|
18
|
+
processAiResponse(responseText: string): Promise<void>;
|
|
19
|
+
cancelPrompt(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare const GenerateContentPresenterRegistration: typeof GenerateContentPresenterImpl & {
|
|
22
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGenerateContentPresenter>;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { makeAutoObservable, computed, toJS } from "mobx";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import pick from "lodash/pick.js";
|
|
4
|
+
import { ToolRegistry, ToolPipelineRunner } from "@webiny/app-admin";
|
|
5
|
+
import { GenerateContentPresenter } from "./abstractions.js";
|
|
6
|
+
import { GeneratePageContentUseCase } from "../../features/generatePageContent/index.js";
|
|
7
|
+
import { runInAction } from "mobx";
|
|
8
|
+
class GenerateContentPresenterImpl {
|
|
9
|
+
_prompt = "";
|
|
10
|
+
_submitting = false;
|
|
11
|
+
_processing = false;
|
|
12
|
+
_components = [];
|
|
13
|
+
_createElements = () => {};
|
|
14
|
+
constructor(toolRegistry, pipelineRunner, generatePageContent) {
|
|
15
|
+
this.toolRegistry = toolRegistry;
|
|
16
|
+
this.pipelineRunner = pipelineRunner;
|
|
17
|
+
this.generatePageContent = generatePageContent;
|
|
18
|
+
makeAutoObservable(this, {
|
|
19
|
+
vm: computed
|
|
20
|
+
}, {
|
|
21
|
+
autoBind: true
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
get vm() {
|
|
25
|
+
return {
|
|
26
|
+
prompt: this._prompt,
|
|
27
|
+
submitting: this._submitting,
|
|
28
|
+
processing: this._processing
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
init(components, createElements) {
|
|
32
|
+
this._components = components;
|
|
33
|
+
this._createElements = createElements;
|
|
34
|
+
}
|
|
35
|
+
setPrompt(value) {
|
|
36
|
+
this._prompt = value;
|
|
37
|
+
}
|
|
38
|
+
async submit() {
|
|
39
|
+
this._submitting = true;
|
|
40
|
+
try {
|
|
41
|
+
const tools = this.toolRegistry.getTools().map(tool => ({
|
|
42
|
+
name: tool.name,
|
|
43
|
+
description: tool.description,
|
|
44
|
+
inputSchema: pick(z.toJSONSchema(tool.inputSchema), ["properties", "type"]),
|
|
45
|
+
outputSchema: pick(z.toJSONSchema(tool.outputSchema), ["properties", "type"])
|
|
46
|
+
}));
|
|
47
|
+
await this.generatePageContent.execute({
|
|
48
|
+
prompt: this._prompt,
|
|
49
|
+
components: toJS(this._components),
|
|
50
|
+
tools
|
|
51
|
+
});
|
|
52
|
+
} catch {
|
|
53
|
+
runInAction(() => {
|
|
54
|
+
this._submitting = false;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async processAiResponse(responseText) {
|
|
59
|
+
this._processing = true;
|
|
60
|
+
this._submitting = false;
|
|
61
|
+
try {
|
|
62
|
+
const aiResponseJson = JSON.parse(responseText);
|
|
63
|
+
const resolved = await this.pipelineRunner.resolve(aiResponseJson);
|
|
64
|
+
const items = Array.isArray(resolved) ? resolved : [resolved];
|
|
65
|
+
this._createElements(items.map(element => ({
|
|
66
|
+
componentName: element.component,
|
|
67
|
+
parentId: "root",
|
|
68
|
+
slot: "children",
|
|
69
|
+
bindings: {
|
|
70
|
+
inputs: element.inputs
|
|
71
|
+
}
|
|
72
|
+
})));
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.error(e);
|
|
75
|
+
} finally {
|
|
76
|
+
runInAction(() => {
|
|
77
|
+
this._processing = false;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
cancelPrompt() {
|
|
82
|
+
this._processing = false;
|
|
83
|
+
this._submitting = false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export const GenerateContentPresenterRegistration = GenerateContentPresenter.createImplementation({
|
|
87
|
+
implementation: GenerateContentPresenterImpl,
|
|
88
|
+
dependencies: [ToolRegistry, ToolPipelineRunner, GeneratePageContentUseCase]
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=GenerateContentPresenter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["makeAutoObservable","computed","toJS","z","pick","ToolRegistry","ToolPipelineRunner","GenerateContentPresenter","GeneratePageContentUseCase","runInAction","GenerateContentPresenterImpl","_prompt","_submitting","_processing","_components","_createElements","constructor","toolRegistry","pipelineRunner","generatePageContent","vm","autoBind","prompt","submitting","processing","init","components","createElements","setPrompt","value","submit","tools","getTools","map","tool","name","description","inputSchema","toJSONSchema","outputSchema","execute","processAiResponse","responseText","aiResponseJson","JSON","parse","resolved","resolve","items","Array","isArray","element","componentName","component","parentId","slot","bindings","inputs","e","console","error","cancelPrompt","GenerateContentPresenterRegistration","createImplementation","implementation","dependencies"],"sources":["GenerateContentPresenter.ts"],"sourcesContent":["import { makeAutoObservable, computed, toJS } from \"mobx\";\nimport { z } from \"zod\";\nimport pick from \"lodash/pick.js\";\nimport { ToolRegistry, ToolPipelineRunner } from \"@webiny/app-admin\";\nimport { GenerateContentPresenter, type CreateElementsFn } from \"./abstractions.js\";\nimport { GeneratePageContentUseCase } from \"~/admin/features/generatePageContent/index.js\";\nimport { runInAction } from \"mobx\";\n\nclass GenerateContentPresenterImpl implements GenerateContentPresenter.Interface {\n private _prompt = \"\";\n private _submitting = false;\n private _processing = false;\n private _components: Record<string, any>[] = [];\n private _createElements: CreateElementsFn = () => {};\n\n constructor(\n private toolRegistry: ToolRegistry.Interface,\n private pipelineRunner: ToolPipelineRunner.Interface,\n private generatePageContent: GeneratePageContentUseCase.Interface\n ) {\n makeAutoObservable(this, { vm: computed }, { autoBind: true });\n }\n\n get vm(): GenerateContentPresenter.ViewModel {\n return {\n prompt: this._prompt,\n submitting: this._submitting,\n processing: this._processing\n };\n }\n\n init(components: Record<string, any>[], createElements: CreateElementsFn): void {\n this._components = components;\n this._createElements = createElements;\n }\n\n setPrompt(value: string): void {\n this._prompt = value;\n }\n\n async submit(): Promise<void> {\n this._submitting = true;\n\n try {\n const tools = this.toolRegistry.getTools().map(tool => ({\n name: tool.name,\n description: tool.description,\n inputSchema: pick(z.toJSONSchema(tool.inputSchema), [\"properties\", \"type\"]),\n outputSchema: pick(z.toJSONSchema(tool.outputSchema), [\"properties\", \"type\"])\n }));\n\n await this.generatePageContent.execute({\n prompt: this._prompt,\n components: toJS(this._components),\n tools\n });\n } catch {\n runInAction(() => {\n this._submitting = false;\n });\n }\n }\n\n async processAiResponse(responseText: string): Promise<void> {\n this._processing = true;\n this._submitting = false;\n\n try {\n const aiResponseJson = JSON.parse(responseText);\n const resolved = await this.pipelineRunner.resolve(aiResponseJson);\n const items = Array.isArray(resolved) ? resolved : [resolved];\n\n this._createElements(\n items.map((element: { component: string; inputs: Record<string, unknown> }) => ({\n componentName: element.component,\n parentId: \"root\",\n slot: \"children\",\n bindings: { inputs: element.inputs }\n }))\n );\n } catch (e) {\n console.error(e);\n } finally {\n runInAction(() => {\n this._processing = false;\n });\n }\n }\n\n cancelPrompt(): void {\n this._processing = false;\n this._submitting = false;\n }\n}\n\nexport const GenerateContentPresenterRegistration = GenerateContentPresenter.createImplementation({\n implementation: GenerateContentPresenterImpl,\n dependencies: [ToolRegistry, ToolPipelineRunner, GeneratePageContentUseCase]\n});\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,QAAQ,EAAEC,IAAI,QAAQ,MAAM;AACzD,SAASC,CAAC,QAAQ,KAAK;AACvB,OAAOC,IAAI,MAAM,gBAAgB;AACjC,SAASC,YAAY,EAAEC,kBAAkB,QAAQ,mBAAmB;AACpE,SAASC,wBAAwB;AACjC,SAASC,0BAA0B;AACnC,SAASC,WAAW,QAAQ,MAAM;AAElC,MAAMC,4BAA4B,CAA+C;EACrEC,OAAO,GAAG,EAAE;EACZC,WAAW,GAAG,KAAK;EACnBC,WAAW,GAAG,KAAK;EACnBC,WAAW,GAA0B,EAAE;EACvCC,eAAe,GAAqBA,CAAA,KAAM,CAAC,CAAC;EAEpDC,WAAWA,CACCC,YAAoC,EACpCC,cAA4C,EAC5CC,mBAAyD,EACnE;IAAA,KAHUF,YAAoC,GAApCA,YAAoC;IAAA,KACpCC,cAA4C,GAA5CA,cAA4C;IAAA,KAC5CC,mBAAyD,GAAzDA,mBAAyD;IAEjEnB,kBAAkB,CAAC,IAAI,EAAE;MAAEoB,EAAE,EAAEnB;IAAS,CAAC,EAAE;MAAEoB,QAAQ,EAAE;IAAK,CAAC,CAAC;EAClE;EAEA,IAAID,EAAEA,CAAA,EAAuC;IACzC,OAAO;MACHE,MAAM,EAAE,IAAI,CAACX,OAAO;MACpBY,UAAU,EAAE,IAAI,CAACX,WAAW;MAC5BY,UAAU,EAAE,IAAI,CAACX;IACrB,CAAC;EACL;EAEAY,IAAIA,CAACC,UAAiC,EAAEC,cAAgC,EAAQ;IAC5E,IAAI,CAACb,WAAW,GA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C;MAClE,MAAMK,KAAK,GAAGC,KAAK,CAACC,OAAO,CAACJ,QAAQ,CAAC,GAAGA,QAAQ,GAAG,CAACA,QAAQ,CAAC;MAE7D,IAAI,CAAC/B,eAAe,CAChBiC,KAAK,CAACf,GAAG,CAAEkB,OAA+D,KAAM;QAC5EC,aAAa,EAAED,OAAO,CAACE,SAAS;QAChCC,QAAQ,EAAE,MAAM;QAChBC,IAAI,EAAE,UAAU;QAChBC,QAAQ,EAAE;UAAEC,MAAM,EAAEN,OAAO,CAACM;QAAO;MACvC,CAAC,CAAC,CACN,CAAC;IACL,CAAC,CAAC,OAAOC,CAAC,EAAE;MACRC,OAAO,CAACC,KAAK,CAACF,CAAC,CAAC;IACpB,CAAC,SAAS;MACNjD,WAAW,CAAC,MAAM;QACd,IAAI,CAACI,WAAW,GAAG,KAAK;MAC5B,CAAC,CAAC;IACN;EACJ;EAEAgD,YAAYA,CAAA,EAAS;IACjB,IAAI,CAAChD,WAAW,GAAG,KAAK;IACxB,IAAI,CAACD,WAAW,GAAG,KAAK;EAC5B;AACJ;AAEA,OAAO,MAAMkD,oCAAoC,GAAGvD,wBAAwB,CAACwD,oBAAoB,CAAC;EAC9FC,cAAc,EAAEtD,4BAA4B;EAC5CuD,YAAY,EAAE,CAAC5D,YAAY,EAAEC,kBAAkB,EAAEE,0BAA0B;AAC/E,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# PROMPT (sent to AI via generateObject)
|
|
2
|
+
|
|
3
|
+
## System Prompt
|
|
4
|
+
|
|
5
|
+
You are a page content generator. Given a user prompt, generate structured page
|
|
6
|
+
content using the provided component catalog and available actions.
|
|
7
|
+
|
|
8
|
+
### Component Catalog
|
|
9
|
+
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"components": {
|
|
13
|
+
"Webiny/Hero": {
|
|
14
|
+
"name": "Webiny/Hero",
|
|
15
|
+
"label": "Hero",
|
|
16
|
+
"inputs": [
|
|
17
|
+
{ "type": "text", "name": "title", "required": true },
|
|
18
|
+
{ "type": "lexical", "name": "description" },
|
|
19
|
+
{ "type": "image", "name": "heroImage" },
|
|
20
|
+
{ "type": "lexical", "name": "footerText" }
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"Webiny/Grid": {
|
|
24
|
+
"name": "Webiny/Grid",
|
|
25
|
+
"label": "Grid",
|
|
26
|
+
"inputs": [
|
|
27
|
+
{ "type": "text", "name": "gridLayout" },
|
|
28
|
+
{ "type": "number", "name": "rowCount", "minValue": 1 },
|
|
29
|
+
{ "type": "number", "name": "columnGap" },
|
|
30
|
+
{ "type": "number", "name": "rowGap" },
|
|
31
|
+
{
|
|
32
|
+
"type": "select",
|
|
33
|
+
"name": "stackAtBreakpoint",
|
|
34
|
+
"options": ["tablet", "mobile"]
|
|
35
|
+
},
|
|
36
|
+
{ "type": "boolean", "name": "reverseWhenStacked" },
|
|
37
|
+
{
|
|
38
|
+
"type": "object",
|
|
39
|
+
"name": "columns",
|
|
40
|
+
"list": true,
|
|
41
|
+
"fields": [
|
|
42
|
+
{
|
|
43
|
+
"type": "slot",
|
|
44
|
+
"list": false,
|
|
45
|
+
"name": "children",
|
|
46
|
+
"components": ["Webiny/GridColumn"]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"Webiny/GridColumn": {
|
|
53
|
+
"name": "Webiny/GridColumn",
|
|
54
|
+
"label": "Column",
|
|
55
|
+
"inputs": [{ "type": "slot", "list": true, "name": "children" }]
|
|
56
|
+
},
|
|
57
|
+
"Webiny/Lexical": {
|
|
58
|
+
"name": "Webiny/Lexical",
|
|
59
|
+
"label": "Rich Text",
|
|
60
|
+
"inputs": [{ "type": "lexical", "name": "content" }]
|
|
61
|
+
},
|
|
62
|
+
"Webiny/Box": {
|
|
63
|
+
"name": "Webiny/Box",
|
|
64
|
+
"label": "Box",
|
|
65
|
+
"inputs": [{ "type": "slot", "list": true, "name": "children" }]
|
|
66
|
+
},
|
|
67
|
+
"Webiny/ProductCard": {
|
|
68
|
+
"name": "Webiny/ProductCard",
|
|
69
|
+
"label": "Product Card",
|
|
70
|
+
"inputs": [
|
|
71
|
+
{ "type": "product", "name": "product" },
|
|
72
|
+
{ "type": "boolean", "name": "showPrice" },
|
|
73
|
+
{ "type": "boolean", "name": "showRating" }
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Grid layout options: `12`, `6-6`, `4-4-4`, `8-4`, `4-8`, `3-3-3-3`
|
|
81
|
+
|
|
82
|
+
### Available Tools
|
|
83
|
+
|
|
84
|
+
For input fields that require post-processing, wrap the value in a tool
|
|
85
|
+
envelope: `{ "tool": "<toolName>", "params": { ... } }`.
|
|
86
|
+
|
|
87
|
+
Plain values (text, number, boolean, select) should be set directly without
|
|
88
|
+
an envelope.
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"tools": {
|
|
93
|
+
"htmlToLexical": {
|
|
94
|
+
"description": "Converts an HTML string into Lexical editor state. Use for all 'lexical' type inputs.",
|
|
95
|
+
"inputSchema": {
|
|
96
|
+
"type": "object",
|
|
97
|
+
"properties": {
|
|
98
|
+
"html": { "type": "string", "description": "HTML content" }
|
|
99
|
+
},
|
|
100
|
+
"required": ["html"]
|
|
101
|
+
},
|
|
102
|
+
"outputSchema": {
|
|
103
|
+
"type": "object",
|
|
104
|
+
"description": "Lexical editor state JSON"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"resolveImage": {
|
|
108
|
+
"description": "Fetches an image from the DAM matching the given tags and constraints.",
|
|
109
|
+
"inputSchema": {
|
|
110
|
+
"type": "object",
|
|
111
|
+
"properties": {
|
|
112
|
+
"tags": {
|
|
113
|
+
"type": "array",
|
|
114
|
+
"items": { "type": "string" },
|
|
115
|
+
"description": "Semantic tags describing the desired image"
|
|
116
|
+
},
|
|
117
|
+
"aspect": {
|
|
118
|
+
"type": "string",
|
|
119
|
+
"description": "Desired aspect ratio, e.g. '16:9', '1:1'"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"required": ["tags"]
|
|
123
|
+
},
|
|
124
|
+
"outputSchema": {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"properties": {
|
|
127
|
+
"id": { "type": "string" },
|
|
128
|
+
"name": { "type": "string" },
|
|
129
|
+
"src": { "type": "string" },
|
|
130
|
+
"width": { "type": "number" },
|
|
131
|
+
"height": { "type": "number" },
|
|
132
|
+
"mimeType": { "type": "string" }
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"resolveProduct": {
|
|
137
|
+
"description": "Fetches a product reference from the e-commerce catalog.",
|
|
138
|
+
"inputSchema": {
|
|
139
|
+
"type": "object",
|
|
140
|
+
"properties": {
|
|
141
|
+
"query": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"description": "Search query or product name"
|
|
144
|
+
},
|
|
145
|
+
"sku": { "type": "string", "description": "Exact SKU if known" },
|
|
146
|
+
"category": {
|
|
147
|
+
"type": "string",
|
|
148
|
+
"description": "Product category to filter by"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"outputSchema": {
|
|
153
|
+
"type": "object",
|
|
154
|
+
"properties": {
|
|
155
|
+
"id": { "type": "string" },
|
|
156
|
+
"name": { "type": "string" },
|
|
157
|
+
"sku": { "type": "string" },
|
|
158
|
+
"price": { "type": "number" },
|
|
159
|
+
"currency": { "type": "string" },
|
|
160
|
+
"imageUrl": { "type": "string" }
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Page Schema
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
type ElementSchema = {
|
|
172
|
+
component: string;
|
|
173
|
+
inputs: Record<string, unknown>;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
type CreateElementAction = {
|
|
177
|
+
action: "CreateElement";
|
|
178
|
+
params: ElementSchema;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
type PageSchema = ElementSchema[];
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
For slot inputs, use `{ "action": "CreateElement", "params": { "component": "...", "inputs": { ... } } }`.
|
|
185
|
+
Note: `CreateElement` uses "action" — it is a structural instruction for the page builder, not a tool invocation.
|
|
186
|
+
|
|
187
|
+
## User Prompt
|
|
188
|
+
|
|
189
|
+
"Create a landing page for Nike Air Max 90 sneakers. Include a hero section
|
|
190
|
+
with a tagline, a features grid, and a section showing 3 related products."
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type CreateElementParams = {
|
|
2
|
+
componentName: string;
|
|
3
|
+
parentId: string;
|
|
4
|
+
slot: string;
|
|
5
|
+
index?: number;
|
|
6
|
+
bindings?: {
|
|
7
|
+
inputs?: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type CreateElementsFn = (elements: CreateElementParams[]) => void;
|
|
11
|
+
export interface IGenerateContentVm {
|
|
12
|
+
prompt: string;
|
|
13
|
+
submitting: boolean;
|
|
14
|
+
processing: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface IGenerateContentPresenter {
|
|
17
|
+
readonly vm: IGenerateContentVm;
|
|
18
|
+
init(components: Record<string, any>[], createElements: CreateElementsFn): void;
|
|
19
|
+
setPrompt(value: string): void;
|
|
20
|
+
submit(): Promise<void>;
|
|
21
|
+
cancelPrompt(): void;
|
|
22
|
+
processAiResponse(responseText: string): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare const GenerateContentPresenter: import("@webiny/di").Abstraction<IGenerateContentPresenter>;
|
|
25
|
+
export declare namespace GenerateContentPresenter {
|
|
26
|
+
type Interface = IGenerateContentPresenter;
|
|
27
|
+
type ViewModel = IGenerateContentVm;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","GenerateContentPresenter"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\n\nexport type CreateElementParams = {\n componentName: string;\n parentId: string;\n slot: string;\n index?: number;\n bindings?: { inputs?: Record<string, unknown> };\n};\n\nexport type CreateElementsFn = (elements: CreateElementParams[]) => void;\n\nexport interface IGenerateContentVm {\n prompt: string;\n submitting: boolean;\n processing: boolean;\n}\n\nexport interface IGenerateContentPresenter {\n readonly vm: IGenerateContentVm;\n init(components: Record<string, any>[], createElements: CreateElementsFn): void;\n setPrompt(value: string): void;\n submit(): Promise<void>;\n cancelPrompt(): void;\n processAiResponse(responseText: string): Promise<void>;\n}\n\nexport const GenerateContentPresenter = createAbstraction<IGenerateContentPresenter>(\n \"WbContentGeneration/Presenter\"\n);\n\nexport namespace GenerateContentPresenter {\n export type Interface = IGenerateContentPresenter;\n export type ViewModel = IGenerateContentVm;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,uBAAuB;AA2BzD,OAAO,MAAMC,wBAAwB,GAAGD,iBAAiB,CACrD,+BACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function decompressGzipBase64(base64: string): Promise<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function decompressGzipBase64(base64) {
|
|
2
|
+
const binary = atob(base64);
|
|
3
|
+
const bytes = new Uint8Array(binary.length);
|
|
4
|
+
for (let i = 0; i < binary.length; i++) {
|
|
5
|
+
bytes[i] = binary.charCodeAt(i);
|
|
6
|
+
}
|
|
7
|
+
const ds = new DecompressionStream("gzip");
|
|
8
|
+
const writer = ds.writable.getWriter();
|
|
9
|
+
writer.write(bytes);
|
|
10
|
+
writer.close();
|
|
11
|
+
return new Response(ds.readable).text();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=decompressGzipBase64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["decompressGzipBase64","base64","binary","atob","bytes","Uint8Array","length","i","charCodeAt","ds","DecompressionStream","writer","writable","getWriter","write","close","Response","readable","text"],"sources":["decompressGzipBase64.ts"],"sourcesContent":["export async function decompressGzipBase64(base64: string): Promise<string> {\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n const ds = new DecompressionStream(\"gzip\");\n const writer = ds.writable.getWriter();\n writer.write(bytes);\n writer.close();\n return new Response(ds.readable).text();\n}\n"],"mappings":"AAAA,OAAO,eAAeA,oBAAoBA,CAACC,MAAc,EAAmB;EACxE,MAAMC,MAAM,GAAGC,IAAI,CAACF,MAAM,CAAC;EAC3B,MAAMG,KAAK,GAAG,IAAIC,UAAU,CAACH,MAAM,CAACI,MAAM,CAAC;EAC3C,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,MAAM,CAACI,MAAM,EAAEC,CAAC,EAAE,EAAE;IACpCH,KAAK,CAACG,CAAC,CAAC,GAAGL,MAAM,CAACM,UAAU,CAACD,CAAC,CAAC;EACnC;EACA,MAAME,EAAE,GAAG,IAAIC,mBAAmB,CAAC,MAAM,CAAC;EAC1C,MAAMC,MAAM,GAAGF,EAAE,CAACG,QAAQ,CAACC,SAAS,CAAC,CAAC;EACtCF,MAAM,CAACG,KAAK,CAACV,KAAK,CAAC;EACnBO,MAAM,CAACI,KAAK,CAAC,CAAC;EACd,OAAO,IAAIC,QAAQ,CAACP,EAAE,CAACQ,QAAQ,CAAC,CAACC,IAAI,CAAC,CAAC;AAC3C","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/admin";
|
|
2
|
+
import { GenerateContentPresenter } from "./abstractions.js";
|
|
3
|
+
import { GenerateContentPresenterRegistration } from "./GenerateContentPresenter.js";
|
|
4
|
+
export const GenerateContentFeature = createFeature({
|
|
5
|
+
name: "WbContentGeneration/Presenter",
|
|
6
|
+
register(container) {
|
|
7
|
+
container.register(GenerateContentPresenterRegistration);
|
|
8
|
+
},
|
|
9
|
+
resolve(container) {
|
|
10
|
+
return {
|
|
11
|
+
presenter: container.resolve(GenerateContentPresenter)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","GenerateContentPresenter","GenerateContentPresenterRegistration","GenerateContentFeature","name","register","container","resolve","presenter"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { GenerateContentPresenter } from \"./abstractions.js\";\nimport { GenerateContentPresenterRegistration } from \"./GenerateContentPresenter.js\";\n\nexport const GenerateContentFeature = createFeature({\n name: \"WbContentGeneration/Presenter\",\n register(container) {\n container.register(GenerateContentPresenterRegistration);\n },\n resolve(container) {\n return {\n presenter: container.resolve(GenerateContentPresenter)\n };\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,uBAAuB;AACrD,SAASC,wBAAwB;AACjC,SAASC,oCAAoC;AAE7C,OAAO,MAAMC,sBAAsB,GAAGH,aAAa,CAAC;EAChDI,IAAI,EAAE,+BAA+B;EACrCC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,oCAAoC,CAAC;EAC5D,CAAC;EACDK,OAAOA,CAACD,SAAS,EAAE;IACf,OAAO;MACHE,SAAS,EAAEF,SAAS,CAACC,OAAO,CAACN,wBAAwB;IACzD,CAAC;EACL;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/api/Extension.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { BaseGraphQLSchema } from "./graphql/BaseGraphQLSchema.js";
|
|
3
|
+
import { GetSettingsFeature } from "./features/GetSettings/feature.js";
|
|
4
|
+
import { UpdateSettingsFeature } from "./features/UpdateSettings/feature.js";
|
|
5
|
+
import { WbGeneratePageContentFeature } from "./features/WbGeneratePageContent/feature.js";
|
|
6
|
+
export const Extension = createFeature({
|
|
7
|
+
name: "AiPowerUps",
|
|
8
|
+
register(container) {
|
|
9
|
+
GetSettingsFeature.register(container);
|
|
10
|
+
UpdateSettingsFeature.register(container);
|
|
11
|
+
WbGeneratePageContentFeature.register(container);
|
|
12
|
+
container.register(BaseGraphQLSchema);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=Extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","BaseGraphQLSchema","GetSettingsFeature","UpdateSettingsFeature","WbGeneratePageContentFeature","Extension","name","register","container"],"sources":["Extension.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { BaseGraphQLSchema } from \"./graphql/BaseGraphQLSchema.js\";\nimport { GetSettingsFeature } from \"./features/GetSettings/feature.js\";\nimport { UpdateSettingsFeature } from \"./features/UpdateSettings/feature.js\";\nimport { WbGeneratePageContentFeature } from \"./features/WbGeneratePageContent/feature.js\";\n\nexport const Extension = createFeature({\n name: \"AiPowerUps\",\n register(container) {\n GetSettingsFeature.register(container);\n UpdateSettingsFeature.register(container);\n WbGeneratePageContentFeature.register(container);\n\n container.register(BaseGraphQLSchema);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,iBAAiB;AAC1B,SAASC,kBAAkB;AAC3B,SAASC,qBAAqB;AAC9B,SAASC,4BAA4B;AAErC,OAAO,MAAMC,SAAS,GAAGL,aAAa,CAAC;EACnCM,IAAI,EAAE,YAAY;EAClBC,QAAQA,CAACC,SAAS,EAAE;IAChBN,kBAAkB,CAACK,QAAQ,CAACC,SAAS,CAAC;IACtCL,qBAAqB,CAACI,QAAQ,CAACC,SAAS,CAAC;IACzCJ,4BAA4B,CAACG,QAAQ,CAACC,SAAS,CAAC;IAEhDA,SAAS,CAACD,QAAQ,CAACN,iBAAiB,CAAC;EACzC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AI_POWER_UPS_SETTINGS = "AiPowerUps/Settings";
|
package/api/constants.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AI_POWER_UPS_SETTINGS"],"sources":["constants.ts"],"sourcesContent":["export const AI_POWER_UPS_SETTINGS = \"AiPowerUps/Settings\";\n"],"mappings":"AAAA,OAAO,MAAMA,qBAAqB,GAAG,qBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
3
|
+
import { Encryption } from "@webiny/api-core/features/encryption/index.js";
|
|
4
|
+
import { GetSettingsRepository } from "./abstractions.js";
|
|
5
|
+
import type { AiPowerUpsSettings } from "../../../api/types.js";
|
|
6
|
+
declare class GetSettingsRepositoryImpl implements GetSettingsRepository.Interface {
|
|
7
|
+
private keyValueStore;
|
|
8
|
+
private encryption;
|
|
9
|
+
constructor(keyValueStore: KeyValueStore.Interface, encryption: Encryption.Interface);
|
|
10
|
+
get(): Promise<Result<AiPowerUpsSettings>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const GetSettingsRepositoryImplementation: typeof GetSettingsRepositoryImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetSettingsRepository>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
3
|
+
import { Encryption } from "@webiny/api-core/features/encryption/index.js";
|
|
4
|
+
import { GetSettingsRepository } from "./abstractions.js";
|
|
5
|
+
import { AI_POWER_UPS_SETTINGS } from "../../constants.js";
|
|
6
|
+
class GetSettingsRepositoryImpl {
|
|
7
|
+
constructor(keyValueStore, encryption) {
|
|
8
|
+
this.keyValueStore = keyValueStore;
|
|
9
|
+
this.encryption = encryption;
|
|
10
|
+
}
|
|
11
|
+
async get() {
|
|
12
|
+
const result = await this.keyValueStore.get(AI_POWER_UPS_SETTINGS);
|
|
13
|
+
if (result.isFail() || !result.value) {
|
|
14
|
+
return Result.ok({
|
|
15
|
+
providers: {
|
|
16
|
+
presets: []
|
|
17
|
+
},
|
|
18
|
+
personas: {
|
|
19
|
+
presets: []
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const settings = result.value;
|
|
24
|
+
const providerPresets = await Promise.all((settings.providers?.presets ?? []).map(async provider => {
|
|
25
|
+
return {
|
|
26
|
+
...provider,
|
|
27
|
+
apiKey: await this.encryption.decrypt(provider.apiKey)
|
|
28
|
+
};
|
|
29
|
+
}));
|
|
30
|
+
return Result.ok({
|
|
31
|
+
providers: {
|
|
32
|
+
presets: providerPresets
|
|
33
|
+
},
|
|
34
|
+
personas: {
|
|
35
|
+
presets: settings.personas?.presets ?? []
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({
|
|
41
|
+
implementation: GetSettingsRepositoryImpl,
|
|
42
|
+
dependencies: [KeyValueStore, Encryption]
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=GetSettingsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","KeyValueStore","Encryption","GetSettingsRepository","AI_POWER_UPS_SETTINGS","GetSettingsRepositoryImpl","constructor","keyValueStore","encryption","get","result","isFail","value","ok","providers","presets","personas","settings","providerPresets","Promise","all","map","provider","apiKey","decrypt","GetSettingsRepositoryImplementation","createImplementation","implementation","dependencies"],"sources":["GetSettingsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { Encryption } from \"@webiny/api-core/features/encryption/index.js\";\nimport { GetSettingsRepository } from \"./abstractions.js\";\nimport type { AiProvider, AiPowerUpsSettings } from \"~/api/types.js\";\nimport { AI_POWER_UPS_SETTINGS } from \"~/api/constants.js\";\n\nclass GetSettingsRepositoryImpl implements GetSettingsRepository.Interface {\n constructor(\n private keyValueStore: KeyValueStore.Interface,\n private encryption: Encryption.Interface\n ) {}\n\n async get(): Promise<Result<AiPowerUpsSettings>> {\n const result = await this.keyValueStore.get<AiPowerUpsSettings>(AI_POWER_UPS_SETTINGS);\n\n if (result.isFail() || !result.value) {\n return Result.ok({\n providers: { presets: [] },\n personas: { presets: [] }\n });\n }\n\n const settings = result.value;\n\n const providerPresets = await Promise.all(\n (settings.providers?.presets ?? []).map(async (provider: AiProvider) => {\n return {\n ...provider,\n apiKey: await this.encryption.decrypt(provider.apiKey)\n };\n })\n );\n\n return Result.ok({\n providers: { presets: providerPresets },\n personas: { presets: settings.personas?.presets ?? [] }\n });\n }\n}\n\nexport const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({\n implementation: GetSettingsRepositoryImpl,\n dependencies: [KeyValueStore, Encryption]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,aAAa,QAAQ,kDAAkD;AAChF,SAASC,UAAU,QAAQ,+CAA+C;AAC1E,SAASC,qBAAqB;AAE9B,SAASC,qBAAqB;AAE9B,MAAMC,yBAAyB,CAA4C;EACvEC,WAAWA,CACCC,aAAsC,EACtCC,UAAgC,EAC1C;IAAA,KAFUD,aAAsC,GAAtCA,aAAsC;IAAA,KACtCC,UAAgC,GAAhCA,UAAgC;EACzC;EAEH,MAAMC,GAAGA,CAAA,EAAwC;IAC7C,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACH,aAAa,CAACE,GAAG,CAAqBL,qBAAqB,CAAC;IAEtF,IAAIM,MAAM,CAACC,MAAM,CAAC,CAAC,IAAI,CAACD,MAAM,CAACE,KAAK,EAAE;MAClC,OAAOZ,MAAM,CAACa,EAAE,CAAC;QACbC,SAAS,EAAE;UAAEC,OAAO,EAAE;QAAG,CAAC;QAC1BC,QAAQ,EAAE;UAAED,OAAO,EAAE;QAAG;MAC5B,CAAC,CAAC;IACN;IAEA,MAAME,QAAQ,GAAGP,MAAM,CAACE,KAAK;IAE7B,MAAMM,eAAe,GAAG,MAAMC,OAAO,CAACC,GAAG,CACrC,CAACH,QAAQ,CAACH,SAAS,EAAEC,OAAO,IAAI,EAAE,EAAEM,GAAG,CAAC,MAAOC,QAAoB,IAAK;MACpE,OAAO;QACH,GAAGA,QAAQ;QACXC,MAAM,EAAE,MAAM,IAAI,CAACf,UAAU,CAACgB,OAAO,CAACF,QAAQ,CAACC,MAAM;MACzD,CAAC;IACL,CAAC,CACL,CAAC;IAED,OAAOvB,MAAM,CAACa,EAAE,CAAC;MACbC,SAAS,EAAE;QAAEC,OAAO,EAAEG;MAAgB,CAAC;MACvCF,QAAQ,EAAE;QAAED,OAAO,EAAEE,QAAQ,CAACD,QAAQ,EAAED,OAAO,IAAI;MAAG;IAC1D,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMU,mCAAmC,GAAGtB,qBAAqB,CAACuB,oBAAoB,CAAC;EAC1FC,cAAc,EAAEtB,yBAAyB;EACzCuB,YAAY,EAAE,CAAC3B,aAAa,EAAEC,UAAU;AAC5C,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GetSettingsUseCase, GetSettingsRepository } from "./abstractions.js";
|
|
2
|
+
declare class GetSettingsUseCaseImpl implements GetSettingsUseCase.Interface {
|
|
3
|
+
private repository;
|
|
4
|
+
constructor(repository: GetSettingsRepository.Interface);
|
|
5
|
+
execute(): Promise<import("@webiny/feature/api").Result<import("../../types.js").AiPowerUpsSettings, never>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const GetSettingsUseCaseImplementation: typeof GetSettingsUseCaseImpl & {
|
|
8
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetSettingsUseCase>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GetSettingsUseCase, GetSettingsRepository } from "./abstractions.js";
|
|
2
|
+
class GetSettingsUseCaseImpl {
|
|
3
|
+
constructor(repository) {
|
|
4
|
+
this.repository = repository;
|
|
5
|
+
}
|
|
6
|
+
execute() {
|
|
7
|
+
return this.repository.get();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({
|
|
11
|
+
implementation: GetSettingsUseCaseImpl,
|
|
12
|
+
dependencies: [GetSettingsRepository]
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=GetSettingsUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GetSettingsUseCase","GetSettingsRepository","GetSettingsUseCaseImpl","constructor","repository","execute","get","GetSettingsUseCaseImplementation","createImplementation","implementation","dependencies"],"sources":["GetSettingsUseCase.ts"],"sourcesContent":["import { GetSettingsUseCase, GetSettingsRepository } from \"./abstractions.js\";\n\nclass GetSettingsUseCaseImpl implements GetSettingsUseCase.Interface {\n constructor(private repository: GetSettingsRepository.Interface) {}\n\n execute() {\n return this.repository.get();\n }\n}\n\nexport const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({\n implementation: GetSettingsUseCaseImpl,\n dependencies: [GetSettingsRepository]\n});\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,qBAAqB;AAElD,MAAMC,sBAAsB,CAAyC;EACjEC,WAAWA,CAASC,UAA2C,EAAE;IAAA,KAA7CA,UAA2C,GAA3CA,UAA2C;EAAG;EAElEC,OAAOA,CAAA,EAAG;IACN,OAAO,IAAI,CAACD,UAAU,CAACE,GAAG,CAAC,CAAC;EAChC;AACJ;AAEA,OAAO,MAAMC,gCAAgC,GAAGP,kBAAkB,CAACQ,oBAAoB,CAAC;EACpFC,cAAc,EAAEP,sBAAsB;EACtCQ,YAAY,EAAE,CAACT,qBAAqB;AACxC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { AiPowerUpsSettings } from "../../../api/types.js";
|
|
3
|
+
export interface IGetSettingsRepository {
|
|
4
|
+
get(): Promise<Result<AiPowerUpsSettings>>;
|
|
5
|
+
}
|
|
6
|
+
export declare const GetSettingsRepository: import("@webiny/di").Abstraction<IGetSettingsRepository>;
|
|
7
|
+
export declare namespace GetSettingsRepository {
|
|
8
|
+
type Interface = IGetSettingsRepository;
|
|
9
|
+
}
|
|
10
|
+
export interface IGetSettingsUseCase {
|
|
11
|
+
execute(): Promise<Result<AiPowerUpsSettings>>;
|
|
12
|
+
}
|
|
13
|
+
export declare const GetSettingsUseCase: import("@webiny/di").Abstraction<IGetSettingsUseCase>;
|
|
14
|
+
export declare namespace GetSettingsUseCase {
|
|
15
|
+
type Interface = IGetSettingsUseCase;
|
|
16
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
export const GetSettingsRepository = createAbstraction("AiPowerUpsGetSettingsRepository");
|
|
3
|
+
export const GetSettingsUseCase = createAbstraction("AiPowerUpsGetSettingsUseCase");
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","GetSettingsRepository","GetSettingsUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type { AiPowerUpsSettings } from \"~/api/types.js\";\n\nexport interface IGetSettingsRepository {\n get(): Promise<Result<AiPowerUpsSettings>>;\n}\n\nexport const GetSettingsRepository = createAbstraction<IGetSettingsRepository>(\n \"AiPowerUpsGetSettingsRepository\"\n);\n\nexport namespace GetSettingsRepository {\n export type Interface = IGetSettingsRepository;\n}\n\nexport interface IGetSettingsUseCase {\n execute(): Promise<Result<AiPowerUpsSettings>>;\n}\n\nexport const GetSettingsUseCase = createAbstraction<IGetSettingsUseCase>(\n \"AiPowerUpsGetSettingsUseCase\"\n);\n\nexport namespace GetSettingsUseCase {\n export type Interface = IGetSettingsUseCase;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAgB,qBAAqB;AAO/D,OAAO,MAAMC,qBAAqB,GAAGD,iBAAiB,CAClD,iCACJ,CAAC;AAUD,OAAO,MAAME,kBAAkB,GAAGF,iBAAiB,CAC/C,8BACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { GetSettingsRepositoryImplementation } from "./GetSettingsRepository.js";
|
|
3
|
+
import { GetSettingsUseCaseImplementation } from "./GetSettingsUseCase.js";
|
|
4
|
+
export const GetSettingsFeature = createFeature({
|
|
5
|
+
name: "AiPowerUpsGetSettings",
|
|
6
|
+
register(container) {
|
|
7
|
+
container.register(GetSettingsRepositoryImplementation).inSingletonScope();
|
|
8
|
+
container.register(GetSettingsUseCaseImplementation);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=feature.js.map
|