@paroicms/site-generator-plugin 0.11.0 → 0.12.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/gen-backend/dist/generator/fake-content-generator/content-report.js +81 -0
- package/gen-backend/dist/generator/fake-content-generator/create-database-with-fake-content.js +80 -0
- package/gen-backend/dist/generator/fake-content-generator/fill-nodels.js +115 -0
- package/gen-backend/dist/generator/fake-content-generator/fill-site-fields.js +63 -0
- package/gen-backend/dist/generator/fake-content-generator/fill-taxonomy-fields.js +57 -0
- package/gen-backend/dist/generator/site-generator/site-generator.js +1 -1
- package/gen-backend/dist/generator/site-schema-generator/create-site-schema.js +5 -0
- package/gen-backend/prompts/initial-1-analysis.md +3 -1
- package/gen-front/dist/gen-front.css +1 -1
- package/gen-front/dist/gen-front.mjs +45 -47
- package/package.json +7 -5
- package/gen-backend/dist/generator/fake-content-generator.ts/content-report.js +0 -15
- package/gen-backend/dist/generator/fake-content-generator.ts/create-database-with-fake-content.js +0 -238
- /package/gen-backend/dist/generator/{fake-content-generator.ts → fake-content-generator}/content-helpers.js +0 -0
- /package/gen-backend/dist/generator/{fake-content-generator.ts → fake-content-generator}/create-node-contents.js +0 -0
- /package/gen-backend/dist/generator/{fake-content-generator.ts → fake-content-generator}/fake-content-types.js +0 -0
- /package/gen-backend/dist/generator/{fake-content-generator.ts → fake-content-generator}/generate-fake-content.js +0 -0
- /package/gen-backend/dist/generator/{fake-content-generator.ts → fake-content-generator}/invoke-generate-fake-content.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paroicms/site-generator-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "ParoiCMS Site Generator Plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"paroicms",
|
|
@@ -45,12 +45,14 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@paroi/data-formatters-lib": "~0.4.0",
|
|
48
|
-
"@
|
|
48
|
+
"@paroi/use-async-effect": "~1.0.0",
|
|
49
|
+
"@paroicms/connector": "0.33.1",
|
|
49
50
|
"@paroicms/internal-anywhere-lib": "1.28.0",
|
|
50
|
-
"@paroicms/internal-bo-lib": "1.
|
|
51
|
+
"@paroicms/internal-bo-lib": "1.15.0",
|
|
51
52
|
"@paroicms/public-anywhere-lib": "0.22.0",
|
|
52
|
-
"@paroicms/public-bo-lib": "0.
|
|
53
|
-
"@paroicms/public-server-lib": "0.
|
|
53
|
+
"@paroicms/public-bo-lib": "0.23.0",
|
|
54
|
+
"@paroicms/public-server-lib": "0.33.0",
|
|
55
|
+
"@paroicms/react-ui": "0.1.0",
|
|
54
56
|
"@types/dom-speech-recognition": "^0.0.6",
|
|
55
57
|
"@types/node": "~22.14.1",
|
|
56
58
|
"@types/react": "~19.1.1",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function createGeneratedContentReport() {
|
|
2
|
-
let totalEntryCount = 0;
|
|
3
|
-
const llmReports = [];
|
|
4
|
-
return {
|
|
5
|
-
getResults() {
|
|
6
|
-
return { entryCount: totalEntryCount, llmReports };
|
|
7
|
-
},
|
|
8
|
-
add(entryCount, llmReport) {
|
|
9
|
-
totalEntryCount += entryCount;
|
|
10
|
-
if (llmReport) {
|
|
11
|
-
llmReports.push(llmReport);
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
}
|
package/gen-backend/dist/generator/fake-content-generator.ts/create-database-with-fake-content.js
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { getPartTypeByName, getRegularDocumentTypeByName, getRoutingDocumentTypeByName, } from "@paroicms/internal-anywhere-lib";
|
|
2
|
-
import { createSimpleTranslator, } from "@paroicms/public-server-lib";
|
|
3
|
-
import { updateGeneratedSiteStepSetAsCompleted, } from "../../db/db-write.queries.js";
|
|
4
|
-
import { getRandomImagePath } from "../lib/images-lib.js";
|
|
5
|
-
import { createTaskCollector } from "../lib/tasks.js";
|
|
6
|
-
import { dedupMessages } from "./content-helpers.js";
|
|
7
|
-
import { createGeneratedContentReport } from "./content-report.js";
|
|
8
|
-
import { generateLocalizedFooterMention } from "./create-node-contents.js";
|
|
9
|
-
import { generateFieldSetContent, generateMultipleFieldSetContents, } from "./generate-fake-content.js";
|
|
10
|
-
export async function fillSiteWithFakeContent(ctx, stepHandle, { regSite, localizedValues }) {
|
|
11
|
-
const { service } = ctx;
|
|
12
|
-
const { fqdn } = regSite;
|
|
13
|
-
const report = createGeneratedContentReport();
|
|
14
|
-
const { siteSchema, siteIds } = await service.connector.loadSiteSchemaAndIds(fqdn);
|
|
15
|
-
const schemaI18n = createSimpleTranslator({
|
|
16
|
-
labels: siteSchema.l10n,
|
|
17
|
-
logger: ctx.logger,
|
|
18
|
-
});
|
|
19
|
-
await updateSiteFields(ctx, report, { fqdn, siteSchema, siteTitle: localizedValues.siteTitle });
|
|
20
|
-
const tasks = createTaskCollector(ctx);
|
|
21
|
-
fillRoutingDocumentAndAddChildren(ctx, tasks, report, {
|
|
22
|
-
fqdn,
|
|
23
|
-
siteSchema,
|
|
24
|
-
schemaI18n,
|
|
25
|
-
}, {
|
|
26
|
-
routingIds: siteIds.homeIds,
|
|
27
|
-
nodeType: siteSchema.nodeTypes.home,
|
|
28
|
-
});
|
|
29
|
-
const { promise } = tasks.runAll({ maxParallel: 10, rateLimitPerSecond: 3 });
|
|
30
|
-
const { doneCount, errorMessages } = await promise;
|
|
31
|
-
if (errorMessages.length > 0) {
|
|
32
|
-
ctx.logger.warn(`Failed to generate documents:\n - ${errorMessages.join("\n - ")}`);
|
|
33
|
-
}
|
|
34
|
-
ctx.logger.debug(`… Executed ${doneCount} generating tasks`);
|
|
35
|
-
const results = report.getResults();
|
|
36
|
-
await updateGeneratedSiteStepSetAsCompleted(ctx, stepHandle, {
|
|
37
|
-
status: "completed",
|
|
38
|
-
contentEntryCount: results.entryCount,
|
|
39
|
-
contentInputTokenCount: results.llmReports.reduce((acc, r) => acc + r.inputTokenCount, 0),
|
|
40
|
-
contentOutputTokenCount: results.llmReports.reduce((acc, r) => acc + (r.outputTokenCount ?? 0), 0),
|
|
41
|
-
contentErrors: errorMessages.length > 0 ? errorMessages.join("\n - ") : null,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function fillRoutingDocumentAndAddChildren(ctx, tasks, report, siteOptions, nodeOptions) {
|
|
45
|
-
const { routingIds, nodeType } = nodeOptions;
|
|
46
|
-
const { siteSchema } = siteOptions;
|
|
47
|
-
tasks.add(() => updateRoutingDocument(ctx, report, siteOptions, nodeOptions));
|
|
48
|
-
for (const listType of nodeType.lists ?? []) {
|
|
49
|
-
for (const typeName of listType.parts) {
|
|
50
|
-
const partType = getPartTypeByName(siteSchema, typeName);
|
|
51
|
-
tasks.add(() => addParts(ctx, report, siteOptions, {
|
|
52
|
-
parentNodeId: routingIds.nodeId,
|
|
53
|
-
nodeType: partType,
|
|
54
|
-
documentType: nodeType,
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
for (const typeName of nodeType.routingChildren ?? []) {
|
|
59
|
-
const childType = getRoutingDocumentTypeByName(siteSchema, typeName);
|
|
60
|
-
const childIds = routingIds.children?.[typeName];
|
|
61
|
-
if (!childIds)
|
|
62
|
-
throw new Error(`Missing childIds for ${typeName}`);
|
|
63
|
-
fillRoutingDocumentAndAddChildren(ctx, tasks, report, siteOptions, {
|
|
64
|
-
routingIds: childIds,
|
|
65
|
-
nodeType: childType,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
for (const typeName of nodeType.regularChildren ?? []) {
|
|
69
|
-
const childType = getRegularDocumentTypeByName(siteSchema, typeName);
|
|
70
|
-
tasks.add(() => addRegularDocuments(ctx, report, siteOptions, {
|
|
71
|
-
parentNodeId: routingIds.nodeId,
|
|
72
|
-
nodeType: childType,
|
|
73
|
-
documentType: childType,
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
async function updateSiteFields(ctx, _report, options) {
|
|
78
|
-
const { service, logger } = ctx;
|
|
79
|
-
logger.debug("Updating site fields…");
|
|
80
|
-
const { fqdn, siteSchema, siteTitle } = options;
|
|
81
|
-
const siteType = siteSchema.nodeTypes._site;
|
|
82
|
-
const logoImageFile = getRandomImagePath();
|
|
83
|
-
const fields = [
|
|
84
|
-
[
|
|
85
|
-
"title",
|
|
86
|
-
{
|
|
87
|
-
dataType: "string",
|
|
88
|
-
localized: true,
|
|
89
|
-
value: siteTitle,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
[
|
|
93
|
-
"favicon",
|
|
94
|
-
{
|
|
95
|
-
dataType: "media",
|
|
96
|
-
localized: false,
|
|
97
|
-
value: {
|
|
98
|
-
file: logoImageFile,
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
[
|
|
103
|
-
"ogImage",
|
|
104
|
-
{
|
|
105
|
-
dataType: "media",
|
|
106
|
-
localized: false,
|
|
107
|
-
value: {
|
|
108
|
-
file: logoImageFile,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
];
|
|
113
|
-
if (siteType.fields.some((f) => f.name === "logo")) {
|
|
114
|
-
fields.push([
|
|
115
|
-
"logo",
|
|
116
|
-
{
|
|
117
|
-
dataType: "media",
|
|
118
|
-
localized: false,
|
|
119
|
-
value: {
|
|
120
|
-
file: logoImageFile,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
]);
|
|
124
|
-
}
|
|
125
|
-
if (siteType.fields.some((f) => f.name === "footerMention")) {
|
|
126
|
-
fields.push([
|
|
127
|
-
"footerMention",
|
|
128
|
-
{
|
|
129
|
-
dataType: "json",
|
|
130
|
-
localized: true,
|
|
131
|
-
value: generateLocalizedFooterMention(siteSchema),
|
|
132
|
-
},
|
|
133
|
-
]);
|
|
134
|
-
}
|
|
135
|
-
await service.connector.updateSiteFields(fqdn, Object.fromEntries(fields));
|
|
136
|
-
logger.debug("… Site fields updated");
|
|
137
|
-
}
|
|
138
|
-
async function updateRoutingDocument(ctx, report, siteOptions, nodeOptions) {
|
|
139
|
-
ctx.logger.debug(`[TASK] Updating routing document "${nodeOptions.nodeType.typeName}"…`);
|
|
140
|
-
const { routingIds, nodeType } = nodeOptions;
|
|
141
|
-
const { fqdn, siteSchema, schemaI18n } = siteOptions;
|
|
142
|
-
const content = await generateFieldSetContent(ctx, {
|
|
143
|
-
nodeType,
|
|
144
|
-
documentType: nodeType,
|
|
145
|
-
siteSchema,
|
|
146
|
-
schemaI18n,
|
|
147
|
-
withTitle: false,
|
|
148
|
-
llmTaskName: nodeType.kebabName,
|
|
149
|
-
}, report);
|
|
150
|
-
await ctx.service.connector.updateDocumentContent(fqdn, {
|
|
151
|
-
nodeId: routingIds.nodeId,
|
|
152
|
-
content: toRiDocumentContent(content, nodeType),
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
async function addRegularDocuments(ctx, report, siteOptions, nodeOptions) {
|
|
156
|
-
ctx.logger.debug(`[TASK] Adding regular documents "${nodeOptions.nodeType.typeName}"…`);
|
|
157
|
-
const { parentNodeId, nodeType, documentType } = nodeOptions;
|
|
158
|
-
const { fqdn, siteSchema, schemaI18n } = siteOptions;
|
|
159
|
-
const tolerateErrors = {
|
|
160
|
-
errorMessages: [],
|
|
161
|
-
};
|
|
162
|
-
const list = await generateMultipleFieldSetContents(ctx, {
|
|
163
|
-
siteSchema,
|
|
164
|
-
nodeType,
|
|
165
|
-
documentType,
|
|
166
|
-
schemaI18n,
|
|
167
|
-
count: getDefaultNodeContentCount(nodeType),
|
|
168
|
-
withTitle: true,
|
|
169
|
-
tolerateErrors,
|
|
170
|
-
llmTaskName: nodeType.kebabName,
|
|
171
|
-
}, report);
|
|
172
|
-
const errorMessages = dedupMessages(tolerateErrors.errorMessages);
|
|
173
|
-
if (errorMessages.length > 0) {
|
|
174
|
-
ctx.logger.warn(`Error generating content for ${nodeType.typeName}:\n - ${errorMessages.join("\n - ")}`);
|
|
175
|
-
}
|
|
176
|
-
await ctx.service.connector.addMultipleDocumentContents(fqdn, {
|
|
177
|
-
parentNodeId,
|
|
178
|
-
contents: list.map((content) => toRiDocumentContent(content, nodeType)),
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
async function addParts(ctx, report, siteOptions, nodeOptions) {
|
|
182
|
-
ctx.logger.debug(`[TASK] Adding parts "${nodeOptions.nodeType.typeName}"…`);
|
|
183
|
-
const { parentNodeId, nodeType, documentType } = nodeOptions;
|
|
184
|
-
const { fqdn, siteSchema, schemaI18n } = siteOptions;
|
|
185
|
-
const tolerateErrors = {
|
|
186
|
-
errorMessages: [],
|
|
187
|
-
};
|
|
188
|
-
const list = await generateMultipleFieldSetContents(ctx, {
|
|
189
|
-
siteSchema,
|
|
190
|
-
nodeType,
|
|
191
|
-
documentType,
|
|
192
|
-
schemaI18n,
|
|
193
|
-
count: getDefaultNodeContentCount(nodeType),
|
|
194
|
-
withTitle: true,
|
|
195
|
-
tolerateErrors,
|
|
196
|
-
llmTaskName: nodeType.kebabName,
|
|
197
|
-
}, report);
|
|
198
|
-
const errorMessages = dedupMessages(tolerateErrors.errorMessages);
|
|
199
|
-
if (errorMessages.length > 0) {
|
|
200
|
-
ctx.logger.warn(`Error generating content for ${nodeType.typeName}:\n - ${errorMessages.join("\n - ")}`);
|
|
201
|
-
}
|
|
202
|
-
await ctx.service.connector.addMultiplePartContents(fqdn, {
|
|
203
|
-
parentNodeId,
|
|
204
|
-
contents: list.map((content) => toRiPartContent(content, nodeType)),
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
function toRiDocumentContent(content, nodeType) {
|
|
208
|
-
const { title, fields, featuredImage } = content;
|
|
209
|
-
return {
|
|
210
|
-
kind: "document",
|
|
211
|
-
typeName: nodeType.typeName,
|
|
212
|
-
title,
|
|
213
|
-
featuredImage,
|
|
214
|
-
fields,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
function toRiPartContent(content, nodeType) {
|
|
218
|
-
const { fields } = content;
|
|
219
|
-
return {
|
|
220
|
-
kind: "part",
|
|
221
|
-
typeName: nodeType.typeName,
|
|
222
|
-
fields,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function getDefaultNodeContentCount(nodeType) {
|
|
226
|
-
if (nodeType.kind === "site")
|
|
227
|
-
throw new Error("Cannot generate content for site node type");
|
|
228
|
-
if (nodeType.kind === "document") {
|
|
229
|
-
if (nodeType.documentKind === "routing")
|
|
230
|
-
return 1;
|
|
231
|
-
if (nodeType.route === ":yyyy/:mm/:dd/:relativeId-:slug")
|
|
232
|
-
return 14; // 4
|
|
233
|
-
return 8; // 2
|
|
234
|
-
}
|
|
235
|
-
if (nodeType.kind === "part")
|
|
236
|
-
return 8; // 2
|
|
237
|
-
throw new Error(`Unknown node type kind: ${nodeType.kind}`);
|
|
238
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|