@webiny/ai-powerups 6.4.5-beta.0 → 6.6.0-alpha.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.
Files changed (82) hide show
  1. package/admin/Extension.js +2 -1
  2. package/admin/Extension.js.map +1 -1
  3. package/admin/features/generateEntryContent/GenerateEntryContentGateway.d.ts +12 -0
  4. package/admin/features/generateEntryContent/GenerateEntryContentGateway.js +43 -0
  5. package/admin/features/generateEntryContent/GenerateEntryContentGateway.js.map +1 -0
  6. package/admin/features/generateEntryContent/GenerateEntryContentUseCase.d.ts +11 -0
  7. package/admin/features/generateEntryContent/GenerateEntryContentUseCase.js +18 -0
  8. package/admin/features/generateEntryContent/GenerateEntryContentUseCase.js.map +1 -0
  9. package/admin/features/generateEntryContent/abstractions.d.ts +23 -0
  10. package/admin/features/generateEntryContent/abstractions.js +6 -0
  11. package/admin/features/generateEntryContent/abstractions.js.map +1 -0
  12. package/admin/features/generateEntryContent/feature.d.ts +1 -0
  13. package/admin/features/generateEntryContent/feature.js +13 -0
  14. package/admin/features/generateEntryContent/feature.js.map +1 -0
  15. package/admin/features/generateEntryContent/index.d.ts +3 -0
  16. package/admin/features/generateEntryContent/index.js +2 -0
  17. package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.js +3 -4
  18. package/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.js.map +1 -1
  19. package/admin/presentation/CmsContentGeneration/CmsGenerateContentButton.d.ts +4 -0
  20. package/admin/presentation/CmsContentGeneration/CmsGenerateContentButton.js +27 -0
  21. package/admin/presentation/CmsContentGeneration/CmsGenerateContentButton.js.map +1 -0
  22. package/admin/presentation/CmsContentGeneration/CmsGenerateContentDialog.d.ts +5 -0
  23. package/admin/presentation/CmsContentGeneration/CmsGenerateContentDialog.js +106 -0
  24. package/admin/presentation/CmsContentGeneration/CmsGenerateContentDialog.js.map +1 -0
  25. package/admin/presentation/CmsContentGeneration/CmsGenerateContentPresenter.d.ts +37 -0
  26. package/admin/presentation/CmsContentGeneration/CmsGenerateContentPresenter.js +202 -0
  27. package/admin/presentation/CmsContentGeneration/CmsGenerateContentPresenter.js.map +1 -0
  28. package/admin/presentation/CmsContentGeneration/Extension.d.ts +2 -0
  29. package/admin/presentation/CmsContentGeneration/Extension.js +23 -0
  30. package/admin/presentation/CmsContentGeneration/Extension.js.map +1 -0
  31. package/admin/presentation/CmsContentGeneration/abstractions.d.ts +20 -0
  32. package/admin/presentation/CmsContentGeneration/abstractions.js +5 -0
  33. package/admin/presentation/CmsContentGeneration/abstractions.js.map +1 -0
  34. package/admin/presentation/CmsContentGeneration/feature.d.ts +3 -0
  35. package/admin/presentation/CmsContentGeneration/feature.js +17 -0
  36. package/admin/presentation/CmsContentGeneration/feature.js.map +1 -0
  37. package/admin/presentation/ProjectsSettings.js +4 -4
  38. package/admin/presentation/ProjectsSettings.js.map +1 -1
  39. package/admin/presentation/WbContentGeneration/GenerateContentPresenter.js +2 -2
  40. package/admin/presentation/WbContentGeneration/GenerateContentPresenter.js.map +1 -1
  41. package/api/Extension.js +5 -3
  42. package/api/Extension.js.map +1 -1
  43. package/api/features/AiImageEnrichment/AiImageEnrichmentAfterCreateHandler.d.ts +3 -1
  44. package/api/features/AiImageEnrichment/AiImageEnrichmentAfterCreateHandler.js +6 -2
  45. package/api/features/AiImageEnrichment/AiImageEnrichmentAfterCreateHandler.js.map +1 -1
  46. package/api/features/AiImageEnrichment/AiImageEnrichmentTask.d.ts +7 -5
  47. package/api/features/AiImageEnrichment/AiImageEnrichmentTask.js +32 -30
  48. package/api/features/AiImageEnrichment/AiImageEnrichmentTask.js.map +1 -1
  49. package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentTask.d.ts +32 -0
  50. package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentTask.js +74 -0
  51. package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentTask.js.map +1 -0
  52. package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentUseCase.d.ts +29 -0
  53. package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentUseCase.js +141 -0
  54. package/api/features/CmsGenerateEntryContent/CmsGenerateEntryContentUseCase.js.map +1 -0
  55. package/api/features/CmsGenerateEntryContent/abstractions.d.ts +29 -0
  56. package/api/features/CmsGenerateEntryContent/abstractions.js +5 -0
  57. package/api/features/CmsGenerateEntryContent/abstractions.js.map +1 -0
  58. package/api/features/CmsGenerateEntryContent/buildPrompt.d.ts +2 -0
  59. package/api/features/CmsGenerateEntryContent/buildPrompt.js +61 -0
  60. package/api/features/CmsGenerateEntryContent/buildPrompt.js.map +1 -0
  61. package/api/features/CmsGenerateEntryContent/feature.d.ts +4 -0
  62. package/api/features/CmsGenerateEntryContent/feature.js +13 -0
  63. package/api/features/CmsGenerateEntryContent/feature.js.map +1 -0
  64. package/api/features/CmsGenerateEntryContent/index.d.ts +1 -0
  65. package/api/features/CmsGenerateEntryContent/index.js +1 -0
  66. package/api/features/CmsGenerateEntryContent/injectDynamicZoneTypenames.d.ts +2 -0
  67. package/api/features/CmsGenerateEntryContent/injectDynamicZoneTypenames.js +30 -0
  68. package/api/features/CmsGenerateEntryContent/injectDynamicZoneTypenames.js.map +1 -0
  69. package/api/features/CmsResolveImageTool/CmsResolveImageTool.d.ts +14 -0
  70. package/api/features/CmsResolveImageTool/CmsResolveImageTool.js +27 -0
  71. package/api/features/CmsResolveImageTool/CmsResolveImageTool.js.map +1 -0
  72. package/api/features/CmsResolveImageTool/feature.d.ts +4 -0
  73. package/api/features/CmsResolveImageTool/feature.js +11 -0
  74. package/api/features/CmsResolveImageTool/feature.js.map +1 -0
  75. package/api/features/GetSettings/GetSettingsUseCase.d.ts +1 -1
  76. package/api/features/WbGeneratePageContent/WbGeneratePageContentTask.d.ts +3 -3
  77. package/api/features/WbGeneratePageContent/WbGeneratePageContentTask.js +6 -6
  78. package/api/features/WbGeneratePageContent/WbGeneratePageContentTask.js.map +1 -1
  79. package/api/graphql/BaseGraphQLSchema.d.ts +2 -2
  80. package/api/graphql/BaseGraphQLSchema.js +34 -2
  81. package/api/graphql/BaseGraphQLSchema.js.map +1 -1
  82. package/package.json +23 -22
@@ -3,6 +3,7 @@ import { AdminConfig, AdminLayout, RegisterFeature, useRouter } from "@webiny/ap
3
3
  import { AiPowerUpsSettingsFeature } from "./presentation/AiPowerUpsSettings/index.js";
4
4
  import { AiPowerUpsSettingsPage } from "./presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.js";
