Skip to content

Commit 06cc29d

Browse files
Copilotthebuilder
andcommitted
Remove auto-fetch functionality, revert to original behavior when no cultures provided
Co-authored-by: thebuilder <[email protected]>
1 parent c9efe0d commit 06cc29d

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/umb-management-api/tools/document/__tests__/create-document.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ describe("create-document", () => {
9898
expect(cultures).toEqual(["da-DK", "en-US"]);
9999
});
100100

101-
it("should create a document with empty cultures array (auto-fetch behavior)", async () => {
102-
// Create document with empty cultures array - should behave same as no cultures parameter
101+
it("should create a document with empty cultures array (null culture)", async () => {
102+
// Create document with empty cultures array - should behave like original (null culture)
103103
const docModel = {
104104
documentTypeId: ROOT_DOCUMENT_TYPE_ID,
105105
name: TEST_DOCUMENT_NAME,
@@ -115,8 +115,8 @@ describe("create-document", () => {
115115

116116
const item = await DocumentTestHelper.findDocument(TEST_DOCUMENT_NAME);
117117
expect(item).toBeDefined();
118-
// Should fetch cultures and create variants (same as when cultures parameter is omitted)
119-
// The exact number of variants depends on available cultures in the test environment
120-
expect(item!.variants.length).toBeGreaterThanOrEqual(1);
118+
// Should have single variant with null culture (original behavior)
119+
expect(item!.variants).toHaveLength(1);
120+
expect(item!.variants[0].culture).toBeNull();
121121
});
122122
});

src/umb-management-api/tools/document/post/create-document.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const createDocumentSchema = z.object({
1010
documentTypeId: z.string().uuid("Must be a valid document type type UUID"),
1111
parentId: z.string().uuid("Must be a valid document UUID").optional(),
1212
name: z.string(),
13-
cultures: z.array(z.string()).optional().describe("Array of culture codes. If not provided, will fetch available cultures from Umbraco."),
13+
cultures: z.array(z.string()).optional().describe("Array of culture codes. If not provided or empty array, will create single variant with null culture."),
1414
values: z
1515
.array(
1616
z.object({
@@ -29,7 +29,7 @@ const CreateDocumentTool = CreateUmbracoTool(
2929
`Creates a document with support for multiple cultures.
3030
3131
If cultures parameter is provided, a variant will be created for each culture code.
32-
If cultures parameter is not provided, the tool will automatically fetch available cultures from Umbraco and create variants for all of them.
32+
If cultures parameter is not provided or is an empty array, will create a single variant with null culture (original behavior).
3333
3434
Always follow these requirements when creating documents exactly, do not deviate in any way.
3535
@@ -641,18 +641,8 @@ const CreateDocumentTool = CreateUmbracoTool(
641641
let culturesToUse: (string | null)[] = [];
642642

643643
if (model.cultures === undefined || model.cultures.length === 0) {
644-
// If cultures not provided or empty array, fetch available cultures from Umbraco
645-
try {
646-
const cultureResponse = await client.getCulture({ take: 100 });
647-
culturesToUse = cultureResponse.items.map(culture => culture.name);
648-
// If no cultures available, fallback to null culture
649-
if (culturesToUse.length === 0) {
650-
culturesToUse = [null];
651-
}
652-
} catch (error) {
653-
// If fetching cultures fails, fallback to null culture
654-
culturesToUse = [null];
655-
}
644+
// If cultures not provided or empty array, use original behavior (null culture)
645+
culturesToUse = [null];
656646
} else {
657647
// Use provided cultures
658648
culturesToUse = model.cultures;

0 commit comments

Comments
 (0)