5
5
  import { WbContentGeneration } from "./presentation/WbContentGeneration/Extension.js";
6
+ import { CmsContentGeneration } from "./presentation/CmsContentGeneration/Extension.js";
6
7
  import { AiPowerUpsHeadlessFeatures } from "./features/feature.js";
7
8
  import { Routes } from "./routes.js";
8
9
  const { Menu: Menu, Route: Route } = AdminConfig;
@@ -30,7 +31,7 @@ const Extension = ()=>/*#__PURE__*/ react.createElement(react.Fragment, null, /*
30
31
  feature: AiPowerUpsHeadlessFeatures
31
32
  }), /*#__PURE__*/ react.createElement(RegisterFeature, {
32
33
  feature: AiPowerUpsSettingsFeature
33
- }), /*#__PURE__*/ react.createElement(AiPowerUpsSettings, null), /*#__PURE__*/ react.createElement(WbContentGeneration, null));
34
+ }), /*#__PURE__*/ react.createElement(AiPowerUpsSettings, null), /*#__PURE__*/ react.createElement(WbContentGeneration, null), /*#__PURE__*/ react.createElement(CmsContentGeneration, null));
34
35
  export { Extension };
35
36
 
36
37
  //# sourceMappingURL=Extension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin/Extension.js","sources":["../../src/admin/Extension.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig, AdminLayout, useRouter, RegisterFeature } from \"@webiny/app-admin\";\nimport { AiPowerUpsSettingsFeature } from \"./presentation/AiPowerUpsSettings/index.js\";\nimport { AiPowerUpsSettingsPage } from \"./presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.js\";\nimport { WbContentGeneration } from \"~/admin/presentation/WbContentGeneration/Extension.js\";\nimport { AiPowerUpsHeadlessFeatures } from \"~/admin/features/feature.js\";\nimport { Routes } from \"./routes.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nconst AiPowerUpsSettings = () => {\n const { getLink } = useRouter();\n\n return (\n <AdminConfig>\n <Route\n route={Routes.Settings}\n element={\n <AdminLayout title={\"AI Power-Ups\"}>\n <AiPowerUpsSettingsPage />\n </AdminLayout>\n }\n />\n <Menu\n parent={\"settings.system\"}\n name={\"aiPowerUps\"}\n element={\n <Menu.Link\n text={\"AI Power-Ups\"}\n badge={<Menu.Link.Badge text=\"BETA\" />}\n to={getLink(Routes.Settings)}\n pinnable={true}\n />\n }\n />\n </AdminConfig>\n );\n};\n\nexport const Extension = () => {\n return (\n <>\n <RegisterFeature feature={AiPowerUpsHeadlessFeatures} />\n <RegisterFeature feature={AiPowerUpsSettingsFeature} />\n <AiPowerUpsSettings />\n {/* Website Builder Extension */}\n <WbContentGeneration />\n </>\n );\n};\n"],"names":["Menu","Route","AdminConfig","AiPowerUpsSettings","getLink","useRouter","Routes","AdminLayout","AiPowerUpsSettingsPage","Extension","RegisterFeature","AiPowerUpsHeadlessFeatures","AiPowerUpsSettingsFeature","WbContentGeneration"],"mappings":";;;;;;;AAQA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,OAAAA,KAAK,EAAE,GAAGC;AAExB,MAAMC,qBAAqB;IACvB,MAAM,EAAEC,OAAO,EAAE,GAAGC;IAEpB,OAAO,WAAP,GACI,oBAACH,aAAWA,MAAAA,WAAAA,GACR,oBAACD,OAAKA;QACF,OAAOK,OAAO,QAAQ;QACtB,uBACI,oBAACC,aAAWA;YAAC,OAAO;yBAChB,oBAACC,wBAAsBA;sBAInC,oBAACR,MAAIA;QACD,QAAQ;QACR,MAAM;QACN,uBACI,oBAACA,KAAK,IAAI;YACN,MAAM;YACN,qBAAO,oBAACA,KAAK,IAAI,CAAC,KAAK;gBAAC,MAAK;;YAC7B,IAAII,QAAQE,OAAO,QAAQ;YAC3B,UAAU;;;AAMlC;AAEO,MAAMG,YAAY,IACd,WAAP,GACI,wDACI,oBAACC,iBAAeA;QAAC,SAASC;sBAC1B,oBAACD,iBAAeA;QAAC,SAASE;sBAC1B,oBAACT,oBAAkBA,OAAAA,WAAAA,GAEnB,oBAACU,qBAAmBA"}
1
+ {"version":3,"file":"admin/Extension.js","sources":["../../src/admin/Extension.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig, AdminLayout, useRouter, RegisterFeature } from \"@webiny/app-admin\";\nimport { AiPowerUpsSettingsFeature } from \"./presentation/AiPowerUpsSettings/index.js\";\nimport { AiPowerUpsSettingsPage } from \"./presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.js\";\nimport { WbContentGeneration } from \"~/admin/presentation/WbContentGeneration/Extension.js\";\nimport { CmsContentGeneration } from \"~/admin/presentation/CmsContentGeneration/Extension.js\";\nimport { AiPowerUpsHeadlessFeatures } from \"~/admin/features/feature.js\";\nimport { Routes } from \"./routes.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nconst AiPowerUpsSettings = () => {\n const { getLink } = useRouter();\n\n return (\n <AdminConfig>\n <Route\n route={Routes.Settings}\n element={\n <AdminLayout title={\"AI Power-Ups\"}>\n <AiPowerUpsSettingsPage />\n </AdminLayout>\n }\n />\n <Menu\n parent={\"settings.system\"}\n name={\"aiPowerUps\"}\n element={\n <Menu.Link\n text={\"AI Power-Ups\"}\n badge={<Menu.Link.Badge text=\"BETA\" />}\n to={getLink(Routes.Settings)}\n pinnable={true}\n />\n }\n />\n </AdminConfig>\n );\n};\n\nexport const Extension = () => {\n return (\n <>\n <RegisterFeature feature={AiPowerUpsHeadlessFeatures} />\n <RegisterFeature feature={AiPowerUpsSettingsFeature} />\n <AiPowerUpsSettings />\n {/* Website Builder Extension */}\n <WbContentGeneration />\n {/* Headless CMS Extension */}\n <CmsContentGeneration />\n </>\n );\n};\n"],"names":["Menu","Route","AdminConfig","AiPowerUpsSettings","getLink","useRouter","Routes","AdminLayout","AiPowerUpsSettingsPage","Extension","RegisterFeature","AiPowerUpsHeadlessFeatures","AiPowerUpsSettingsFeature","WbContentGeneration","CmsContentGeneration"],"mappings":";;;;;;;;AASA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,OAAAA,KAAK,EAAE,GAAGC;AAExB,MAAMC,qBAAqB;IACvB,MAAM,EAAEC,OAAO,EAAE,GAAGC;IAEpB,OAAO,WAAP,GACI,oBAACH,aAAWA,MAAAA,WAAAA,GACR,oBAACD,OAAKA;QACF,OAAOK,OAAO,QAAQ;QACtB,uBACI,oBAACC,aAAWA;YAAC,OAAO;yBAChB,oBAACC,wBAAsBA;sBAInC,oBAACR,MAAIA;QACD,QAAQ;QACR,MAAM;QACN,uBACI,oBAACA,KAAK,IAAI;YACN,MAAM;YACN,qBAAO,oBAACA,KAAK,IAAI,CAAC,KAAK;gBAAC,MAAK;;YAC7B,IAAII,QAAQE,OAAO,QAAQ;YAC3B,UAAU;;;AAMlC;AAEO,MAAMG,YAAY,IACd,WAAP,GACI,wDACI,oBAACC,iBAAeA;QAAC,SAASC;sBAC1B,oBAACD,iBAAeA;QAAC,SAASE;sBAC1B,oBAACT,oBAAkBA,OAAAA,WAAAA,GAEnB,oBAACU,qBAAmBA,OAAAA,WAAAA,GAEpB,oBAACC,sBAAoBA"}
@@ -0,0 +1,12 @@
1
+ import { GenerateEntryContentGateway as GatewayAbstraction } from "./abstractions.js";
2
+ import type { GenerateEntryContentParams } from "./abstractions.js";
3
+ import { MainGraphQLClient } from "@webiny/app/exports/admin.js";
4
+ declare class GenerateEntryContentGatewayImpl implements GatewayAbstraction.Interface {
5
+ private client;
6
+ constructor(client: MainGraphQLClient.Interface);
7
+ execute(params: GenerateEntryContentParams): Promise<void>;
8
+ }
9
+ export declare const GenerateEntryContentGateway: typeof GenerateEntryContentGatewayImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGenerateEntryContentGateway>;
11
+ };
12
+ export {};
@@ -0,0 +1,43 @@
1
+ import { GenerateEntryContentGateway } from "./abstractions.js";
2
+ import { MainGraphQLClient } from "@webiny/app/exports/admin.js";
3
+ const GENERATE_ENTRY_CONTENT = `
4
+ mutation GenerateEntryContent(
5
+ $prompt: String!
6
+ $modelId: String!
7
+ $projectId: String
8
+ $excludedFileIds: [String!]
9
+ $readerPersonaId: String
10
+ $writerPersonaId: String
11
+ ) {
12
+ aiPowerUps {
13
+ generateEntryContent(
14
+ prompt: $prompt
15
+ modelId: $modelId
16
+ projectId: $projectId
17
+ excludedFileIds: $excludedFileIds
18
+ readerPersonaId: $readerPersonaId
19
+ writerPersonaId: $writerPersonaId
20
+ )
21
+ }
22
+ }
23
+ `;
24
+ class GenerateEntryContentGatewayImpl {
25
+ constructor(client){
26
+ this.client = client;
27
+ }
28
+ async execute(params) {
29
+ await this.client.execute({
30
+ query: GENERATE_ENTRY_CONTENT,
31
+ variables: params
32
+ });
33
+ }
34
+ }
35
+ const GenerateEntryContentGateway_GenerateEntryContentGateway = GenerateEntryContentGateway.createImplementation({
36
+ implementation: GenerateEntryContentGatewayImpl,
37
+ dependencies: [
38
+ MainGraphQLClient
39
+ ]
40
+ });
41
+ export { GenerateEntryContentGateway_GenerateEntryContentGateway as GenerateEntryContentGateway };
42
+
43
+ //# sourceMappingURL=GenerateEntryContentGateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin/features/generateEntryContent/GenerateEntryContentGateway.js","sources":["../../../../src/admin/features/generateEntryContent/GenerateEntryContentGateway.ts"],"sourcesContent":["import { GenerateEntryContentGateway as GatewayAbstraction } from \"./abstractions.js\";\nimport type { GenerateEntryContentParams } from \"./abstractions.js\";\nimport { MainGraphQLClient } from \"@webiny/app/exports/admin.js\";\n\nconst GENERATE_ENTRY_CONTENT = /* GraphQL */ `\n mutation GenerateEntryContent(\n $prompt: String!\n $modelId: String!\n $projectId: String\n $excludedFileIds: [String!]\n $readerPersonaId: String\n $writerPersonaId: String\n ) {\n aiPowerUps {\n generateEntryContent(\n prompt: $prompt\n modelId: $modelId\n projectId: $projectId\n excludedFileIds: $excludedFileIds\n readerPersonaId: $readerPersonaId\n writerPersonaId: $writerPersonaId\n )\n }\n }\n`;\n\ntype GenerateEntryContentResponse = {\n aiPowerUps: {\n generateEntryContent: { id: string };\n };\n};\n\nclass GenerateEntryContentGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private client: MainGraphQLClient.Interface) {}\n\n async execute(params: GenerateEntryContentParams): Promise<void> {\n await this.client.execute<GenerateEntryContentResponse>({\n query: GENERATE_ENTRY_CONTENT,\n variables: params\n });\n }\n}\n\nexport const GenerateEntryContentGateway = GatewayAbstraction.createImplementation({\n implementation: GenerateEntryContentGatewayImpl,\n dependencies: [MainGraphQLClient]\n});\n"],"names":["GENERATE_ENTRY_CONTENT","GenerateEntryContentGatewayImpl","client","params","GenerateEntryContentGateway","GatewayAbstraction","MainGraphQLClient"],"mappings":";;AAIA,MAAMA,yBAAuC,CAAC;;;;;;;;;;;;;;;;;;;;AAoB9C,CAAC;AAQD,MAAMC;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,QAAQC,MAAkC,EAAiB;QAC7D,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA+B;YACpD,OAAOH;YACP,WAAWG;QACf;IACJ;AACJ;AAEO,MAAMC,0DAA8BC,4BAAAA,oBAAuC,CAAC;IAC/E,gBAAgBJ;IAChB,cAAc;QAACK;KAAkB;AACrC"}
@@ -0,0 +1,11 @@
1
+ import { GenerateEntryContentUseCase as UseCaseAbstraction, GenerateEntryContentGateway } from "./abstractions.js";
2
+ import type { GenerateEntryContentParams } from "./abstractions.js";
3
+ declare class GenerateEntryContentUseCaseImpl implements UseCaseAbstraction.Interface {
4
+ private gateway;
5
+ constructor(gateway: GenerateEntryContentGateway.Interface);
6
+ execute(params: GenerateEntryContentParams): Promise<void>;
7
+ }
8
+ export declare const GenerateEntryContentUseCase: typeof GenerateEntryContentUseCaseImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGenerateEntryContentUseCase>;
10
+ };
11
+ export {};
@@ -0,0 +1,18 @@
1
+ import { GenerateEntryContentGateway, GenerateEntryContentUseCase } from "./abstractions.js";
2
+ class GenerateEntryContentUseCaseImpl {
3
+ constructor(gateway){
4
+ this.gateway = gateway;
5
+ }
6
+ async execute(params) {
7
+ return this.gateway.execute(params);
8
+ }
9
+ }
10
+ const GenerateEntryContentUseCase_GenerateEntryContentUseCase = GenerateEntryContentUseCase.createImplementation({
11
+ implementation: GenerateEntryContentUseCaseImpl,
12
+ dependencies: [
13
+ GenerateEntryContentGateway
14
+ ]
15
+ });
16
+ export { GenerateEntryContentUseCase_GenerateEntryContentUseCase as GenerateEntryContentUseCase };
17
+
18
+ //# sourceMappingURL=GenerateEntryContentUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin/features/generateEntryContent/GenerateEntryContentUseCase.js","sources":["../../../../src/admin/features/generateEntryContent/GenerateEntryContentUseCase.ts"],"sourcesContent":["import {\n GenerateEntryContentUseCase as UseCaseAbstraction,\n GenerateEntryContentGateway\n} from \"./abstractions.js\";\nimport type { GenerateEntryContentParams } from \"./abstractions.js\";\n\nclass GenerateEntryContentUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(private gateway: GenerateEntryContentGateway.Interface) {}\n\n async execute(params: GenerateEntryContentParams): Promise<void> {\n return this.gateway.execute(params);\n }\n}\n\nexport const GenerateEntryContentUseCase = UseCaseAbstraction.createImplementation({\n implementation: GenerateEntryContentUseCaseImpl,\n dependencies: [GenerateEntryContentGateway]\n});\n"],"names":["GenerateEntryContentUseCaseImpl","gateway","params","GenerateEntryContentUseCase","UseCaseAbstraction","GenerateEntryContentGateway"],"mappings":";AAMA,MAAMA;IACF,YAAoBC,OAA8C,CAAE;aAAhDA,OAAO,GAAPA;IAAiD;IAErE,MAAM,QAAQC,MAAkC,EAAiB;QAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAACA;IAChC;AACJ;AAEO,MAAMC,0DAA8BC,4BAAAA,oBAAuC,CAAC;IAC/E,gBAAgBJ;IAChB,cAAc;QAACK;KAA4B;AAC/C"}
@@ -0,0 +1,23 @@
1
+ export interface GenerateEntryContentParams {
2
+ prompt: string;
3
+ modelId: string;
4
+ projectId?: string | null;
5
+ excludedFileIds?: string[] | null;
6
+ readerPersonaId?: string | null;
7
+ writerPersonaId?: string | null;
8
+ }
9
+ export interface IGenerateEntryContentUseCase {
10
+ execute(params: GenerateEntryContentParams): Promise<void>;
11
+ }
12
+ export declare const GenerateEntryContentUseCase: import("@webiny/di").Abstraction<IGenerateEntryContentUseCase>;
13
+ export declare namespace GenerateEntryContentUseCase {
14
+ type Interface = IGenerateEntryContentUseCase;
15
+ type Params = GenerateEntryContentParams;
16
+ }
17
+ export interface IGenerateEntryContentGateway {
18
+ execute(params: GenerateEntryContentParams): Promise<void>;
19
+ }
20
+ export declare const GenerateEntryContentGateway: import("@webiny/di").Abstraction<IGenerateEntryContentGateway>;
21
+ export declare namespace GenerateEntryContentGateway {
22
+ type Interface = IGenerateEntryContentGateway;
23
+ }
@@ -0,0 +1,6 @@
1
+ import { createAbstraction } from "@webiny/feature/admin";
2
+ const GenerateEntryContentUseCase = createAbstraction("AiPowerUps/GenerateEntryContentUseCase");
3
+ const GenerateEntryContentGateway = createAbstraction("AiPowerUps/GenerateEntryContentGateway");
4
+ export { GenerateEntryContentGateway, GenerateEntryContentUseCase };
5
+
6
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin/features/generateEntryContent/abstractions.js","sources":["../../../../src/admin/features/generateEntryContent/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\n\nexport interface GenerateEntryContentParams {\n prompt: string;\n modelId: string;\n projectId?: string | null;\n excludedFileIds?: string[] | null;\n readerPersonaId?: string | null;\n writerPersonaId?: string | null;\n}\n\nexport interface IGenerateEntryContentUseCase {\n execute(params: GenerateEntryContentParams): Promise<void>;\n}\n\nexport const GenerateEntryContentUseCase = createAbstraction<IGenerateEntryContentUseCase>(\n \"AiPowerUps/GenerateEntryContentUseCase\"\n);\n\nexport namespace GenerateEntryContentUseCase {\n export type Interface = IGenerateEntryContentUseCase;\n export type Params = GenerateEntryContentParams;\n}\n\nexport interface IGenerateEntryContentGateway {\n execute(params: GenerateEntryContentParams): Promise<void>;\n}\n\nexport const GenerateEntryContentGateway = createAbstraction<IGenerateEntryContentGateway>(\n \"AiPowerUps/GenerateEntryContentGateway\"\n);\n\nexport namespace GenerateEntryContentGateway {\n export type Interface = IGenerateEntryContentGateway;\n}\n"],"names":["GenerateEntryContentUseCase","createAbstraction","GenerateEntryContentGateway"],"mappings":";AAeO,MAAMA,8BAA8BC,kBACvC;AAYG,MAAMC,8BAA8BD,kBACvC"}
@@ -0,0 +1 @@
1
+ export declare const GenerateEntryContentFeature: import("@webiny/feature/admin").FeatureDefinition<any, []>;
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/admin";
2
+ import { GenerateEntryContentUseCase } from "./GenerateEntryContentUseCase.js";
3
+ import { GenerateEntryContentGateway } from "./GenerateEntryContentGateway.js";
4
+ const GenerateEntryContentFeature = createFeature({
5
+ name: "AiPowerUps/GenerateEntryContent",
6
+ register (container) {
7
+ container.register(GenerateEntryContentUseCase);
8
+ container.register(GenerateEntryContentGateway).inSingletonScope();
9
+ }
10
+ });
11
+ export { GenerateEntryContentFeature };
12
+
13
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin/features/generateEntryContent/feature.js","sources":["../../../../src/admin/features/generateEntryContent/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { GenerateEntryContentUseCase } from \"./GenerateEntryContentUseCase.js\";\nimport { GenerateEntryContentGateway } from \"./GenerateEntryContentGateway.js\";\n\nexport const GenerateEntryContentFeature = createFeature({\n name: \"AiPowerUps/GenerateEntryContent\",\n register(container) {\n container.register(GenerateEntryContentUseCase);\n container.register(GenerateEntryContentGateway).inSingletonScope();\n }\n});\n"],"names":["GenerateEntryContentFeature","createFeature","container","GenerateEntryContentUseCase","GenerateEntryContentGateway"],"mappings":";;;AAIO,MAAMA,8BAA8BC,cAAc;IACrD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,6BAA6B,gBAAgB;IACpE;AACJ"}
@@ -0,0 +1,3 @@
1
+ export { GenerateEntryContentFeature } from "./feature.js";
2
+ export { GenerateEntryContentUseCase, GenerateEntryContentGateway } from "./abstractions.js";
3
+ export type { GenerateEntryContentParams } from "./abstractions.js";
@@ -0,0 +1,2 @@
1
+ export { GenerateEntryContentFeature } from "./feature.js";
2
+ export { GenerateEntryContentGateway, GenerateEntryContentUseCase } from "./abstractions.js";
@@ -23,11 +23,10 @@ const AiPowerUpsSettingsPage = observer(()=>{
23
23
  className: "mb-lg"
24
24
  }, /*#__PURE__*/ react.createElement(PresenterErrors, {
25
25
  errors: vm.errors
26
- })) : null, vm.form && vm.form.errors.length > 0 ? /*#__PURE__*/ react.createElement("div", {
26
+ })) : null, vm.form ? /*#__PURE__*/ react.createElement(FormErrors, {
27
+ form: vm.form,
27
28
  className: "mb-lg"
28
- }, /*#__PURE__*/ react.createElement(FormErrors, {
29
- form: vm.form
30
- })) : null, vm.loading || vm.saving ? /*#__PURE__*/ react.createElement(OverlayLoader, {
29
+ }) : null, vm.loading || vm.saving ? /*#__PURE__*/ react.createElement(OverlayLoader, {
31
30
  text: vm.saving ? "Saving..." : "Loading..."
32
31
  }) : null, /*#__PURE__*/ react.createElement(SimpleFormHeader, {
33
32
  title: "AI Power-Ups"
@@ -1 +1 @@
1
- {"version":3,"file":"admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.js","sources":["../../../../src/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport {\n FormView,\n FormErrors,\n PresenterErrors,\n SimpleForm,\n SimpleFormContent,\n SimpleFormFooter,\n SimpleFormHeader\n} from \"@webiny/app-admin\";\nimport { Button, OverlayLoader, useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport { AiPowerUpsSettingsFeature } from \"./feature.js\";\n\nexport const AiPowerUpsSettingsPage = observer(() => {\n const toast = useToast();\n const { presenter } = useFeature(AiPowerUpsSettingsFeature);\n const vm = presenter.vm;\n\n useEffect(() => {\n presenter.init();\n }, []);\n\n const handleSave = async () => {\n const success = await presenter.save();\n if (success) {\n toast.showSuccessToast({\n title: \"AI power-ups settings saved successfully!\"\n });\n }\n };\n\n return (\n <div>\n <SimpleForm size={\"xl\"}>\n {vm.errors.length > 0 ? (\n <div className={\"mb-lg\"}>\n <PresenterErrors errors={vm.errors} />\n </div>\n ) : null}\n {vm.form && vm.form.errors.length > 0 ? (\n <div className={\"mb-lg\"}>\n <FormErrors form={vm.form} />\n </div>\n ) : null}\n {vm.loading || vm.saving ? (\n <OverlayLoader text={vm.saving ? \"Saving...\" : \"Loading...\"} />\n ) : null}\n <SimpleFormHeader title=\"AI Power-Ups\" />\n <SimpleFormContent className={\"p-0\"}>\n <div className=\"flex flex-col gap-4\">\n {vm.form ? <FormView name=\"AI Power-Ups\" form={vm.form} /> : null}\n </div>\n </SimpleFormContent>\n <SimpleFormFooter className={\"border-t-sm border-t-neutral-dimmed pt-lg\"}>\n <Button text=\"Save Settings\" onClick={handleSave} />\n </SimpleFormFooter>\n </SimpleForm>\n </div>\n );\n});\n"],"names":["AiPowerUpsSettingsPage","observer","toast","useToast","presenter","useFeature","AiPowerUpsSettingsFeature","vm","useEffect","handleSave","success","SimpleForm","PresenterErrors","FormErrors","OverlayLoader","SimpleFormHeader","SimpleFormContent","FormView","SimpleFormFooter","Button"],"mappings":";;;;;;AAeO,MAAMA,yBAAyBC,SAAS;IAC3C,MAAMC,QAAQC;IACd,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAMC,KAAKH,UAAU,EAAE;IAEvBI,UAAU;QACNJ,UAAU,IAAI;IAClB,GAAG,EAAE;IAEL,MAAMK,aAAa;QACf,MAAMC,UAAU,MAAMN,UAAU,IAAI;QACpC,IAAIM,SACAR,MAAM,gBAAgB,CAAC;YACnB,OAAO;QACX;IAER;IAEA,OAAO,WAAP,GACI,oBAAC,2BACG,oBAACS,YAAUA;QAAC,MAAM;OACbJ,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,WAAJ,GAChB,oBAAC;QAAI,WAAW;qBACZ,oBAACK,iBAAeA;QAAC,QAAQL,GAAG,MAAM;UAEtC,MACHA,GAAG,IAAI,IAAIA,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,WAAJ,GAChC,oBAAC;QAAI,WAAW;qBACZ,oBAACM,YAAUA;QAAC,MAAMN,GAAG,IAAI;UAE7B,MACHA,GAAG,OAAO,IAAIA,GAAG,MAAM,GAAG,WAAH,GACpB,oBAACO,eAAaA;QAAC,MAAMP,GAAG,MAAM,GAAG,cAAc;SAC/C,oBACJ,oBAACQ,kBAAgBA;QAAC,OAAM;sBACxB,oBAACC,mBAAiBA;QAAC,WAAW;qBAC1B,oBAAC;QAAI,WAAU;OACVT,GAAG,IAAI,GAAG,WAAH,GAAG,oBAACU,UAAQA;QAAC,MAAK;QAAe,MAAMV,GAAG,IAAI;SAAO,sBAGrE,oBAACW,kBAAgBA;QAAC,WAAW;qBACzB,oBAACC,QAAMA;QAAC,MAAK;QAAgB,SAASV;;AAK1D"}
1
+ {"version":3,"file":"admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.js","sources":["../../../../src/admin/presentation/AiPowerUpsSettings/AiPowerUpsSettingsPage.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport {\n FormView,\n FormErrors,\n PresenterErrors,\n SimpleForm,\n SimpleFormContent,\n SimpleFormFooter,\n SimpleFormHeader\n} from \"@webiny/app-admin\";\nimport { Button, OverlayLoader, useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport { AiPowerUpsSettingsFeature } from \"./feature.js\";\n\nexport const AiPowerUpsSettingsPage = observer(() => {\n const toast = useToast();\n const { presenter } = useFeature(AiPowerUpsSettingsFeature);\n const vm = presenter.vm;\n\n useEffect(() => {\n presenter.init();\n }, []);\n\n const handleSave = async () => {\n const success = await presenter.save();\n if (success) {\n toast.showSuccessToast({\n title: \"AI power-ups settings saved successfully!\"\n });\n }\n };\n\n return (\n <div>\n <SimpleForm size={\"xl\"}>\n {vm.errors.length > 0 ? (\n <div className={\"mb-lg\"}>\n <PresenterErrors errors={vm.errors} />\n </div>\n ) : null}\n {vm.form ? <FormErrors form={vm.form} className={\"mb-lg\"} /> : null}\n {vm.loading || vm.saving ? (\n <OverlayLoader text={vm.saving ? \"Saving...\" : \"Loading...\"} />\n ) : null}\n <SimpleFormHeader title=\"AI Power-Ups\" />\n <SimpleFormContent className={\"p-0\"}>\n <div className=\"flex flex-col gap-4\">\n {vm.form ? <FormView name=\"AI Power-Ups\" form={vm.form} /> : null}\n </div>\n </SimpleFormContent>\n <SimpleFormFooter className={\"border-t-sm border-t-neutral-dimmed pt-lg\"}>\n <Button text=\"Save Settings\" onClick={handleSave} />\n </SimpleFormFooter>\n </SimpleForm>\n </div>\n );\n});\n"],"names":["AiPowerUpsSettingsPage","observer","toast","useToast","presenter","useFeature","AiPowerUpsSettingsFeature","vm","useEffect","handleSave","success","SimpleForm","PresenterErrors","FormErrors","OverlayLoader","SimpleFormHeader","SimpleFormContent","FormView","SimpleFormFooter","Button"],"mappings":";;;;;;AAeO,MAAMA,yBAAyBC,SAAS;IAC3C,MAAMC,QAAQC;IACd,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAMC,KAAKH,UAAU,EAAE;IAEvBI,UAAU;QACNJ,UAAU,IAAI;IAClB,GAAG,EAAE;IAEL,MAAMK,aAAa;QACf,MAAMC,UAAU,MAAMN,UAAU,IAAI;QACpC,IAAIM,SACAR,MAAM,gBAAgB,CAAC;YACnB,OAAO;QACX;IAER;IAEA,OAAO,WAAP,GACI,oBAAC,2BACG,oBAACS,YAAUA;QAAC,MAAM;OACbJ,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,WAAJ,GAChB,oBAAC;QAAI,WAAW;qBACZ,oBAACK,iBAAeA;QAAC,QAAQL,GAAG,MAAM;UAEtC,MACHA,GAAG,IAAI,GAAG,WAAH,GAAG,oBAACM,YAAUA;QAAC,MAAMN,GAAG,IAAI;QAAE,WAAW;SAAc,MAC9DA,GAAG,OAAO,IAAIA,GAAG,MAAM,GAAG,WAAH,GACpB,oBAACO,eAAaA;QAAC,MAAMP,GAAG,MAAM,GAAG,cAAc;SAC/C,oBACJ,oBAACQ,kBAAgBA;QAAC,OAAM;sBACxB,oBAACC,mBAAiBA;QAAC,WAAW;qBAC1B,oBAAC;QAAI,WAAU;OACVT,GAAG,IAAI,GAAG,WAAH,GAAG,oBAACU,UAAQA;QAAC,MAAK;QAAe,MAAMV,GAAG,IAAI;SAAO,sBAGrE,oBAACW,kBAAgBA;QAAC,WAAW;qBACzB,oBAACC,QAAMA;QAAC,MAAK;QAAgB,SAASV;;AAK1D"}
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ export declare const CmsGenerateContentButton: (() => React.JSX.Element | null) & {
3
+ displayName: string;
4
+ };
@@ -0,0 +1,27 @@
1
+ import react from "react";
2
+ import { observer } from "mobx-react-lite";
3
+ import { IconButton } from "@webiny/admin-ui";
4
+ import { ReactComponent } from "@webiny/icons/auto_fix_high.svg";
5
+ import { useOpenDialog } from "@webiny/app-admin";
6
+ import { useModel } from "@webiny/app-headless-cms/admin/components/ModelProvider/useModel.js";
7
+ import { CMS_GENERATE_CONTENT_DIALOG } from "./CmsGenerateContentDialog.js";
8
+ import { useAiPowerUpsSettings } from "../AiPowerUpsSettings/index.js";
9
+ import { useContentEntryFormPresenter } from "@webiny/app-headless-cms/exports/admin/cms/entry/editor.js";
10
+ const CmsGenerateContentButton = observer(()=>{
11
+ const { openDialog } = useOpenDialog();
12
+ const { settings } = useAiPowerUpsSettings();
13
+ const { model } = useModel();
14
+ const presenter = useContentEntryFormPresenter();
15
+ if (!presenter.vm.canSave) return null;
16
+ if (!settings || 0 === settings.providers.presets.length) return null;
17
+ return /*#__PURE__*/ react.createElement(IconButton, {
18
+ variant: "ghost",
19
+ icon: /*#__PURE__*/ react.createElement(ReactComponent, null),
20
+ onClick: ()=>openDialog(CMS_GENERATE_CONTENT_DIALOG, {
21
+ modelId: model.modelId
22
+ })
23
+ });
24
+ });
25
+ export { CmsGenerateContentButton };
26
+
27
+ //# sourceMappingURL=CmsGenerateContentButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin/presentation/CmsContentGeneration/CmsGenerateContentButton.js","sources":["../../../../src/admin/presentation/CmsContentGeneration/CmsGenerateContentButton.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { IconButton } from \"@webiny/admin-ui\";\nimport { ReactComponent as ChatIcon } from \"@webiny/icons/auto_fix_high.svg\";\nimport { useOpenDialog } from \"@webiny/app-admin\";\nimport { useModel } from \"@webiny/app-headless-cms/admin/components/ModelProvider/useModel.js\";\nimport { CMS_GENERATE_CONTENT_DIALOG } from \"./CmsGenerateContentDialog.js\";\nimport { useAiPowerUpsSettings } from \"~/admin/presentation/AiPowerUpsSettings/index.js\";\nimport { useContentEntryFormPresenter } from \"@webiny/app-headless-cms/exports/admin/cms/entry/editor.js\";\n\nexport const CmsGenerateContentButton = observer(() => {\n const { openDialog } = useOpenDialog();\n const { settings } = useAiPowerUpsSettings();\n const { model } = useModel();\n const presenter = useContentEntryFormPresenter();\n\n if (!presenter.vm.canSave) {\n return null;\n }\n\n if (!settings || settings.providers.presets.length === 0) {\n return null;\n }\n\n return (\n <IconButton\n variant=\"ghost\"\n icon={<ChatIcon />}\n onClick={() => openDialog(CMS_GENERATE_CONTENT_DIALOG, { modelId: model.modelId })}\n />\n );\n});\n"],"names":["CmsGenerateContentButton","observer","openDialog","useOpenDialog","settings","useAiPowerUpsSettings","model","useModel","presenter","useContentEntryFormPresenter","IconButton","ChatIcon","CMS_GENERATE_CONTENT_DIALOG"],"mappings":";;;;;;;;;AAUO,MAAMA,2BAA2BC,SAAS;IAC7C,MAAM,EAAEC,UAAU,EAAE,GAAGC;IACvB,MAAM,EAAEC,QAAQ,EAAE,GAAGC;IACrB,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAClB,MAAMC,YAAYC;IAElB,IAAI,CAACD,UAAU,EAAE,CAAC,OAAO,EACrB,OAAO;IAGX,IAAI,CAACJ,YAAYA,AAAsC,MAAtCA,SAAS,SAAS,CAAC,OAAO,CAAC,MAAM,EAC9C,OAAO;IAGX,OAAO,WAAP,GACI,oBAACM,YAAUA;QACP,SAAQ;QACR,oBAAM,oBAACC,gBAAQA;QACf,SAAS,IAAMT,WAAWU,6BAA6B;gBAAE,SAASN,MAAM,OAAO;YAAC;;AAG5F"}
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ export declare const CMS_GENERATE_CONTENT_DIALOG = "cms-generate-content";
3
+ export declare const CmsGenerateContentDialog: (() => React.JSX.Element) & {
4
+ displayName: string;
5
+ };
@@ -0,0 +1,106 @@
1
+ import react, { useEffect, useRef } from "react";
2
+ import { observer } from "mobx-react-lite";
3
+ import { FormView, useDialog } from "@webiny/app-admin";
4
+ import { Dialog, OverlayLoader, useToast } from "@webiny/admin-ui";
5
+ import { useFeature } from "@webiny/app";
6
+ import { useWebsockets } from "@webiny/app-websockets";
7
+ import { useContentEntryFormPresenter } from "@webiny/app-headless-cms/presentation/contentEntries/form/useContentEntryFormPresenter.js";
8
+ import { CmsGenerateContentFeature } from "./feature.js";
9
+ import { decompressGzipBase64 } from "../WbContentGeneration/decompressGzipBase64.js";
10
+ function formatElapsed(totalSeconds) {
11
+ const minutes = Math.floor(totalSeconds / 60);
12
+ const seconds = totalSeconds % 60;
13
+ return `${minutes}:${seconds.toString().padStart(2, "0")}`;
14
+ }
15
+ const CMS_GENERATE_CONTENT_DIALOG = "cms-generate-content";
16
+ const WS_ACTION_CONTENT = "aiPowerUps.generateEntryContent.content";
17
+ const WS_ACTION_ERROR = "aiPowerUps.generateEntryContent.error";
18
+ const CmsGenerateContentDialog = observer(()=>{
19
+ const { closeDialog, params } = useDialog();
20
+ const { presenter } = useFeature(CmsGenerateContentFeature);
21
+ const formPresenter = useContentEntryFormPresenter();
22
+ const vm = presenter.vm;
23
+ const wasSubmitting = useRef(false);
24
+ const websockets = useWebsockets();
25
+ const toast = useToast();
26
+ const modelId = params.modelId;
27
+ useEffect(()=>{
28
+ presenter.init();
29
+ }, []);
30
+ useEffect(()=>{
31
+ const contentSubscription = websockets.onMessage(WS_ACTION_CONTENT, async (message)=>{
32
+ const responseText = await decompressGzipBase64(message.data.value);
33
+ try {
34
+ const entryValues = await presenter.processAiResponse(responseText);
35
+ console.log("entryValues", entryValues);
36
+ const form = formPresenter.vm.form;
37
+ if (form) form.setData(entryValues);
38
+ } catch (e) {
39
+ console.error("Failed to process AI response", {
40
+ responseText
41
+ });
42
+ console.error(e);
43
+ toast.showWarningToast({
44
+ title: "Failed to process AI response",
45
+ description: "Open the console for more details."
46
+ });
47
+ presenter.cancelPrompt();
48
+ }
49
+ });
50
+ const errorSubscription = websockets.onMessage(WS_ACTION_ERROR, async (message)=>{
51
+ toast.showWarningToast({
52
+ title: "Failed to generate content",
53
+ description: message.data.message
54
+ });
55
+ presenter.cancelPrompt();
56
+ });
57
+ return ()=>{
58
+ contentSubscription.off();
59
+ errorSubscription.off();
60
+ };
61
+ }, []);
62
+ useEffect(()=>{
63
+ if (wasSubmitting.current && !vm.submitting && !vm.timedOut) closeDialog();
64
+ wasSubmitting.current = vm.submitting;
65
+ }, [
66
+ vm.submitting
67
+ ]);
68
+ useEffect(()=>{
69
+ if (vm.timedOut) toast.showWarningToast({
70
+ title: "Request timed out",
71
+ description: "The AI generation took too long. Please try again."
72
+ });
73
+ }, [
74
+ vm.timedOut
75
+ ]);
76
+ const handleSubmit = async ()=>{
77
+ await presenter.submit(modelId);
78
+ };
79
+ return /*#__PURE__*/ react.createElement(Dialog, {
80
+ open: true,
81
+ onClose: closeDialog,
82
+ title: "Generate Entry Content",
83
+ size: "lg",
84
+ actions: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Dialog.CancelAction, {
85
+ onClick: closeDialog,
86
+ text: "Cancel"
87
+ }), /*#__PURE__*/ react.createElement(Dialog.ConfirmAction, {
88
+ onClick: handleSubmit,
89
+ text: "Generate",
90
+ disabled: vm.loading || vm.submitting
91
+ }))
92
+ }, vm.loading ? /*#__PURE__*/ react.createElement(OverlayLoader, {
93
+ text: "Loading..."
94
+ }) : null, vm.submitting ? /*#__PURE__*/ react.createElement(OverlayLoader, {
95
+ className: "bg-neutral-base/90",
96
+ text: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement("div", null, "Generating content... ", formatElapsed(vm.elapsedSeconds)), /*#__PURE__*/ react.createElement("div", {
97
+ className: "text-sm text-neutral-muted pt-xs"
98
+ }, "Content generation can take a few minutes, depending on the model you're using."))
99
+ }) : null, vm.form ? /*#__PURE__*/ react.createElement(FormView, {
100
+ name: "CmsGenerateContent",
101
+ form: vm.form
102
+ }) : null);
103
+ });
104
+ export { CMS_GENERATE_CONTENT_DIALOG, CmsGenerateContentDialog };
105
+
106
+ //# sourceMappingURL=CmsGenerateContentDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin/presentation/CmsContentGeneration/CmsGenerateContentDialog.js","sources":["../../../../src/admin/presentation/CmsContentGeneration/CmsGenerateContentDialog.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useDialog, FormView } from \"@webiny/app-admin\";\nimport { Dialog, OverlayLoader, useToast } from \"@webiny/admin-ui\";\nimport { useFeature } from \"@webiny/app\";\nimport type { IncomingGenericData } from \"@webiny/app-websockets\";\nimport { useWebsockets } from \"@webiny/app-websockets\";\nimport { useContentEntryFormPresenter } from \"@webiny/app-headless-cms/presentation/contentEntries/form/useContentEntryFormPresenter.js\";\nimport { CmsGenerateContentFeature } from \"./feature.js\";\nimport { decompressGzipBase64 } from \"~/admin/presentation/WbContentGeneration/decompressGzipBase64.js\";\n\nfunction formatElapsed(totalSeconds: number): string {\n const minutes = Math.floor(totalSeconds / 60);\n const seconds = totalSeconds % 60;\n return `${minutes}:${seconds.toString().padStart(2, \"0\")}`;\n}\n\nexport const CMS_GENERATE_CONTENT_DIALOG = \"cms-generate-content\";\n\nconst WS_ACTION_CONTENT = \"aiPowerUps.generateEntryContent.content\";\nconst WS_ACTION_ERROR = \"aiPowerUps.generateEntryContent.error\";\n\ninterface GenerateEntryContentMessage extends IncomingGenericData {\n action: typeof WS_ACTION_CONTENT;\n data: {\n compression: \"gzip\";\n value: string;\n };\n}\n\ninterface GenerateEntryContentErrorMessage extends IncomingGenericData {\n action: typeof WS_ACTION_ERROR;\n data: {\n message: string;\n };\n}\n\nexport const CmsGenerateContentDialog = observer(() => {\n const { closeDialog, params } = useDialog();\n const { presenter } = useFeature(CmsGenerateContentFeature);\n const formPresenter = useContentEntryFormPresenter();\n const vm = presenter.vm;\n const wasSubmitting = useRef(false);\n const websockets = useWebsockets();\n const toast = useToast();\n const modelId = params.modelId as string;\n\n useEffect(() => {\n presenter.init();\n }, []);\n\n useEffect(() => {\n const contentSubscription = websockets.onMessage<GenerateEntryContentMessage>(\n WS_ACTION_CONTENT,\n async message => {\n const responseText = await decompressGzipBase64(message.data.value);\n try {\n const entryValues = await presenter.processAiResponse(responseText);\n console.log(\"entryValues\", entryValues);\n const form = formPresenter.vm.form;\n if (form) {\n form.setData(entryValues);\n }\n } catch (e) {\n console.error(\"Failed to process AI response\", { responseText });\n console.error(e);\n toast.showWarningToast({\n title: \"Failed to process AI response\",\n description: \"Open the console for more details.\"\n });\n presenter.cancelPrompt();\n }\n }\n );\n\n const errorSubscription = websockets.onMessage<GenerateEntryContentErrorMessage>(\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 && !vm.timedOut) {\n closeDialog();\n }\n wasSubmitting.current = vm.submitting;\n }, [vm.submitting]);\n\n useEffect(() => {\n if (vm.timedOut) {\n toast.showWarningToast({\n title: \"Request timed out\",\n description: \"The AI generation took too long. Please try again.\"\n });\n }\n }, [vm.timedOut]);\n\n const handleSubmit = async () => {\n await presenter.submit(modelId);\n };\n\n return (\n <Dialog\n open={true}\n onClose={closeDialog}\n title=\"Generate Entry 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.loading || vm.submitting}\n />\n </>\n }\n >\n {vm.loading ? <OverlayLoader text={\"Loading...\"} /> : null}\n {vm.submitting ? (\n <OverlayLoader\n className={\"bg-neutral-base/90\"}\n text={\n <>\n <div>Generating content... {formatElapsed(vm.elapsedSeconds)}</div>\n <div className=\"text-sm text-neutral-muted pt-xs\">\n Content generation can take a few minutes, depending on the model\n you&apos;re using.\n </div>\n </>\n }\n />\n ) : null}\n {vm.form ? <FormView name=\"CmsGenerateContent\" form={vm.form} /> : null}\n </Dialog>\n );\n});\n"],"names":["formatElapsed","totalSeconds","minutes","Math","seconds","CMS_GENERATE_CONTENT_DIALOG","WS_ACTION_CONTENT","WS_ACTION_ERROR","CmsGenerateContentDialog","observer","closeDialog","params","useDialog","presenter","useFeature","CmsGenerateContentFeature","formPresenter","useContentEntryFormPresenter","vm","wasSubmitting","useRef","websockets","useWebsockets","toast","useToast","modelId","useEffect","contentSubscription","message","responseText","decompressGzipBase64","entryValues","console","form","e","errorSubscription","handleSubmit","Dialog","OverlayLoader","FormView"],"mappings":";;;;;;;;;AAWA,SAASA,cAAcC,YAAoB;IACvC,MAAMC,UAAUC,KAAK,KAAK,CAACF,eAAe;IAC1C,MAAMG,UAAUH,eAAe;IAC/B,OAAO,GAAGC,QAAQ,CAAC,EAAEE,QAAQ,QAAQ,GAAG,QAAQ,CAAC,GAAG,MAAM;AAC9D;AAEO,MAAMC,8BAA8B;AAE3C,MAAMC,oBAAoB;AAC1B,MAAMC,kBAAkB;AAiBjB,MAAMC,2BAA2BC,SAAS;IAC7C,MAAM,EAAEC,WAAW,EAAEC,MAAM,EAAE,GAAGC;IAChC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAMC,gBAAgBC;IACtB,MAAMC,KAAKL,UAAU,EAAE;IACvB,MAAMM,gBAAgBC,OAAO;IAC7B,MAAMC,aAAaC;IACnB,MAAMC,QAAQC;IACd,MAAMC,UAAUd,OAAO,OAAO;IAE9Be,UAAU;QACNb,UAAU,IAAI;IAClB,GAAG,EAAE;IAELa,UAAU;QACN,MAAMC,sBAAsBN,WAAW,SAAS,CAC5Cf,mBACA,OAAMsB;YACF,MAAMC,eAAe,MAAMC,qBAAqBF,QAAQ,IAAI,CAAC,KAAK;YAClE,IAAI;gBACA,MAAMG,cAAc,MAAMlB,UAAU,iBAAiB,CAACgB;gBACtDG,QAAQ,GAAG,CAAC,eAAeD;gBAC3B,MAAME,OAAOjB,cAAc,EAAE,CAAC,IAAI;gBAClC,IAAIiB,MACAA,KAAK,OAAO,CAACF;YAErB,EAAE,OAAOG,GAAG;gBACRF,QAAQ,KAAK,CAAC,iCAAiC;oBAAEH;gBAAa;gBAC9DG,QAAQ,KAAK,CAACE;gBACdX,MAAM,gBAAgB,CAAC;oBACnB,OAAO;oBACP,aAAa;gBACjB;gBACAV,UAAU,YAAY;YAC1B;QACJ;QAGJ,MAAMsB,oBAAoBd,WAAW,SAAS,CAC1Cd,iBACA,OAAMqB;YACFL,MAAM,gBAAgB,CAAC;gBACnB,OAAO;gBACP,aAAaK,QAAQ,IAAI,CAAC,OAAO;YACrC;YACAf,UAAU,YAAY;QAC1B;QAGJ,OAAO;YACHc,oBAAoB,GAAG;YACvBQ,kBAAkB,GAAG;QACzB;IACJ,GAAG,EAAE;IAELT,UAAU;QACN,IAAIP,cAAc,OAAO,IAAI,CAACD,GAAG,UAAU,IAAI,CAACA,GAAG,QAAQ,EACvDR;QAEJS,cAAc,OAAO,GAAGD,GAAG,UAAU;IACzC,GAAG;QAACA,GAAG,UAAU;KAAC;IAElBQ,UAAU;QACN,IAAIR,GAAG,QAAQ,EACXK,MAAM,gBAAgB,CAAC;YACnB,OAAO;YACP,aAAa;QACjB;IAER,GAAG;QAACL,GAAG,QAAQ;KAAC;IAEhB,MAAMkB,eAAe;QACjB,MAAMvB,UAAU,MAAM,CAACY;IAC3B;IAEA,OAAO,WAAP,GACI,oBAACY,QAAMA;QACH,MAAM;QACN,SAAS3B;QACT,OAAM;QACN,MAAM;QACN,uBACI,wDACI,oBAAC2B,OAAO,YAAY;YAAC,SAAS3B;YAAa,MAAK;0BAChD,oBAAC2B,OAAO,aAAa;YACjB,SAASD;YACT,MAAK;YACL,UAAUlB,GAAG,OAAO,IAAIA,GAAG,UAAU;;OAKhDA,GAAG,OAAO,GAAG,WAAH,GAAG,oBAACoB,eAAaA;QAAC,MAAM;SAAmB,MACrDpB,GAAG,UAAU,GAAG,WAAH,GACV,oBAACoB,eAAaA;QACV,WAAW;QACX,oBACI,wDACI,oBAAC,aAAI,0BAAuBtC,cAAckB,GAAG,cAAc,kBAC3D,oBAAC;YAAI,WAAU;WAAmC;SAO9D,MACHA,GAAG,IAAI,GAAG,WAAH,GAAG,oBAACqB,UAAQA;QAAC,MAAK;QAAqB,MAAMrB,GAAG,IAAI;SAAO;AAG/E"}
@@ -0,0 +1,37 @@
1
+ import { FormModelFactory, ToolPipelineRunner } from "@webiny/app-admin";
2
+ import { CmsGenerateContentPresenter as Abstraction } from "./abstractions.js";
3
+ import { GenerateEntryContentUseCase } from "../../../admin/features/generateEntryContent/index.js";
4
+ import { GetSettingsUseCase } from "../../../admin/features/settings/getSettings/abstractions.js";
5
+ declare class CmsGenerateContentPresenterImpl implements Abstraction.Interface {
6
+ private pipelineRunner;
7
+ private generateEntryContent;
8
+ private formModelFactory;
9
+ private getSettings;
10
+ private _loading;
11
+ private _submitting;
12
+ private _timedOut;
13
+ private _form;
14
+ private _settings;
15
+ private _timeoutId;
16
+ private _intervalId;
17
+ private _elapsedSeconds;
18
+ constructor(pipelineRunner: ToolPipelineRunner.Interface, generateEntryContent: GenerateEntryContentUseCase.Interface, formModelFactory: FormModelFactory.Interface, getSettings: GetSettingsUseCase.Interface);
19
+ get vm(): Abstraction.ViewModel;
20
+ init(): Promise<void>;
21
+ submit(modelId: string): Promise<void>;
22
+ processAiResponse(responseText: string): Promise<Record<string, unknown>>;
23
+ cancelPrompt(): void;
24
+ private startTimeout;
25
+ private clearTimeout;
26
+ private clearInterval;
27
+ private buildForm;
28
+ private getSelectedProject;
29
+ private getProjectFileOptions;
30
+ private computeExcludedFileIds;
31
+ private getProjectOptions;
32
+ private getPersonaOptions;
33
+ }
34
+ export declare const CmsGenerateContentPresenter: typeof CmsGenerateContentPresenterImpl & {
35
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ICmsGenerateContentPresenter>;
36
+ };
37
+ export {};